Skip to content

feat: add output_config.effort support for Claude Code adaptive thinking (Opus 4.8 xhigh) - #240

Open
5h4d0wn1k wants to merge 1 commit into
jwadow:mainfrom
5h4d0wn1k:main
Open

feat: add output_config.effort support for Claude Code adaptive thinking (Opus 4.8 xhigh)#240
5h4d0wn1k wants to merge 1 commit into
jwadow:mainfrom
5h4d0wn1k:main

Conversation

@5h4d0wn1k

Copy link
Copy Markdown

Summary

Claude Code on Opus 4.7+/4.8 uses adaptive thinking with effort levels instead of legacy budget_tokens. This PR adds support for the output_config.effort parameter to the Anthropic /v1/messages endpoint so Claude Code can route through kiro-gateway with full effort control.

Changes

kiro/models_anthropic.py

  • Added output_config: Optional[Dict[str, Any]] field to AnthropicMessagesRequest

kiro/converters_anthropic.py

  • Added effort→budget mapping: none=0%, low=20%, medium=50%, high=80%, xhigh=95%, max=99% of max_tokens
  • extract_thinking_config_from_anthropic() now handles:
    • thinking.type="adaptive" — derives budget from output_config.effort
    • Effort without explicit thinking field (Claude Code sends this)
    • Case-insensitive effort matching ("XHIGH"", "xHigh"" → works)
    • Zero-budget effort ("none") → thinking disabled
  • Refactored budget derivation into shared helpers (_budget_from_effort, _thinking_config_from_effort)

Testing

Verified with Claude Code v2.1.72:

  • output_config={"effort": "xhigh"} → budget = 95% of max_tokens
  • Existing thinking.type="enabled"/"disabled"/None behavior preserved
  • All 75 existing tests pass

Background

On Claude Opus 4.8 (and 4.7), Anthropic replaced thinking: {type: "enabled", budget_tokens: N} with adaptive thinking controlled by output_config.effort. Claude Code sends:

{
  "thinking": {"type": "adaptive"},
  "output_config": {"effort": "xhigh"}
}

Since Kiro API only supports the legacy extended thinking via XML tag injection, the effort is converted to a budget percentage internally.

Add output_config field to AnthropicMessagesRequest model and update
extract_thinking_config_from_anthropic() to handle:
- thinking.type="adaptive" with budget derived from output_config.effort
- Effort levels: none(0%), low(20%), medium(50%), high(80%), xhigh(95%), max(99%)
- Effort without explicit thinking field (Claude Code sends output_config alone)
- Case-insensitive effort matching

Claude Code on Opus 4.7+/4.8 uses adaptive thinking with effort levels
instead of budget_tokens. This enables routing Claude Code through
kiro-gateway with full xhigh effort support.
@cla-bot

cla-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Thanks for the PR! 🎉

Before merge, we need a one-time CLA confirmation.
It confirms that you have the right to contribute this code and allow the project to use it.

Full CLA text:
https://github.com/jwadow/kiro-gateway/blob/main/CLA.md

Please reply once with:

I have read the CLA and I accept its terms

You need to write once, all further messages from me can be ignored.

zhujunsan added a commit to zhujunsan/kiro-gateway that referenced this pull request Jul 14, 2026
Cherry-pick upstream PR jwadow#240:Claude Code Opus 4.8 使用
thinking.type=adaptive + output_config.effort,映射为 thinking budget。
@ankitcharolia

Copy link
Copy Markdown

@5h4d0wn1k could you give a try to this gateway: https://github.com/ankitcharolia/kiro-gateway

It works quite well with All AI harness and actively being developed. The most important thing is that it is ACP compliant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants