Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix: put filePath before content in write tool schema#14744

Open
harmeet wants to merge 4 commits intoanomalyco:devfrom
harmeet:fix/write-tool-filepath-param-order
Open

fix: put filePath before content in write tool schema#14744
harmeet wants to merge 4 commits intoanomalyco:devfrom
harmeet:fix/write-tool-filepath-param-order

Conversation

@harmeet
Copy link

@harmeet harmeet commented Feb 23, 2026

Issue for this PR

Closes #1498

Type of change

  • Bug fix

What does this PR do?

The write tool schema defined content before filePath. Every other file tool (read, edit, apply_patch) puts filePath first. Small/quantized models are sensitive to property ordering in JSON schemas and use it as a positional cue — so with content first, they either omit filePath or get the key name wrong (e.g. producing file_path instead of filePath), causing:

Error: The write tool was called with invalid arguments: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "filePath"
    ],
    "message": "Invalid input: expected string, received undefined"
  }
]

The fix swaps the two parameters so filePath comes first, consistent with all other file tools.

How did you verify your code works?

Ran bun test test/tool/write.test.ts — 13/13 tests pass.

The bug only reproduces with a live small quantized model (originally observed with mlx-community/Qwen3-Coder-Next-4bit). The fix is a mechanical consistency change: filePath now comes first in the write tool schema, matching read, edit, and apply_patch.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@mapoit
Copy link

mapoit commented Mar 2, 2026

yes I can also see this error in qwen/qwen3.5-35b-a3b model with 4bit quantization.

@Rudd-O
Copy link

Rudd-O commented Mar 2, 2026

Can this please be merged? This is impacting us too.

@harmeet harmeet requested a review from adamdotdevin as a code owner March 7, 2026 15:06
@harmeet harmeet force-pushed the fix/write-tool-filepath-param-order branch from eb2f229 to 83526d6 Compare March 7, 2026 15:30
Harmeet Singh and others added 3 commits March 7, 2026 10:56
The mention search query is passed to the backend as-is, so using
backslashes on Windows produced no suggestions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@harmeet harmeet force-pushed the fix/write-tool-filepath-param-order branch from 83526d6 to 39e5371 Compare March 7, 2026 15:57
On slow environments (Windows CI), the ripgrep scan of the project
could still be in progress when the first @mention search fired,
returning an empty file list and no suggestions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

AI_InvalidToolInputError: Invalid input for tool write

3 participants