qwen-code/packages/sdk-python/tests/unit
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
..
test_query_core.py feat(sdk): expose transport and query options in both SDKs (#6491) 2026-07-12 07:10:45 +00:00
test_transport.py feat(sdk): expose transport and query options in both SDKs (#6491) 2026-07-12 07:10:45 +00:00
test_validation.py fix(sdk-python): validate max_tool_calls and max_subagent_depth as integers (#7548) 2026-07-23 08:45:13 +00:00