Skip to content

fix(agent-runtime): reject differing spellings of one tool argument - #2642

Merged
vastsa merged 2 commits into
mainfrom
fix/tool-path-alias-conflict
Nov 28, 2026
Merged

vastsa merged 2 commits into
mainfrom
fix/tool-path-alias-conflict

Conversation

@vastsa

@vastsa vastsa commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Fixes #2552.

Root cause

Every malformed call the reporter recovered carried junk in path and the clean value in an alias:

{ "path": "src/pages/Wizard.tsx here?", "file_path": "src/pages/Wizard.tsx" }
{ "path": "src/pages/Wizard.tsx:{",     "file_path": "src/pages/Wizard.tsx" }

normalizeToolParams let the canonical name win when both arrived (D273). It dropped the clean file_path and ran the junk path on every retry, so host-core never saw the value the model also sent. Both fields are in the schema, so models fill both.

Fix

A call that names one argument under several accepted spellings with different values now fails with INVALID_ARGUMENT before the write lock and the host call. The message quotes each value and asks for path alone:

Invalid arguments for Read: `path` = "src/pages/Wizard.tsx here?", `file_path` = "src/pages/Wizard.tsx" name the same argument with different values. Send only `path`, with the exact intended value. Example: {"path": "..."}.
  • Identical values still fold into one argument. Single-spelling calls are unchanged.
  • The check covers Read/Write/Edit/BrowserPreview (path) and Glob/Grep (pattern), including two aliases without the canonical name.
  • It runs on the raw arguments in both validation points (execute and preparePathToolCall). normalizeToolParams stays non-throwing because the batch planner calls it too.
  • The alias map and its validation move from runtime.ts into tool-param-aliases.ts, so the hotspot shrinks by 49 LOC.
  • Historical transcripts keep their meaning: the compaction file-op collector still reads path first, which is how those calls ran.
  • Spec 03-runtime/03-tools-and-permissions.md and decision D690 (amends D273) record the change.

The malformed Edit tags (9DA2 nope?) are a separate symptom. They already fail with EDIT_TAG_REQUIRED and are not changed here. Where the suffixes originate (model, endpoint, or stream assembly) is still unknown.

Verification

Base origin/main 09400b27c, macOS arm64.

  • packages/agent-runtime vitest: 146 files / 2181 tests pass. The alias test now covers:

    • Read with the reporter's here? shape: rejected, and the message quotes both values
    • Edit with :{: rejected
    • Write with two differing aliases: rejected
    • Grep with pattern vs query: rejected
    • identical values: fold into one
    • no tools.execute call for any rejected call

    It replaces the old "canonical wins" assertion.

  • Package builds (tsc), biome lint, check-architecture (runtime.ts shrinks), docs:check, check:pr-base: pass.

Calls in #2552 stored conversational junk in `path` ("Wizard.tsx here?",
"Wizard.tsx:{") next to a clean `file_path`. D273 let the canonical name
win when both arrived, so every retry ran the junk path and host-core
never saw the clean value. Picking either spelling is a guess, so a call
whose spellings disagree now fails with INVALID_ARGUMENT before the write
lock and host call, quoting each value so the next call can send one.
Identical values still fold to one argument.

The alias map and its validation move from runtime.ts into
tool-param-aliases.ts, shrinking the hotspot. Spec 03 and D690 record
the amendment to D273.

fixes #2552
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Deploying pi-desktop with  Cloudflare Pages  Cloudflare Pages

Latest commit: 477b82b
Status: ✅  Deploy successful!
Preview URL: https://329ba897.pi-desktop.pages.dev
Branch Preview URL: https://fix-tool-path-alias-conflict.pi-desktop.pages.dev

View logs

@vastsa

vastsa commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

I independently checked this on 6ff8d4fd0 and head 477b82bc. For both stored Read shapes from #2552, the baseline normalizer kept the malformed path and dropped the clean alias. The candidate validator rejected both with INVALID_ARGUMENT; identical and single-spelling arguments still passed, and conflicting Write and Grep aliases were rejected (8 focused assertions). The full local runtime suite could not start because the shared pi-ai install does not export ./utils/hosted-search.

The runtime change addresses that confirmed conflict, but the PR should not automatically close #2552. The reported EDIT_TAG_REQUIRED retry failure is untouched, and the issue still tracks where the suffixes first enter the tool arguments. Please change Fixes #2552 to Refs #2552 and describe this as the conflicting-alias diagnostic, not a fix for the upstream malformed arguments.

The first Windows Host E2E attempt failed when the visualization fork fixture timed out waiting for Bash. That log does not establish whether the failure is transient. This is not an approval; the refreshed check results and required candidate validation still need to be confirmed before merging.

@vastsa
vastsa merged commit ad15547 into main Nov 28, 2026
10 of 11 checks passed
@vastsa
vastsa deleted the fix/tool-path-alias-conflict branch November 28, 2026 08:28
zergfff added a commit to zergfff/PI-Desktop-fork that referenced this pull request Nov 30, 2026
Ported from vastsa/PI-Desktop v0.24.0-beta.7 (bug fixes only; the release's
features were left for a later rebase):

vastsa#2625 quarantine rejected outbox appends instead of retrying them forever
vastsa#2574 settle live turns and tool rows when the sidecar dies mid-stream
vastsa#2578 native Pi turns stay stoppable after a reload
vastsa#2634 the task badge mirrors work that is still running
vastsa#2639 let Arabic and Hebrew paragraphs choose their own side
vastsa#2640 stop a renderer crash loop with one GPU-less relaunch, then a dialog
vastsa#2642 reject differing spellings of one tool argument
vastsa#2655 compaction summaries open on demand in the transcript
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.

[Bug] Repeated malformed Read/Edit tool calls with GPT-6.1 Terra causing

1 participant