You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bedrock: configured output limit never sent, long reasoning turns truncate at 4096 tokens #46595
V2 sends Bedrock Converse requests without inferenceConfig.maxTokens, even when the model config sets limit.output: 128000. The prepared model request only carries generation values set by hooks/context, so the resolved limit never reaches the provider and Bedrock applies a much lower implicit budget.
With adaptive thinking (reasoningConfig: adaptive, effort xhigh), reasoning and text share that budget. Long-thinking turns finish as max_tokens at exactly 4096 output tokens, often reasoning-only with no visible text.
Captured request (via a session.hook("http.request") plugin, sanitized): additionalModelRequestFields.thinking is present, inferenceConfig is absent:
Auditing ~1,500 sessions across two workspaces: 1,098 assistant turns finished max_tokens at exactly 4,096 output tokens; 552 of them contained reasoning only.
The Bedrock protocol already serializes generation.maxTokens as inferenceConfig.maxTokens; it just never receives a value. I have a fix ready (projects resolved.limit.output into the request with hook/model/route defaults taking precedence) and will open a PR.
Plugins
opencode-bedrock-rotate (bearer token rotation; not related, reproduced with it failing to load)
OpenCode version
0.0.0-beta-18743, also reproduced on 0.0.0-dev-18806
Steps to reproduce
Configure a Bedrock Claude model with limit.output: 128000 and an adaptive reasoning variant.
Log outgoing requests with a plugin hooked on session.hook("http.request").
The request has no inferenceConfig; turns with long reasoning truncate at 4096 output tokens.
If #29363 covers the same root fix, it may be worth coordinating the PR there. If the Bedrock inferenceConfig path is a distinct code site, this can remain a separate issue.
Same root cause reproduces on @ai-sdk/openai-compatible models with @opencode-ai/cli 0.0.0-beta-19086 (opencode2): the outbound /chat/completions body has no max_tokens at all, while opencode 1.18.20 sends max_tokens: 32000 for the same config (limit.output: 131072).
The code site looks shared, not Bedrock-specific: packages/core/src/session/runner/llm.ts builds LLM.request(...) without a generation block, so openai-chat.tsfromRequest ends up with max_tokens: generation?.maxTokens === undefined. runner/model.ts does copy limit.output into route.defaults.limits, but nothing turns it into generation.maxTokens.
Effect on my side: DeepSeek V4 with thinking enabled gets the provider's default budget, spends it all on reasoning, and the turn ends at exactly 4096 output tokens with empty content, the same "reasoning only" pattern you describe.
Filed the openai-compatible details separately in #47398 so the fix can cover both routes.
Fix merged into v2 in #51271. It landed after v2.0.18 and will be included in the next V2 release, v2.0.19. Primary requests now supply the output-token limit that Bedrock Converse sends as inferenceConfig.maxTokens, instead of falling back to Bedrock's implicit limit.
Activity
github-actions commentedon Sep 1, 2026
This issue might be a duplicate of an existing issue. Please check:
limit.outputin config is silently capped at 32k;OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAXis a poor workaround #29363:limit.outputin config is silently capped and never properly forwarded to the model request — same root symptom (configured output limit not reaching the provider) reported for other providers/paths.If #29363 covers the same root fix, it may be worth coordinating the PR there. If the Bedrock
inferenceConfigpath is a distinct code site, this can remain a separate issue.bbartels commentedon Sep 2, 2026
Running into the same issue!
TheFerragamo commentedon Sep 4, 2026
Same root cause reproduces on
@ai-sdk/openai-compatiblemodels with@opencode-ai/cli0.0.0-beta-19086 (opencode2): the outbound/chat/completionsbody has nomax_tokensat all, whileopencode1.18.20 sendsmax_tokens: 32000for the same config (limit.output: 131072).The code site looks shared, not Bedrock-specific:
packages/core/src/session/runner/llm.tsbuildsLLM.request(...)without agenerationblock, soopenai-chat.tsfromRequestends up withmax_tokens: generation?.maxTokens === undefined.runner/model.tsdoes copylimit.outputintoroute.defaults.limits, but nothing turns it intogeneration.maxTokens.Effect on my side: DeepSeek V4 with thinking enabled gets the provider's default budget, spends it all on reasoning, and the turn ends at exactly 4096 output tokens with empty content, the same "reasoning only" pattern you describe.
Filed the openai-compatible details separately in #47398 so the fix can cover both routes.
fix(core): propagate resolved output limit into model request generation
opencode-agent commentedon Sep 27, 2026
Fix merged into
v2in #51271. It landed afterv2.0.18and will be included in the next V2 release,v2.0.19. Primary requests now supply the output-token limit that Bedrock Converse sends asinferenceConfig.maxTokens, instead of falling back to Bedrock's implicit limit.