Skip to content

Tools: Accept Python-style booleans for parameters declared boolean - #522

Open
iojeda wants to merge 1 commit into
theroyallab:mainfrom
iojeda:fix/tool-boolean-python-case
Open

iojeda wants to merge 1 commit into
theroyallab:mainfrom
iojeda:fix/tool-boolean-python-case

Conversation

@iojeda

@iojeda iojeda commented Nov 16, 2026

Copy link
Copy Markdown

Is your pull request related to a problem? Please describe.
With tool_format: qwen3_coder and Qwen3.8 on exllamav3, the model writes True / False (Python spelling) for parameters the tool schema declares as boolean. coerce_param_value tries json.loads, which rejects True, and falls back to the plain string, so the tool call reaches the client with "recursive": "True" where the schema asks for a boolean. llama.cpp avoids it because its grammar forces true. Clients that validate arguments against the schema reject or retry the call.

Why should this feature be added?
Now that coerce_param_value knows the declared type (#513 and the typed-parameter work), the declared boolean is the right place to accept the other spelling. It is local to that case: a declared boolean whose value is true or false in any capitalization becomes a boolean. Declared strings stay verbatim, other declared types are untouched, and untyped values keep the previous guess (True stays a string).

Examples
Before: recursive = 'True' (str) in the parsed arguments of a call whose schema has "recursive": {"type": "boolean"}. After: recursive = True (bool). The new assertions in tests/test_tool_param_types.py cover True, False (with surrounding newlines), true, a non-boolean word under boolean (yes stays a string), True under string, and untyped True.

Additional context
Passed: tests/test_tool_param_types.py (12 tests, run with PYTHONPATH=.. python -m unittest test_tool_param_types from tests/); a live check against a Qwen3.8-27B EXL3 server on a 7900 XTX, where a request with a boolean-typed tool parameter returned True as a bool (one check, one model).
Not run: ruff (not installed here; the lines respect the 100-column limit), the other tool formats, other models. Run from the repository root the same module fails on an unrelated import (test_tool_delta_streaming), also without this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_012VGZjFp8LFECH1cWgdagpB

Qwen3.8 on exllamav3 writes `True` / `False` for boolean parameters. json.loads rejects them, so the call carried the string where the schema asks for a boolean.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_012VGZjFp8LFECH1cWgdagpB

This branch has not been deployed

No deployments
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.

1 participant