Skip to content

feat(agent): continue the same run when the output budget runs out - #1595

Merged
huichen merged 2 commits into
mainfrom
pr/huichen
Nov 12, 2026
Merged

huichen merged 2 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

A run that hits the per-response output limit used to end as incomplete and 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 by convert_to_llm and nothing survived to continue from. This run now keeps writing on its own budget instead, up to 2 continuations.

Commits

  • feat(agent): continue the same run when the output budget runs out

Verification

Run in a detached worktree at the branch tip, with the pinned toolchain (rust-toolchain.toml → 1.99.1) first on PATH and ulimit -n 8192:

  • cargo fmt --all -- --check → clean
  • cargo clippy -p future-rpc --all-targets -- -D warnings → clean
  • cargo clippy -p future-agent --all-targets -- -D warnings → clean
  • cargo test -p future-rpc → 6 passed, 0 failed
  • cargo 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 on origin/main in an identical full parallel run, all 12 of those tests pass in isolation on this branch, and this branch's diff does not touch agent/src/sandbox/ — pre-existing and environment/ordering dependent, not introduced here
  • @future-os/thread-projection: tsc --noEmit clean; shared vitest project 453 passed (including liveApply 109); eslint clean
  • make check-docs → 417 docs OK, 0 pairs pending bilingualization, provider matrix 13 rows

User-visible changes

  • A reply cut by the output budget now continues instead of ending. Before: the run ended incomplete at 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 to MAX_OUTPUT_LIMIT_CONTINUATIONS (2) continuations, on a budget separate from the reconnect allowance and gated by the same max_retries > 0 switch (set_auto_retry(false) and fusion are unaffected). Revert bf58a2565.
  • A cut that produced no visible text steps the thinking level down one notch for that continuation only — a fixed-scale step filtered through the model's declared levels, applied to the run's private provider snapshot, never to the session setting. Before: the continuation would have been the identical request that just ran out. Revert bf58a2565.
  • The truncation banner no longer appears while a continuation is still possible. Revert bf58a2565.
  • New stream event output_stream_continuing {attempt, maxContinuations, thinkingLevel?}. It is not a reconnect: the reply keeps growing across it, and stream_resumed semantics are unchanged. Clients that do not know the event simply ignore it. Revert bf58a2565.

Notes

  • packages/rpc/proto/future.proto and the checked-in generated/proto.rs are updated together (comments plus the new event type); no wire field numbers change.
  • When the continuation allowance is spent, the original incomplete semantics apply unchanged, so the goal worker fallback path is untouched.

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.
@huichen
huichen enabled auto-merge (squash) November 12, 2026 12:26
@huichen
huichen merged commit e96d3e0 into main Nov 12, 2026
71 of 74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant