fix(runtime): retry output-free provider finishes - #3777
Conversation
Generated-by: OpenAI Codex
Astro-Han
left a comment
There was a problem hiding this comment.
I reviewed this head and found no blocking issues.
The fix correctly classifies output-free stop without usage as incomplete for bounded recovery, and routes network_error raw finishes to retryable network failure. Usage accounting retains failed-request usage and remains fail-closed. Two minor P3 observations remain non-blocking (evidence accumulation across steps, finish-without-step-finish usage fallback).
Checks on fe53c1529 are test: success.
简体中文
该头未发现阻断,两处 P3 观察已记录。|
Reviewed the production diff. The fix is right and the test weight is proportionate — 816 of the 985 added lines are tests, covering the branches that actually fork (metadata-only evidence, authoritative zero usage, exhausted-retry metering). Two non-blocking notes, both about where the new logic lives rather than whether it is correct. P2 —
The owner here is P3 — the Backend recomputes what the adapter has already computed. The adapter's iterator already walks the translated stream and derives
Not raised as a change request here: Reviewed with help from Claude. 简体中文看了生产代码部分。修复方向是对的,测试的分量也匹配——985 行新增里有 816 行是测试,覆盖的都是真会分叉的分支(只有 metadata 的证据、权威零 usage、重试耗尽后的计费)。两条意见,都不阻塞,说的是新逻辑该放在哪里,而不是它对不对。 P2 ——
真正的所有者是 #2297 引入的 P3 —— Backend 重算了一遍 adapter 已经算出来的东西。 adapter 的迭代器已经走过完整的翻译流,算出了
这里不作为修改要求提出: 本次 Review 有 Claude 协助。 |
Dismissing my earlier approval — follow-up review found two non-blocking items (P2/P3) worth settling first; details in the review comment above.
|
Addressed both review notes in 776d3f5.
Local verification is green, including the full affected workspace suites, release contracts, and the installed CLI package smoke. For the broader finish-reason vocabulary consolidation tracked in #3802, this fix does not make further changes at this time. 简体中文已在 776d3f5 中处理两条评审意见。
本地验证全部通过,包括受影响工作区的完整测试、发布契约检查和安装后的 CLI 包冒烟测试。 对于 #3802 中跟踪的更广泛 finish-reason 语义统一工作,本次修复工作暂不作进一步调整。 |
Summary
stopwith unavailable usage as an incomplete provider response instead of a successfulend_turn; retry it through the existing bounded recovery path and fail explicitly withprovider_unavailablewhen recovery is exhausted.network_errorfinish reason through the existing bounded network retry policy.Fixes #3772
Verification
npm --workspace @maka/runtime test— 3,047 passed, 13 skipped, 0 failed.npm run lint,npm run format:check,npm run build, andnpm run typecheck— passed.git diff --check— passed.Not run: a live OpenRouter/Ox Alpha reproduction because the provider-controlled empty finish is intermittent; deterministic Runtime fixtures cover the exact observed
stopandnetwork_errorframes.Review focus
stopis recoverable only when it has no model-response evidence and no usable usage.network_errorvalue enters the network retry path.AI use
Select exactly one:
Tool(s) and scope: OpenAI Codex traced the provider-finish settlement, retry, persistence, and usage-accounting paths; implemented the Runtime changes and regression tests; ran local verification; and performed adversarial review of the final diff. I reviewed the resulting implementation, tests, and PR description and decided to submit the change.
Checklist
Does this PR entail a change in behavior?