Repository navigation
fix(runtime): retry output-free unmetered stop finishes - #5849
garvit-arora wants to merge 2 commits into
Conversation
Treat output-free, unmetered provider stop frames as retryable failures instead of successful end_turn completions, and route output-free network_error finishes through the existing network retry policy. Generated-by: Cursor Co-authored-by: Cursor <[email protected]>
hqhq1025
left a comment
There was a problem hiding this comment.
Reviewed exact head 68d6d29a71f90d6f342500b0787393483b705634. The change records step output in the model adapter, retries an output-free unmetered stop as provider_unavailable, and routes an output-free network_error through network retry. It preserves an explicit zero-usage stop and adds adapter/backend regressions. One P2 boundary remains, inline, so I would not merge this head yet.
Node 24 core/storage/runtime builds passed. Twelve focused output-free/settlement tests passed. A broader two-file test run was stopped after it stalled without further output; it is not counted as a pass. Fetched-main merge-tree and git diff --check are clean. Hosted CI is action_required, so there is no current-head test result. I did not run a live provider or full Runtime suite.
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.
| return event.text.length > 0; | ||
| case 'tool-call': | ||
| case 'provider-tool-result': | ||
| case 'tool-input': |
There was a problem hiding this comment.
[P2] Do not treat a tool-input marker as completed step output. The SDK can emit tool-input-start before any tool-call or provider result. With {stream-start, tool-input-start, finish(stop, unavailable usage)}, the stream exposes only a tool-input marker, yet this branch sets sawStepOutput and settleModelStepOutcome() returns completed. I reproduced that on this head with providerExecuted both false and true. With no returned tool call, the Runtime takes the success path and ends the Turn without an answer, retry, or error—the failure this change is meant to prevent. Keep the marker for replay-safety accounting, but require actual text/reasoning or a completed tool call/result for successful settlement; a provider-executed partial input must fail rather than blindly retry. Please cover this terminal sequence in the adapter/backend tests.
Output-free stop settlement must not treat a bare tool-input-start marker as completed step output. Cover the terminal tool-input + stop sequences in adapter and backend regressions. Generated-by: Cursor Co-authored-by: Cursor <[email protected]>
|
Addressed in 7d18949: removed \ ool-input\ from \streamEventCountsAsStepOutput()\ and added adapter/backend regressions for tool-input-start + output-free \stop\ (both \providerExecuted\ false and true). |
hqhq1025
left a comment
There was a problem hiding this comment.
Reviewed commit 7d18949563aca7a95349972039465534f24e700b. This update fixes the issue I reported on the previous head: a bare tool-input-start no longer counts as completed step output (packages/runtime/src/model-adapter.ts:710-720), so an unmetered, output-free stop fails rather than silently completing an empty turn. The new adapter cases cover client and provider-executed markers (packages/runtime/src/__tests__/model-adapter-onerror.test.ts:486-507); backend cases verify retry/recovery for the client marker and refusal to retry after provider-side effects (packages/runtime/src/__tests__/ai-sdk-backend.test.ts:8877-8977). I found no new substantiated P0–P3 issue in this increment and the previously reported P2 is resolved on this head.
The Runtime build and 15 focused output-free/retry tests passed locally. A broader two-file test run did not complete: 172 tests passed, then one backend file was cancelled with a pending-promise diagnostic, so I do not count it as a full-suite pass. No hosted checks are currently attached to this head. The branch merges cleanly with current main; I did not test a live provider or the complete Runtime suite. This is not merge approval.
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.
Summary
Providers can end a model step with
finishReason: stop(or rawnetwork_error) while emitting no text, reasoning, tool calls, or authoritative usage. Maka previously settled those frames ascompleted/end_turn, so unfinished work could appear successful.This change tracks per-step output during stream translation and updates
settleModelStepOutcome()to:stopas retryableprovider_unavailablenetwork_errorthrough the existing network retry policyFixes #3772
Happy to coordinate with @sunrioa if work is already in progress elsewhere.
Verification
lintandformat:checkpass@maka/runtimebuild, typecheck, and fulltest:distsuite pass (274 tests)typecheckfails locally on an unrelated@maka/evalresolution inpackages/cli(pre-existing in this checkout)AI use
Select exactly one:
Tool(s) and scope:
Cursor — implementation and tests for runtime step settlement and backend retry coverage.
Checklist
Does this PR entail a change in behavior?