agent: raise default SPROUT_AGENT_MAX_OUTPUT_TOKENS to 32768#565
Merged
Conversation
The previous default (4096) caused frequent mid-tool-use truncation when
the model emits a large `command` value (e.g. file creation via heredoc).
When the per-response token cap fires inside a `tool_use` block, the
provider returns the block with whatever `input` JSON parsed cleanly so
far — often `{}` if the cap hit mid-value — and the MCP rejects the call
with `-32602: missing field \`command\``. From the user's perspective
the MCP "errors on file creation," but the trigger is response length.
Sonnet 4 and Opus 4 (the two models offered in the ACP settings panel)
both support up to 64K output tokens, so 32K leaves comfortable headroom.
The cost shape is unchanged: providers bill on tokens *generated*, not
on the cap, so normal turns cost the same. Only the ceiling moves.
The env override (`SPROUT_AGENT_MAX_OUTPUT_TOKENS`) still wins for any
deployment that wants to pin a lower value.
This was referenced May 28, 2026
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.
Problem
When the sprout-agent's per-response token cap fires inside a
tool_useblock (typical for largeshellcommandvalues — e.g. file creation via heredoc), the provider returns the block with whateverinputJSON parsed cleanly so far. That's often{}if the cap hit mid-value of the first field. The MCP then rejects the call with:From the user's perspective the MCP "errors on file creation," but the trigger is response length, not quoting or content. The session loops because the model has no signal that its emission was truncated.
Reproduced empirically:
commandvalues up to ~5-7KB succeed; ~10KB+ trigger the truncation. Same MCP, same model, same harness.Fix
Raise the default
SPROUT_AGENT_MAX_OUTPUT_TOKENSfrom4096to32768.crates/sprout-acp/src/acp.rs:1530-1531) both support up to 64K output tokens, so 32K leaves comfortable headroom.SPROUT_AGENT_MAX_OUTPUT_TOKENS) still wins for any deployment that wants to pin a lower value.Files
crates/sprout-agent/src/config.rs— default literal.crates/sprout-agent/README.md— env-var table row + a one-line note explaining the value.Verification
Lefthook pre-commit and pre-push hooks ran clean (rust-fmt, rust-clippy, rust-tests, plus the desktop/web/mobile checks).
Follow-ups (separate PRs, not blocking this one)
MaxTokensguard: detectstop_reason: max_tokenswith non-empty tool_calls incrates/sprout-agent/src/agent.rsand refuse to forward the partialtool_use, returning a corrective synthetic tool-result instead. Defense in depth for sessions that still exceed the new 32K ceiling, or for deployments pinning the env override lower.write_fileMCP tool in sprout-dev-mcp: takes{path, content}as plain JSON fields, sidestepping bash heredoc quoting footguns entirely (indented EOF, space-indent under<<-, unquoted-delimiter$varexpansion). Removes the dominant "one giantcommandvalue" usage pattern that creates the truncation pressure in the first place.