Repository navigation
feat(agent): continue bounded turns from provider stop reasons - #75
Merged
austinchennn merged 1 commit intoOct 23, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
A response could end successfully at the transport layer while generation was truncated. AgentSession previously continued only after tool calls, so a no-tool token limit or provider pause ended the user turn early. Carry a provider-neutral stop reason and continue within a bounded per-turn budget.
Fixes:
No linked issue. Implements the requested stop-reason continuation contract; the paired vdoc-server integration pins local SDK packages until an upstream release is available.
Behaviours Completed:
stopReasonandrawStopReasonto response endings and cascade text finishes; exportStopReasonfrom core while preserving existing response statuses.max_tokensandpauseeven without tools. Wait for every issued tool result before deciding; preserve the existing validation, authorization, serial execution and interruption gates.tool_callswithout actual calls. Providers that omit reasons retain the previous inference behavior.maxContinuations, reset the budget on new input, and reportcontinuation_limitwhen exhausted.Files Changed:
packages/core/src/{events,agent,index,session}.ts: public contract, metrics, bounded scheduling and lifecycle guards.packages/openai-compatible/src/index.ts: provider mapping and short raw-reason preservation.packages/cascade/src/index.ts: finish propagation after synthesized audio completes; preserve conversation history for continuations.Brief Explanation:
Transport status remains independent of generation stop reason. The runtime makes one decision only after the response has ended and its issued calls have settled; subsequent generations stay in the same turn. Only real tool feedback uses
autoReplyAfterResult. No fabricated user messages, write replay, provider network retries or browser wire-protocol changes are introduced. This branch is based on current upstream main, including bounded cascade history.Testing:
npm run typecheck: passed.npm test: 591 tests across 34 files passed on current upstream main.npm run pack,npm run check:budgets,npm run check:specandgit diff --check: passed.max_tokens → pause → completed, terminal outcomes with and without tools, budget reset/default/zero, late interrupted responses, duplicate usage and preserved assistant/tool history.Unsure About:
completedmeans generation ended, not that a business task or document write succeeded. Tool results and application verification retain that responsibility.