Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(runtime): fold weak-model path aliases so Read stops falling back to Bash
vastsa55e513e2f515
diff --git a/packages/agent-runtime/src/runtime.test.ts b/packages/agent-runtime/src/runtime.test.tsindex 90189d6fa..5e60d2430 100644--- a/packages/agent-runtime/src/runtime.test.ts+++ b/packages/agent-runtime/src/runtime.test.ts@@ -1132,13 +1132,35 @@ describe("DesktopAgentRuntime configuration matching", () => {});expect(lastExecute()).toMatchObject({ args: { path: "src/canonical.ts" } });+ // Extra path spellings weaker models reach for (issue #454): every one of+ // these folds onto `path` so the model does not silently fall back to Bash+ // when its tokenizer prefers a non-canonical argument name.+ for (const alias of ["filepath", "filePath", "filename", "fileName", "file"]) {+ await tool("Read").execute(`read-${alias}`, {+ [alias]: `src/${alias}.ts`,+ });+ expect(lastExecute()).toMatchObject({+ toolName: "Read",+ args: { path: `src/${alias}.ts` },+ });+ const seen = lastExecute().args as Record<string, unknown>;+ expect(seen[alias]).toBeUndefined();+ }+// Neither spelling present still fails, and before any host execution.+ // The message now names the accepted aliases and shows a minimal example+ // so the next call can self-correct instead of falling back to shell.await expect(tool("Read").execute("read-missing", { limit: 5 }),- ).rejects.toMatchObject({ errorCode: "INVALID_ARGUMENT" });+ ).rejects.toMatchObject({+ errorCode: "INVALID_ARGUMENT",+ message: expect.stringMatching(+ /`path` is required.*(file_path|filepath).*Example.*"path"/s,+ ),+ });expect(host.call.mock.calls.filter((call: unknown[]) => call[0] === "tools.execute"),- ).toHaveLength(3);+ ).toHaveLength(3 + 5);await runtime.dispose();});diff --git a/packages/agent-runtime/src/runtime.ts b/packages/agent-runtime/src/runtime.tsindex 76c78cd3e..565c5e70f 100644--- a/packages/agent-runtime/src/runtime.ts+++ b/packages/agent-runtime/src/runtime.ts@@ -1058,13 +1058,24 @@ const MAX_ACCEPTED_COMMAND_TIMEOUT = 100_000_000;* name. Every strong model has `file_path`/`query` burned in from pretraining* and sends them regardless of what the schema says, so the schema accepts both* spellings and {@link normalizeToolParams} folds the alias away before the- * host sees the call (D273).+ * host sees the call (D273). Weaker models — issue #454 pinned longcat 2.0 —+ * reach for `filepath` / `filename` / `filePath` / `file` instead; folding+ * those the same way rescues the turn before the model gives up on the tool+ * and silently falls back to Bash.*/+const PATH_ARG_ALIASES = {+ file_path: "path",+ filepath: "path",+ filePath: "path",+ filename: "path",+ fileName: "path",+ file: "path",+} as const;const TOOL_PARAM_ALIASES: Record<string, Record<string, string>> = {- Read: { file_path: "path" },- Write: { file_path: "path" },- Edit: { file_path: "path" },- BrowserPreview: { file_path: "path" },+ Read: { ...PATH_ARG_ALIASES },+ Write: { ...PATH_ARG_ALIASES },+ Edit: { ...PATH_ARG_ALIASES },+ BrowserPreview: { ...PATH_ARG_ALIASES },Glob: { query: "pattern" },Grep: { query: "pattern" },};@@ -1150,9 +1161,22 @@ function requireAliasedParams(toolName: string, params: unknown): void {if (!aliases || !isRecord(params)) return;for (const canonical of new Set(Object.values(aliases))) {if (params[canonical] !== undefined) continue;+ // A weaker model that keeps hitting this error gives up on the tool and+ // silently switches to Bash (issue #454). Naming the accepted spellings and+ // showing a minimal example lets the next call self-correct instead of the+ // whole turn falling back to shell.+ const acceptedAliases = Object.keys(aliases).filter(+ (alias) => aliases[alias] === canonical,+ );+ const aliasHint =+ acceptedAliases.length > 0+ ? ` (the alias${acceptedAliases.length > 1 ? "es" : ""} ${acceptedAliases+ .map((name) => `\`${name}\``)+ .join(", ")} ${acceptedAliases.length > 1 ? "are" : "is"} also accepted)`+ : "";throw Object.assign(new Error(- `Invalid arguments for ${toolName}: \`${canonical}\` is required`,+ `Invalid arguments for ${toolName}: \`${canonical}\` is required${aliasHint}. Example: {"${canonical}": "..."}.`,),{ errorCode: "INVALID_ARGUMENT" },);