Uh oh!
There was an error while loading. Please reload this page.
fix(runtime): seal partial thinking before retrying mid-stream network cuts - #4393
fix(runtime): seal partial thinking before retrying mid-stream network cuts#4393chinawch007 wants to merge 1 commit into
Conversation
hqhq1025
left a comment
There was a problem hiding this comment.
I did not find a P0-P3 correctness issue in the exact-head change. The new path permits only retryable failures whose physical request emitted thinking but no answer text, tool activity, continuation metadata, or completed step boundary; it seals that fragment under the current message id, rotates the id, and allows one such recovery per provider step. The added tests cover the successful retry, no-output retry, the one-fragment budget, and the continuation-metadata exclusion.
Validation on this exact head passed: clean install, npm run build:test, full repository typecheck, lint, format, git diff --check, and the complete Runtime suite (3081 passed, 13 skipped). The PR is currently CONFLICTING/DIRTY against main and has no hosted test result. I also performed a local semantic conflict resolution that preserves current main’s ordered reasoning-parts accumulator; the merged tree passed build:test, full typecheck, and the complete Runtime suite (3105 passed, 13 skipped). This is therefore a technical code-review GO for the reviewed head, not a merge-ready decision; the author still needs to rebase and obtain current-head hosted checks.
I did not exercise a real paid provider or reproduce the original macOS gateway incident.
Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.
d046ea5 to
304e6cdComparechinawch007
commented
Sep 1, 2026
Thanks for your attention, resolved the conflicts. |
…k cuts A thinking-only attempt that failed with a retryable provider/network error (the 2026-08-28 ECONNRESET incident: reset landed seconds before the 120s idle watchdog would have) ended the turn, while the identical attempt state recovered when the watchdog noticed the failure first. Recovery safety depends on what the attempt emitted, not on which side detected the cut: thinking is sealable, so the plain retryable path now accepts thinking-only attempts with the same flushStep() + fresh-message-id contract as the watchdog path, under its own budget of one recovery per step so a systematically cutting gateway fails fast instead of accumulating sealed fragments across the full attempt budget. The sealed fragment stays out of the retried request's provider context. Answer text, tool activity, and provider continuation metadata remain non-retryable; the watchdog and truncated-stream paths are unchanged. Fixesapache#4284 Generated-by: ZCode
304e6cd to
99720efCompare
Summary
A thinking-only streaming attempt that died from a retryable network error
ended the turn, while the identical attempt state recovered when the 120s
idle watchdog fired first — in the #4284 incident an ECONNRESET landed
seconds before the watchdog would have, so the same fault got opposite
outcomes depending on which detector noticed it. Recovery safety depends on
what the attempt emitted, not on which side detected the cut.
The plain retryable path now accepts thinking-only attempts under the seal
contract the watchdog path already uses:
flushStep()closes the partialthinking as a message under its own id, the retry streams into a fresh id,
and the sealed fragment stays out of the retried request's provider context.
It carries its own budget (
MAX_SEALED_THINKING_RETRIES_PER_STEP = 1) so agateway that systematically cuts long thinking streams fails fast instead of
accumulating fragments across the full attempt budget. The new
sealedThinkingRecoveryflag is mutually exclusive with the other threeretry paths by construction.
Answer text, tool activity, and provider continuation metadata remain
non-retryable; the watchdog and truncated-stream paths are unchanged.
Fixes#4284
Verification
npm run format:check— clean (8 formatting nits auto-fixed and folded in)npm run lint— 2304 files, no issuesnpm run typechecknpm --workspace @maka/runtime run build— cleannpm --workspace @maka/runtime run test:dist— 3107 tests, 3094 pass, 13 skipNot run: the full root-level battery (
npm run lint,format:check,workspace-wide tests, knip).
AI use
Select exactly one:
Tool(s) and scope: ZCode — analyzed the issue, authored the implementation
and tests from that analysis under a plan reviewed by the contributor; every
step was human-reviewed and verified locally.
Checklist
Does this PR entail a change in behavior?