qwen-code/packages/sdk-python/src/qwen_code_sdk
chinesepowered c5dddb5e5d
fix(sdk-python): validate max_tool_calls and max_subagent_depth as integers (#7548)
* fix(sdk-python): validate max_tool_calls and max_subagent_depth as integers

max_session_turns rejects bools and non-ints before its range check, but
the two sibling limits only range-checked, so values their own error
messages rule out were accepted and stringified onto the CLI:

  max_tool_calls=True      -> --max-tool-calls True
  max_tool_calls=2.5       -> --max-tool-calls 2.5
  max_subagent_depth=True  -> --max-subagent-depth True

bool is the sharp edge: it subclasses int, so True passes both isinstance
and the range comparison as 1.

Extract the bool-aware check the max_session_turns branch already
performed into _is_int and apply it to all three. max_session_turns keeps
its exact previous behavior; the expression is the same, only named.

* fix(sdk-python): say integer in the max_subagent_depth range message

A float like 2.5 is between 1 and 100, so the old message described a
constraint the value already satisfied and gave no hint that the type
was the problem.

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-23 08:45:13 +00:00
..
__init__.py feat(sdk): add control request methods for effort, models, usage, context (#6492) 2026-07-11 10:08:12 +00:00
errors.py feat(SDK) Add Python SDK implementation for #3010 (#3494) 2026-04-25 07:02:58 +08:00
json_lines.py feat(SDK) Add Python SDK implementation for #3010 (#3494) 2026-04-25 07:02:58 +08:00
protocol.py feat(sdk): add control request methods for effort, models, usage, context (#6492) 2026-07-11 10:08:12 +00:00
py.typed feat(SDK) Add Python SDK implementation for #3010 (#3494) 2026-04-25 07:02:58 +08:00
query.py feat(sdk): expose transport and query options in both SDKs (#6491) 2026-07-12 07:10:45 +00:00
sync_query.py feat(SDK) Add Python SDK implementation for #3010 (#3494) 2026-04-25 07:02:58 +08:00
transport.py feat(sdk): expose transport and query options in both SDKs (#6491) 2026-07-12 07:10:45 +00:00
types.py feat(sdk): expose transport and query options in both SDKs (#6491) 2026-07-12 07:10:45 +00:00
validation.py fix(sdk-python): validate max_tool_calls and max_subagent_depth as integers (#7548) 2026-07-23 08:45:13 +00:00