Repository navigation
Conversation
…ing unless the config asks
For AIC-3585. The handler ran with the Claude Code CLI's own defaults: the
config's max_tokens was dropped, and with no thinking setting the CLI chose
one (a 31,999-token budget on claude-haiku-4-5).
max_tokens now reaches the CLI as CLAUDE_CODE_MAX_OUTPUT_TOKENS in env,
which the Agent SDK adds to os.environ. When the config sets neither
thinking nor max_thinking_tokens, the handler passes
thinking={"type": "disabled"}.
BREAKING CHANGE: a config that sets no thinking now runs without thinking.
Configs that relied on the CLI's adaptive-thinking default must set
thinking in their model parameters, for example {"type": "adaptive"}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s test gaps Drop a max_tokens above 2^53 - 1, as the JS SDK does for a value that is not a safe integer, so both SDKs send the same thing for the same config. Tests: the environment the Agent SDK builds for the CLI still holds os.environ; effort alone and thinking with max_thinking_tokens; and a native-graph node's CLI command carries --thinking disabled, plus the invalid max_tokens and max_thinking_tokens-only node cases. README notes that a settings-file env wins and that some models reject disabled thinking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeffdupont
left a comment
There was a problem hiding this comment.
This matches mono#110 and js-ai-sdk#183. The same max_tokens bounds (a positive whole number up to 2^53 - 1, with 200.0 read as 200), the same disabled-thinking default, and the same rule that a dropped malformed thinking counts as not set. I checked env against the SDK: no host or skills option also sets env, so nothing overwrites it. One small test gap, below, is the same one I raised on the JS PR.
…ormed thinking and effort alone
Match the JS graph tests: a node with a thinking that has no budget, and
a node with only effort, each get thinking={"type": "disabled"}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeffdupont
left a comment
There was a problem hiding this comment.
cd91993 covers the test gap from my last review: the native-graph test now pins the disabled default for a malformed thinking ({"type": "enabled"} with no budget) and for effort alone, so every output-limit case mono#110 lists runs through invoke, stream and a graph node. Nothing else changed since 837053d, and the behaviour still matches js-ai-sdk#183.
Summary
AIC-3585. Spec: launchdarkly/ai-sdks-monorepo#110. The same change for TypeScript is launchdarkly/js-ai-sdk#183; Go is not affected.
claude-agentsran with the Claude Code CLI's own defaults instead of the AI Config's. The config'smax_tokenswas dropped, becauseClaudeAgentOptionshas no output-token field. With no thinking setting, the CLI chose one: a 31,999-token budget onclaude-haiku-4-5. Python wasn't checked live; the code path is the same as the TypeScript one that was._options_parameters(handler.py) is shared by the handler'sinvokeandstreamand byto_claude_agents. It now:max_tokensto the CLI. A positive integermax_tokensup to 2^53 − 1 becomesenv={"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "<n>"}. That's the same bound as the JS SDK's safe-integer check. The Agent SDK adds that to the inheritedos.environ. A whole-number float such as200.0counts as 200, as it does in JavaScript. Any other value is dropped. With nomax_tokens,envstays{}and the CLI keeps its default, as before.thinkingnormax_thinking_tokens, it passesthinking={"type": "disabled"}. A malformedthinkingthat gets dropped counts as not set. An explicitthinking, ormax_thinking_tokenson its own, is passed as before. The CLI leavesthinkingout for models that reject disabled thinking, such asclaude-fable-5.max_tokensis read separately rather than added to_CLAUDE_AGENT_OPTIONS_FORWARDED_KEYS, since it isn't aClaudeAgentOptionsfield and the drift test checks that list against the dataclass.envstays in the excluded list: themax_tokensvalue is the only thing written into it.tests/forwarding_spec.pyaddsmax_tokensto the Claude Agents list.Breaking change
A config that sets no thinking now runs without thinking. Before, the CLI chose: adaptive thinking on models that support it, or a fixed budget on others. Configs that relied on that must set
thinkingin their model parameters, for example{"type": "adaptive"}. The README's new "Output limit and thinking" section has the migration note.Tests
TestOutputLimitAndThinkingDefault, on bothinvokeandstream, covers:max_tokens: 200sets the variable and disables thinking, checked against the SDK's own CLI command builder.os.environ.open_processis stubbed to capture it.200.0is read as 200.max_tokens,envis empty.0,-5,1.5,2**53,inf,"200",True,Noneand a dict are each dropped.effortalone gets the default, andthinkingwithmax_thinking_tokenspasses both as given.thinkingreplaces the default.max_thinking_tokenson its own leavesthinkingunset.TestNativeGraphModelParameterscovers four node cases:max_tokens(and checks that the real SDK builds--thinking disabledfor it), its ownthinking, an invalidmax_tokens, andmax_thinking_tokensalone (--max-thinking-tokens 2048).TestThinkingIsRebuilt/TestMalformedObjectValuesAreDroppedcases expected a dropped thinking to beNone, and now expect the default.max_tokenswas removed fromtest_ui_keys_the_sdk_rejects_are_dropped_without_raising, since it's no longer dropped.make testpasses (3686 passed, 18 skipped).make lint,make format-checkandmypypass.🤖 Generated with Claude Code
Note
Overview
Breaking: configs that omit thinking no longer inherit Claude Code’s implicit thinking defaults; the handler now passes
thinking={"type": "disabled"}unless the config setsthinkingormax_thinking_tokens(malformedthinkingfalls back to the same default).The shared
_options_parameterspath (handler invoke/stream andto_claude_agents) now honoursmax_tokens: valid positive integers (including whole floats, capped at 2^53−1) are sent to the CLI asenv={"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "<n>"}becauseClaudeAgentOptionshas no output-token field. Invalid values are ignored; omittingmax_tokensleaves CLI defaults unchanged.README documents output limits, thinking behaviour, and migration. Cross-SDK
forwarding_specaddsmax_tokensto the Claude Agents forwarded list; new handler, native-graph, and updated thinking-rebuild tests lock in the env/thinking rules and CLI command shape.Reviewed by Cursor Bugbot for commit cd91993. Bugbot is set up for automated code reviews on this repo. Configure here.