anomalyco / anomalyco/opencode
Bedrock: configured output limit never sent, long reasoning turns truncate at 4096 tokens
@nexxeln is already working on this.
Since Sep 1, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
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:
{
"url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/global.anthropic.claude-fable-5/converse-stream",
"modelId": "global.anthropic.claude-fable-5",
"inferenceConfig": null,
"additionalModelRequestFields": { "thinking": { "type": "adaptive", "display": "summarized" }, "output_config": { "effort": "xhigh" } }
}
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: 128000and 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.