Repository navigation
feat(agent): continue the same run when the output budget runs out - #1595
Merged
Merged
Conversation
A run that hits the per-response output limit ended as `incomplete` and
handed control back to the user. In an interactive session that meant a
"继续" button; in an unattended goal worker it meant a retry that re-sent
the same prompt, and when the entire budget had gone to reasoning (measured:
three turns at 32,768 tokens, 32,761 of them reasoning, zero visible
characters) that retry was a guaranteed repeat of the same wall — the
reasoning-only assistant message is dropped by `convert_to_llm`, so nothing
survived to continue from.
The run now keeps writing after `finish_length`, up to
MAX_OUTPUT_LIMIT_CONTINUATIONS (2) continuations, on its own budget separate
from the reconnect allowance and gated by the same `max_retries > 0` switch
so `set_auto_retry(false)` and fusion are unaffected.
Two cuts, two instructions. A cut with visible text keeps the prefix in
history and asks the model to continue from the break. A cut with no visible
text has nothing to extend, so the model is asked to stop deliberating and
answer — and the thinking level is stepped one notch down (fixed scale,
filtered through the model's declared levels, never through `default`), so
the continuation is not the identical request that just failed. Stepping
down touches only this run's private provider snapshot, never the session
setting.
The truncated turn's assistant message is not rebound: it is already
persisted under this step's `stream_entry_id`, and a second payload under one
identity is rejected by the transcript store as "conflicting entry identity"
(found by running the new tests against the first implementation). The
continuation path only appends placeholders for unexecuted tool calls and
reuses `retry_text` to carry the delivered text forward.
Observable as `output_stream_continuing` {attempt, maxContinuations,
thinkingLevel?} — not a reconnect, the reply keeps growing — and the
truncation banner no longer appears while a continuation is still possible.
When the allowance is spent the original `incomplete` semantics apply
unchanged, so the goal worker fallback path is untouched.
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.
A run that hits the per-response output limit used to end as
incompleteand hand control back to the user: an interactive session showed a "continue" button, and an unattended goal worker retried by re-sending the same prompt. When the entire budget went to reasoning that retry was a guaranteed repeat of the same wall, because the reasoning-only assistant message is dropped byconvert_to_llmand nothing survived to continue from. This run now keeps writing on its own budget instead, up to 2 continuations.Commits
Verification
Run in a detached worktree at the branch tip, with the pinned toolchain (
rust-toolchain.toml→ 1.99.1) first onPATHandulimit -n 8192:cargo fmt --all -- --check→ cleancargo clippy -p future-rpc --all-targets -- -D warnings→ cleancargo clippy -p future-agent --all-targets -- -D warnings→ cleancargo test -p future-rpc→ 6 passed, 0 failedcargo test -p future-agent --lib→ 3060 passed, 5 failed; the same 5 (sandbox::tests::{add_session_allow_maps_read_op, enabled_gates_writes_outside_workspace, session_allow_takes_effect},sandbox::windows_plan::tests::{allow_write_rule_lands_in_writable_allow_read_does_not, writable_roots_are_minimized_by_ancestor}) also fail onorigin/mainin an identical full parallel run, all 12 of those tests pass in isolation on this branch, and this branch's diff does not touchagent/src/sandbox/— pre-existing and environment/ordering dependent, not introduced here@future-os/thread-projection:tsc --noEmitclean; shared vitest project 453 passed (includingliveApply109); eslint cleanmake check-docs→ 417 docs OK, 0 pairs pending bilingualization, provider matrix 13 rowsUser-visible changes
incompleteat the cut, the session showed a truncation banner, and the user (or the goal worker) had to continue it; with the whole budget spent on reasoning the retry repeated the same failure. After: the same run keeps writing, up toMAX_OUTPUT_LIMIT_CONTINUATIONS(2) continuations, on a budget separate from the reconnect allowance and gated by the samemax_retries > 0switch (set_auto_retry(false)and fusion are unaffected). Revertbf58a2565.bf58a2565.bf58a2565.output_stream_continuing {attempt, maxContinuations, thinkingLevel?}. It is not a reconnect: the reply keeps growing across it, andstream_resumedsemantics are unchanged. Clients that do not know the event simply ignore it. Revertbf58a2565.Notes
packages/rpc/proto/future.protoand the checked-ingenerated/proto.rsare updated together (comments plus the new event type); no wire field numbers change.incompletesemantics apply unchanged, so the goal worker fallback path is untouched.