Skip to content

fix(tools): coerce stringified argument types to schema expectations (#13350) - #13386

Open
patrickswedish wants to merge 1 commit into
continuedev:mainfrom
patrickswedish:fix/tool-args-schema-coercion-13350
Open

patrickswedish wants to merge 1 commit into
continuedev:mainfrom
patrickswedish:fix/tool-args-schema-coercion-13350

Conversation

@patrickswedish

Copy link
Copy Markdown

Summary

Coerces stringified JSON arrays, objects, booleans, and numbers in tool arguments to match their expected schema types before invoking MCP and built-in tools.

Motivation & Context

Certain models (such as Ollama/Qwen) and serialization pipelines emit tool call arguments where array or object parameters are passed as serialized JSON strings (e.g. {"paths": "[\"file1.jsx\", \"file2.jsx\"]"} or {"dryRun": "false"}). When received by tools (especially MCP servers validating with Zod/JSON Schema), these cause validation failures like:
MCP error -32602: Input validation error: Invalid arguments for tool read_multiple_files: Invalid input: expected array, received string at paths

Changes

  • In core/tools/parseArgs.ts, expand coerceArgsToSchema to parse stringified JSON arrays and objects, and coerce boolean and numeric strings to their respective primitives when defined by the schema (including union/anyOf/oneOf constructs).
  • In core/tools/callTool.ts, ensure coerceArgsToSchema is run on parsed tool arguments before dispatching to built-in tools as well.
  • In core/tools/parseArgs.vitest.ts, add unit tests covering array, object, boolean, number, and union type coercion.

Fixes #13350


Diff minimization and pre-flight validation performed with ZeroSlop™ CI — Ribbsaeter Systems.

@patrickswedish
patrickswedish requested a review from a team as a code owner October 15, 2026 21:34
@patrickswedish
patrickswedish requested review from sestinj and removed request for a team October 15, 2026 21:34
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

…ontinuedev#13350)

Signed-off-by: Patrick Ribbsaeter <patrickswedish@gmail.com>
@patrickswedish
patrickswedish force-pushed the fix/tool-args-schema-coercion-13350 branch from 4d74130 to 9c81235 Compare October 15, 2026 21:43

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.

filesystem read_multiple_files and edit_file Input validation error: Invalid arguments: expected array, received string

1 participant