[PR #4754] [Engine] read typed scalar tool arguments the model writes in Python form #5164

Open
opened 2026-11-07 16:33:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4754
Author: @Tsury
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: fix-tool-scalar-args


📝 Commits (1)

  • f80810b [Engine] read typed scalar tool arguments the model writes in Python form

📊 Changes

3 files changed (+206 additions, -5 deletions)

View changed files

📝 serve/frontend.py (+43 -5)
📝 serve/test_server.py (+22 -0)
➕ serve/test_tool_argument_types.py (+141 -0)

📄 Description

Problem and result

A model can write a scalar tool argument in a form that is not JSON: False, None, +10. coerce_value keeps such a value as text, so a parameter declared boolean or integer reaches the client as the string "False" or "+10". Strict clients refuse the call.

After this change, the value is converted when the property's schema declares that type. A parameter declared string keeps its text exactly. So do enum and anyOf properties that are not declared with one of these types. A value that fits none of the declared types stays as it was.

None found in issues or pull requests. It sits on top of the coerce_value work in v0.2.8.

Approach

_coerce_tool_value calls coerce_value first, then handles only the scalar literals that coerce_value left unchanged. The streaming path keeps the property's schema (sprops) so whole and streamed calls agree. This is not schema validation: valid JSON keeps its meaning.

Validation

Passed:

  • New tests against unchanged main (870aedd9): 28 subtest and case failures. With the change: all pass.
  • python -m unittest serve.test_tool_argument_types serve.test_server serve.test_structured: 373 tests pass (Linux, Python 3.14).

Not run:

  • python -m unittest discover -s serve and any GPU or model run. This change was split from a maintained v0.2.8 build that runs on an RTX 5090 Laptop; the unit tests above are the evidence for this branch.

Limits

Python-style True/False/None are also accepted for a property that has no schema at all, where the value's type cannot be checked.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4754 **Author:** [@Tsury](https://github.com/Tsury) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-tool-scalar-args` --- ### 📝 Commits (1) - [`f80810b`](https://github.com/Niko1221/Strata/commit/f80810bb98603e1b5b67efb6092f64e705887a74) [Engine] read typed scalar tool arguments the model writes in Python form ### 📊 Changes **3 files changed** (+206 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `serve/frontend.py` (+43 -5) 📝 `serve/test_server.py` (+22 -0) ➕ `serve/test_tool_argument_types.py` (+141 -0) </details> ### 📄 Description ## Problem and result A model can write a scalar tool argument in a form that is not JSON: `False`, `None`, `+10`. `coerce_value` keeps such a value as text, so a parameter declared `boolean` or `integer` reaches the client as the string `"False"` or `"+10"`. Strict clients refuse the call. After this change, the value is converted when the property's schema declares that type. A parameter declared `string` keeps its text exactly. So do enum and `anyOf` properties that are not declared with one of these types. A value that fits none of the declared types stays as it was. ## Related discussion None found in issues or pull requests. It sits on top of the `coerce_value` work in v0.2.8. ## Approach `_coerce_tool_value` calls `coerce_value` first, then handles only the scalar literals that `coerce_value` left unchanged. The streaming path keeps the property's schema (`sprops`) so whole and streamed calls agree. This is not schema validation: valid JSON keeps its meaning. ## Validation **Passed:** - New tests against unchanged `main` (870aedd9): 28 subtest and case failures. With the change: all pass. - `python -m unittest serve.test_tool_argument_types serve.test_server serve.test_structured`: 373 tests pass (Linux, Python 3.14). **Not run:** - `python -m unittest discover -s serve` and any GPU or model run. This change was split from a maintained v0.2.8 build that runs on an RTX 5090 Laptop; the unit tests above are the evidence for this branch. ## Limits Python-style `True`/`False`/`None` are also accepted for a property that has no schema at all, where the value's type cannot be checked. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5164
No description provided.