Repository navigation
Enable tool call type coersion - #477
Conversation
|
LGTM, tested using Qwen/Qwen3-Coder-30B-A3B-Instruct local and I dont get issues in #472 |
|
Sorry for the late response. |
Done! |
|
在最新版qwen-code v0.1.1版本还是存在这个问题,我在使用 Qwen/Qwen3-Coder-30B-A3B-Instruct 模型时,也遇到了完全相同的验证错误(is_background must be a boolean 和 Parameter "todos" must be an array),这个模型倾向于为工具调用参数输出字符串化的布尔值(例如 "false")和数组(例如 "[...]")。 |
|
现在 0.4.1 还是有这个问题 |
|
The issue is still present in |
* feat: enable tool call type coercion * fix: tests for type coercion --------- Co-authored-by: Mingholy <[email protected]>
TLDR
Some models struggle to produce tool calls that conform to a strict JSON schema. Ajv has built-in support for coercing types to the expected ones. This PR just enables that functionality
Dive Deeper
A tool call might have something like an offset provided as a string when it's supposed to be a number, or a boolean value wrapped in a string.
Input (incorrect):
{ "path": "foo.txt", "offset": "200", "limit": "100" }Corrected by coercion:
{ "path": "foo.txt", "offset": 200, "limit": 100 }Ajv can automatically provide this coercion and update the values in the passed object.
https://ajv.js.org/guide/modifying-data.html#coercing-data-types
However I had to manually handle the cases when Qwen would provide
"False"instead of"false"orfalse, but this is only done as a fallback.Reviewer Test Plan
Testing this can be tricky because we need to somehow get the model to use the wrong types in tool calls.
I managed this with the following prompt:
Testing without this patch, this prompt fails the first tool call
Testing Matrix
Linked issues / bugs
Hopefully resolves #472