Commit graph

12 commits

Author SHA1 Message Date
Dallin Romney
ff89a88299
fix: coerce MCP tool args to match schema string types (#11852)
* fix: coerce MCP tool args to match schema string types

When tool call arguments are parsed via JSON.parse(), string-typed
parameters containing valid JSON (e.g. file content for .json files)
get deeply parsed into objects. Built-in tools handle this via
getStringArg(), but MCP tools with dynamic schemas had no equivalent
fix, causing write_file and similar tools to receive objects instead
of strings.

Add coerceArgsToSchema() that checks the tool's inputSchema and
re-stringifies any values that should be strings before passing
args to the MCP client.

Fixes #8510

* fix: narrow coercion to only objects/arrays, not numbers/booleans

Only re-stringify values that are objects or arrays (the actual
deep-parsing issue). Numbers and booleans passed to a string-typed
parameter are left as-is so they surface as type errors rather than
being silently converted.
2026-03-25 16:39:01 -07:00
silencezhoudev
82f6f69522 fix: support object-type arguments in tool call parsing
Add type check in safeParseToolCallArgs to handle cases where
toolCall.function.arguments is already an object instead of a JSON string.
This prevents parameter loss and 'argument is required' errors in tool calls.
2026-01-21 18:16:12 +08:00
Matt Cowger
e04c21f9c8 Address comments from @RomneyDa 2025-12-02 20:28:45 +00:00
Matt Cowger
a3810024c6 Add tests to match. 2025-12-02 20:15:10 +00:00
Matt Cowger
5f14a2fa66 fix: handle JSON contents of create_new_file
Handle case where JSON content was parsed into an object by the tool call parser.  If the arguments to the tool call are valid JSON (e.g. the model attempts to create a .json file) the earlier call to JSON.parse() will have deeply parsed the returned contents. If that has happened, convert back to string.

Fixes: #8972
2025-12-02 20:08:26 +00:00
chezsmithy
820822196b feat: ✨ Add range and head tools for file operations 2025-08-27 22:27:15 -07:00
Dallin Romney
1c5df69a3f
fix: grep escaped chars and empty results (#7323)
* fix: grep search escape and better truncation warnings

* fix: grep search tweaks

* fix: grep no results

* Fix: url test
2025-08-25 07:20:26 -07:00
Dallin Romney
1ee5c54151 feat: more thorough tool arg checking utils with tests 2025-07-21 15:31:52 +02:00
chezsmithy
1a59113445 fix: 🔇 The safeParseToolCallArgs function is logging excessively 2025-07-10 14:03:07 -07:00
Dallin Romney
c073a1e07c handle empty string json args 2025-06-26 10:35:24 -07:00
Dallin Romney
68ce00ec5c llm pre-fetch tests: nested dependency mocks for continue fetch 2025-06-06 17:39:28 -07:00
Dallin Romney
dcdc04f0ba JSON parsing progress 2025-06-04 15:16:41 -07:00