Skip to content

fix: preserve thinking=disabled as --thinking-disabled flag#699

Open
shubham108prakash-hub wants to merge 1 commit intoanthropics:mainfrom
shubham108prakash-hub:fix/thinking-disabled-flag
Open

fix: preserve thinking=disabled as --thinking-disabled flag#699
shubham108prakash-hub wants to merge 1 commit intoanthropics:mainfrom
shubham108prakash-hub:fix/thinking-disabled-flag

Conversation

@shubham108prakash-hub
Copy link
Copy Markdown

Fixes #693

Problem
When thinking={"type": "disabled"} was set in ClaudeAgentOptions,
the SDK was converting it to --max-thinking-tokens 0.

This loses the user's explicit intent because:

  • --max-thinking-tokens 0 = ambiguous, may be ignored
  • thinking={"type": "disabled"} = explicit opt-out

Anthropic-compatible third-party providers treat these differently,
causing thinking to remain enabled even when the user explicitly disabled it.

Fix
Changed the disabled case in _build_command() to append
--thinking-disabled flag instead of setting tokens to 0.

Before:
elif t["type"] == "disabled":
resolved_max_thinking_tokens = 0

After:
elif t["type"] == "disabled":
cmd.append("--thinking-disabled")

Testing

  • Added test_build_command_with_thinking_disabled in tests/test_transport.py
  • Verifies --thinking-disabled is present in command
  • Verifies --max-thinking-tokens is NOT present when disabled
  • All 38 tests passing

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.

[Bug] SDK maps thinking={"type":"disabled"} to --max-thinking-tokens 0, which breaks Anthropic-compatible providers

1 participant