Skip to content

Bedrock: configured output limit never sent, long reasoning turns truncate at 4096 tokens #46595

Description

@clopca

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

  1. Configure a Bedrock Claude model with limit.output: 128000 and an adaptive reasoning variant.
  2. Log outgoing requests with a plugin hooked on session.hook("http.request").
  3. The request has no inferenceConfig; turns with long reasoning truncate at 4096 output tokens.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions