Skip to content

fix: 模型输出不可解析时优雅降级 + 记录原始输出便于诊断#8

Merged
NeverENG merged 1 commit into
mainfrom
fix/graceful-degradation
May 30, 2026
Merged

fix: 模型输出不可解析时优雅降级 + 记录原始输出便于诊断#8
NeverENG merged 1 commit into
mainfrom
fix/graceful-degradation

Conversation

@NeverENG

Copy link
Copy Markdown
Owner

背景

真实实测(BanDB#48)暴露:DeepSeek 返回了空的结构化结果,重试后仍空,旧代码抛原始 ZodError → Action 变红且什么都没发,违背"不阻塞"原则;而且看不到模型到底返回了什么,无法诊断。

改动

  • review() 在重试耗尽且输出不可解析时抛 InvalidModelOutputError,携带原始输出。
  • Action 捕获它:把原始输出片段 + token 用量打到日志(下次运行即可看到模型究竟返回了什么),upsert 一条"未能生成有效评审(不阻塞合入,可重试/换强模型)"的降级评论,然后绿着退出。其它错误仍然失败。

价值

既修了健壮性缺口(弱模型返回垃圾不该让工具崩),又为当前这个"空输出"问题提供了诊断手段。

验证

55 个单测全绿(新增 errors 测试 + 降级评论测试 + review 错误类型断言);bundle 已重打包。

🤖 Generated with Claude Code

…gnosis

A weak model occasionally returns an empty/invalid structured result; after
retries this threw a raw ZodError, failing the run and posting nothing
(contradicts the non-blocking design). Now:
- review() surfaces InvalidModelOutputError carrying the raw output.
- The Action catches it: logs the raw output snippet + token usage (so the run
  log reveals what the model returned), upserts a degraded "couldn't generate
  a valid review" comment, and exits green (non-blocking). Other errors still
  fail the run.

55 tests green; bundle rebuilt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NeverENG NeverENG merged commit f23ddcc into main May 30, 2026
1 check passed
@NeverENG NeverENG deleted the fix/graceful-degradation branch May 30, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant