feat: add support for claude code goal mode for bedrock opus output config#28877
feat: add support for claude code goal mode for bedrock opus output config#28877dennishenry wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes the Claude Code
Confidence Score: 5/5Safe to merge. The change is additive — new normalization helpers, new JSON capability flags, and new beta-header detection. No existing request paths are altered in a breaking way. All three Bedrock paths (Invoke chat, Invoke messages, Converse) have dedicated test coverage for both effort normalization and output_config.format extraction. The capability-flag-driven approach follows the team's established pattern. The two noted issues are a dead fallback branch and a schema-format inconsistency between paths, neither of which affects the correctness of the primary code paths exercised by Claude Code's /goal workflow. litellm/llms/bedrock/common_utils.py — the _get_bedrock_output_config_effort_ceiling function has a dead local-map fallback that never runs, and convert_bedrock_invoke_output_format_to_inline_schema embeds the schema without the additionalProperties: false normalization applied by the Converse path.
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock/common_utils.py | Adds normalize_bedrock_opus_output_config_effort, pop_bedrock_invoke_output_config_format, and convert_bedrock_invoke_output_format_to_inline_schema helpers; includes a local model-map fallback in _get_bedrock_output_config_effort_ceiling that is unreachable at runtime |
| litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py | Adds effort normalization and output_config.format extraction before calling AnthropicConfig.transform_request; correctly shallow-copies output_config before mutation; removes redundant second normalization call |
| litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py | Moves _convert_output_format_to_inline_schema and beta-header logic to shared helpers; adds output_config.format extraction and effort normalization; extracts _get_bedrock_invoke_anthropic_beta_headers and _strip_unsupported_bedrock_invoke_fields for readability |
| litellm/llms/bedrock/chat/converse_transformation.py | Adds output_config.format extraction and conversion to native Bedrock outputConfig; applies effort normalization at both the reasoning_effort mapping point and the additionalModelRequestFields injection point |
| model_prices_and_context_window.json | Adds supports_output_config, supports_xhigh_reasoning_effort, and bedrock_output_config_effort_ceiling (high/max/xhigh per model tier) to Bedrock Opus 4.5/4.6/4.7 entries and Anthropic-direct Opus aliases |
Reviews (2): Last reviewed commit: "fixing failed test" | Re-trigger Greptile
|
@greptile-ai please re-review |
|
This has been merged. Thanks for the contribution! |
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
Before this patch, the hook evaluator request was rejected with
output_config.format: Extra inputs are not permitted, and directxhighcalls failed on older Opus aliases. After this patch, the same/goalworkflow succeeds against patched LiteLLM and Bedrock using AWS profilegenai.Environment
~/litellmhttp://127.0.0.1:4011/private/tmp/litellm-goal-baselinehttp://127.0.0.1:40102.1.144 (Claude Code)claude-code-test:2.1.144, Linux arm64, cleanHOME=/tmp/claude-homegenaius-east-1/private/tmp/litellm_claude_goal_test_config.yamlThe isolated Claude Code logs confirm no host/user/managed Claude settings were loaded:
Test proxy config
Both baseline and patched proxies reported all three endpoints healthy.
Before: unpatched LiteLLM rejects
/goalCommand run inside isolated Claude Code container:
CLI output:
Debug log shows the user-visible answer succeeded, but the
/goalStop-hook evaluator failed:Baseline LiteLLM proxy log:
Before: direct Anthropic-compatible calls
Payload shape used for each model:
{ "model": "<alias>", "max_tokens": 64, "messages": [ { "role": "user", "content": "Return JSON with answer set to ok." } ], "output_config": { "effort": "xhigh", "format": { "type": "json_schema", "schema": { "type": "object", "properties": { "answer": { "type": "string" } }, "required": ["answer"], "additionalProperties": false } } } }Results on unpatched baseline:
After: patched LiteLLM accepts
/goalCommand run inside the same isolated Claude Code container:
CLI output:
Debug log:
Patched LiteLLM proxy log:
After:
/goalverified for Opus 4.5, 4.6, and 4.7All three aliases completed the same isolated Claude Code
/goalrun without an API rejection.After: plan-mode
/goalverifiedCommand used:
Output and debug evidence:
Captured request body from Claude Code
/goalA localhost capture proxy was inserted between Claude Code and patched LiteLLM:
Capture output summary:
The second POST is the Stop-hook evaluator request. It contains both:
output_config.effort = "xhigh"output_config.format.type = "json_schema"and returned HTTP 200 after the patch.
Full captured request/response body is in:
After: direct Anthropic-compatible calls
Results against patched LiteLLM with the same direct payload shown above:
Automated tests
Focused regression suite:
Result:
Type
🆕 New Feature
🐛 Bug Fix
Changes
This change fixes the Anthropic-compatible adapter path used by Claude Code
/goaland plan-mode goal evaluation for Bedrock-backed Opus aliases:claude-opus-4-5claude-opus-4-6claude-opus-4-7