Skip to content

fix: pass --thinking flag for adaptive/disabled instead of budget tokens#796

Merged
hackyon-anthropic merged 1 commit intomainfrom
fix/thinking-adaptive-flag
Apr 7, 2026
Merged

fix: pass --thinking flag for adaptive/disabled instead of budget tokens#796
hackyon-anthropic merged 1 commit intomainfrom
fix/thinking-adaptive-flag

Conversation

@hackyon-anthropic
Copy link
Copy Markdown
Contributor

Summary

thinking={"type":"adaptive"} was being lowered to --max-thinking-tokens 32000, which puts the CLI into fixed-budget mode rather than adaptive mode. disabled similarly mapped to --max-thinking-tokens 0.

The CLI exposes an explicit --thinking <adaptive|enabled|disabled> flag that takes precedence over --max-thinking-tokens. The TypeScript SDK already uses it. This change mirrors that behavior:

  • adaptive--thinking adaptive
  • disabled--thinking disabled
  • enabled--max-thinking-tokens <budget_tokens>
  • deprecated max_thinking_tokens is only emitted when thinking is unset

Test plan

  • pytest tests/test_transport.py (59 passed)
  • New parametrized test for all three thinking types
  • New precedence test: thinking overrides max_thinking_tokens

Previously thinking={"type":"adaptive"} was lowered to --max-thinking-tokens 32000, which puts the CLI in budget mode rather than adaptive mode. The CLI exposes an explicit --thinking <adaptive|enabled|disabled> flag; use it for adaptive and disabled, and only emit --max-thinking-tokens for the enabled/budget case or the deprecated max_thinking_tokens option.
Copy link
Copy Markdown
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean fix that correctly maps thinking types to the right CLI flags, with good test coverage.

Extended reasoning...

Overview

The PR modifies in to fix how thinking configuration is translated to CLI flags. It also adds tests in . Two files changed, both in the transport layer.

Security Risks

None. This is purely a CLI argument construction fix with no auth, crypto, or permission-sensitive code involved.

Level of Scrutiny

Low. The change is small, mechanical, and clearly correct. The old code incorrectly mapped adaptive to --max-thinking-tokens 32000 (fixed budget) and disabled to --max-thinking-tokens 0, when both should use the dedicated --thinking flag. The fix mirrors the TypeScript SDK behavior as stated in the description.

Other Factors

The new tests cover all three thinking types parametrically and verify the precedence of thinking over the deprecated max_thinking_tokens. The logic restructure from if/elif/elif + if to if/elif is clean and correct. No outstanding reviewer comments.

@hackyon-anthropic hackyon-anthropic merged commit 6617b9e into main Apr 7, 2026
10 checks passed
@hackyon-anthropic hackyon-anthropic deleted the fix/thinking-adaptive-flag branch April 7, 2026 19:42
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