Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
For Amazon Bedrock Claude models that use adaptive thinking (e.g. us.anthropic.claude-opus-4-8), every request is capped at 4096 output tokens regardless of the model's configured maxTokens, and no configuration raises it; at higher thinking effort the extended-thinking block alone consumes the 4096-token budget, so the turn ends with stop_reason: "length" before emitting any answer or tool call.
Steps to reproduce
- Configure an agent with
amazon-bedrock/us.anthropic.claude-opus-4-8and thinking levelhigh. - Send a prompt that needs more than 4096 output tokens in one generation, e.g.
Output the integers from 1 to 2000, one per line. No other text.(or any reasoning-heavy synthesis where extended thinking exceeds ~4096 tokens). - The turn fails with no deliverable content.
Expected behavior
The Bedrock Converse request's inferenceConfig.maxTokens is derived from the model's resolved maxTokens (or an agent-level output-token setting) for adaptive-thinking models too, leaving budget for thinking plus the answer, instead of defaulting to 4096. This matches the non-adaptive Claude branch (which already factors model.maxTokens via adjustMaxTokensForThinking) and the Anthropic-direct transport (which honors model.maxTokens).
Actual behavior
inferenceConfig.maxTokens is the core default 4096 for adaptive-thinking models, and nothing the user configures changes it. The run ends with stopReason: "length" and only a (truncated) thinking block; the UI surfaces "Agent couldn't generate a response."
OpenClaw version
2026.6.10 (aa69b12)
Operating system
macOS 26.5.1 (Darwin 25.5.0, arm64)
Install method
npm global (/opt/homebrew/lib/node_modules/openclaw)
Model
amazon-bedrock/us.anthropic.claude-opus-4-8 (api: bedrock-converse-stream, thinking level high, contextWindow 1000000, configured maxTokens 128000)
Provider / routing chain
openclaw -> amazon-bedrock (bedrock-converse-stream, region us-east-1)
Additional provider/model setup details
The static catalog entry in ~/.openclaw/openclaw.json under models.providers.amazon-bedrock.models[] sets maxTokens: 128000 and contextWindow: 1000000 for us.anthropic.claude-opus-4-8. That value is retained in the model catalog but ignored on the adaptive-thinking request path (see root cause in evidence).
Logs, screenshots, and evidence
# Root cause, traced through the published dist (@openclaw/amazon-bedrock-provider@2026.6.10).
# Three things combine; #3 is the actual blocker:
# 1. discovery.js — resolveKnownMaxTokens(modelId) returns 128000 ONLY for Claude Fable 5;
# every other model (including opus-4-8) returns undefined and falls back to
# DEFAULT_MAX_TOKENS = 4096.
# 2. discovery-shared.js — mergeImplicitBedrockProvider keeps a user static models[] array,
# so a configured maxTokens (128000) IS retained in the catalog (so #1 alone is not the blocker).
# 3. stream.runtime.js — in resolveSimpleBedrockOptions, when supportsAdaptiveThinking(model) is
# true (opus-4-8) the builder returns `base` unchanged and NEVER applies model.maxTokens.
# The non-adaptive Claude branch DOES, via adjustMaxTokensForThinking(base.maxTokens, model.maxTokens, ...).
# The request is then built as inferenceConfig.maxTokens = options.maxTokens = base.maxTokens,
# and core buildBaseOptions sets maxTokens = options?.maxTokens (the core default ~4096),
# NOT model.maxTokens. No zod config key feeds this path, so the cap is effectively unconfigurable.
# The Claude Fable 5 contract branch has the same defect.
# Live evidence: session trajectories show
# terminalError: non_deliverable_terminal_turn
# lastCallUsage.output: 4096
# and the final assistant message has stopReason: "length" containing only a truncated thinking block
# (17 such truncations observed in a single session).
# Proof this is a wiring gap, not a Bedrock limit — a direct Bedrock Converse call accepts a far larger cap
# for the same model (also verified at maxTokens=64000 and 96000):
aws bedrock-runtime converse \
--region us-east-1 \
--model-id us.anthropic.claude-opus-4-8 \
--messages '[{"role":"user","content":[{"text":"reply OK"}]}]' \
--inference-config maxTokens=128000 # returns 200 OKImpact and severity
- Affected: any agent using a Bedrock adaptive-thinking Claude model; opus-4-8 is a common default.
- Severity: High for agentic + long-form use. Tool-call round-trips usually fit under 4096 so it is often invisible, but any single turn whose thinking (at medium/high/xhigh effort) or output exceeds ~4096 tokens fails with no deliverable content.
- Frequency: deterministic whenever a single generation needs more than 4096 tokens; raising thinking effort makes failures more likely, which is counterintuitive.
- Consequence: failed turns with no answer or tool call ("Agent couldn't generate a response").
Additional information
Suggested fix: in stream.runtime.js, the adaptive-thinking branch should apply the resolved model.maxTokens (or an agent-level maxOutputTokens) to inferenceConfig.maxTokens, the way the non-adaptive branch already does; ensure the value comfortably exceeds the thinking budget so thinking plus answer fit. And/or expose a config key that feeds settingsParams.maxOutputTokens, and broaden resolveKnownMaxTokens beyond Fable-5. Apply the same fix to the Fable-5 branch.
Workaround: lower thinking effort (off/minimal/low/medium) so thinking fits under 4096, leaving room for the answer; single output-heavy generations (>4096 tokens) still truncate regardless of effort. A local patch mirroring the non-adaptive branch (apply model.maxTokens in the adaptive + Fable branches) was verified to raise the built inferenceConfig.maxTokens from 4096 to 128000 with the adaptive thinking/output_config.effort fields preserved. Happy to open a PR.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 27, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 27, 2026, 12:47 AM ET / 04:47 UTC.
Summary
Keep open: current main and v2026.6.10 still leave Bedrock adaptive-thinking/Fable option resolution on the base maxTokens path while only the non-adaptive Claude branch applies the model maxTokens cap, and no merged duplicate fix was found.
Reproducibility: yes. at source level: current main shows adaptive Bedrock requests keep options.maxTokens unset while the non-adaptive Claude path derives a cap from model.maxTokens. I did not run a live AWS Bedrock repro in this read-only pass, so this is source-reproducible rather than fully reproduced.
Root-cause cluster
Relationship:
canonicalCanonical: #97176
Summary: This issue is the canonical known report for the Bedrock adaptive-thinking maxTokens cap; provided related refs are false positives from numbered-list text and targeted searches found no separate owner.
Members:
independent: fix: add @lid format support and allowFrom wildcard handling #1 - This closed unmerged WhatsApp PR was only linked by numbered-list text in the issue body and is unrelated to Bedrock provider runtime behavior.independent: WA business, groups & office hours #3 - This closed WhatsApp support question was only linked by numbered-list text in the issue body and is unrelated to Bedrock provider runtime behavior.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
This is a narrow provider-runtime repair with clear source proof, likely files, and focused regression tests; live Bedrock proof can be added when credentials are available.
Review details
Best possible solution:
Make Bedrock adaptive-thinking and Fable option resolution populate maxTokens from resolved model metadata when no explicit caller cap is set, preserving explicit maxTokens overrides and adaptive thinking payload behavior.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level: current main shows adaptive Bedrock requests keep options.maxTokens unset while the non-adaptive Claude path derives a cap from model.maxTokens. I did not run a live AWS Bedrock repro in this read-only pass, so this is source-reproducible rather than fully reproduced.
Is this the best way to solve the issue?
Yes: the narrow maintainable fix is to reuse existing model-cap maxTokens semantics in the Bedrock provider runtime, not to add a new config surface. Existing params.maxTokens behavior should remain the explicit override path.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against fbfadbd806e1.
Label changes
Label justifications:
P2: This is a normal-priority provider runtime bug with a clear source path and a blast radius limited to Bedrock adaptive-thinking Claude requests.impact:message-loss: The reported failure mode can end a turn at length before any visible answer or tool call is delivered.impact:auth-provider: The bug is in provider/model request wiring for Amazon Bedrock Claude output-token limits.Evidence reviewed
Acceptance criteria:
What I checked:
extensions/amazon-bedrock/stream.runtime.ts:213, fbfadbd806e1)extensions/amazon-bedrock/stream.runtime.ts:356, fbfadbd806e1)src/llm/providers/simple-options.ts:10, fbfadbd806e1)extensions/amazon-bedrock/stream.runtime.test.ts:493, fbfadbd806e1)docs/gateway/config-tools.md. (docs/gateway/config-tools.md:521, fbfadbd806e1)extensions/amazon-bedrock/discovery.ts:173, fbfadbd806e1)Likely related people:
extensions/amazon-bedrock/stream.runtime.ts,extensions/amazon-bedrock/discovery.ts,extensions/amazon-bedrock/thinking-policy.ts)extensions/amazon-bedrock/stream.runtime.ts,extensions/amazon-bedrock/discovery.ts,extensions/amazon-bedrock/thinking-policy.ts)extensions/amazon-bedrock/discovery.ts,extensions/amazon-bedrock/discovery.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.[-]Bedrock adaptive-thinking models hard-capped at 4096 output tokens; model maxTokens ignored, no config override[/-][+][Bug]: Bedrock adaptive-thinking models hard-capped at 4096 output tokens; model maxTokens ignored, no config override[/+]test(bedrock): add Fable 5 maxTokens regression tests
test(bedrock): comprehensive maxTokens coverage — all branches, all e…
test(bedrock): add low-effort and Fable 5 undefined-maxTokens coverage (
test(bedrock): add real behavior proof for maxTokens fix (openclaw#97176
fix(bedrock): remove invalid prompt option from test SimpleStreamOpti…
fix(bedrock): apply model maxTokens to adaptive-thinking and Fable 5 …