{"record":{"id":"0e5913b7a83c0bde","repo":"JuliusBrussee/caveman","slug":"unknown-argument-s-unknown-sort-join","errorCode":null,"errorMessage":"unknown argument(s): ${unknown.sort().join(\", \")}","messagePattern":"unknown argument\\(s\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/agent-mcp.ts","lineNumber":546,"sourceCode":"  if (cursor !== undefined) {\n    if (!cursor || typeof cursor !== \"object\" || Array.isArray(cursor)) throw new Error(\"cursor must be an object\");\n    const unknown = Object.keys(cursor).filter((key) => key !== \"sort_value\" && key !== \"request_id\" && key !== \"group_key\");\n    if (unknown.length > 0) throw new Error(`cursor has unknown key(s): ${unknown.sort().join(\", \")}`);\n    if (typeof cursor.sort_value !== \"string\" || cursor.sort_value === \"\") throw new Error(\"cursor.sort_value is required\");\n    for (const key of [\"request_id\", \"group_key\"]) {\n      if (cursor[key] !== undefined && typeof cursor[key] !== \"string\") throw new Error(`cursor.${key} must be a string`);\n    }\n  }\n}\n\nasync function callTool(client: AgentMcpClient, name: string, rawArgs: unknown): Promise<ToolResult> {\n  const started = Date.now();\n  let outcome: \"ok\" | \"error\" = \"ok\";\n  try {\n    const args = objectArg(rawArgs);\n    const allowed = TOOL_ARGUMENT_KEYS[name];\n    const unknown = Object.keys(args).filter((key) => !allowed?.has(key));\n    if (unknown.length > 0) throw new Error(`unknown argument(s): ${unknown.sort().join(\", \")}`);\n    let value: JSONValue;\n    switch (name) {\n      case \"caveman_context\": {\n        const [identity, projects, selectedProjectId] = await Promise.all([\n          client.request(\"/api/v1/auth/me\"),\n          client.request(\"/api/v1/projects\"),\n          client.projectId(),\n        ]);\n        value = { identity, projects, selected_project_id: selectedProjectId };\n        break;\n      }\n      case \"caveman_report\": {\n        const report = stringArg(args, \"report\");\n        const reportPath = REPORT_PATHS[report];\n        if (!reportPath) throw new Error(`unknown report: ${report}`);\n        value = await client.request(await withProjectQuery(client, reportPath));\n        break;\n      }","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/agent-mcp.ts#L528-L564","documentation":"callTool validates every tool invocation against TOOL_ARGUMENT_KEYS, a per-tool allowlist of argument names. This error means the tool call contained at least one argument key that is not part of the named tool's schema, so the CLI refuses to forward it to the API.","triggerScenarios":"Calling any caveman_* MCP tool with a misspelled or extra key, e.g. caveman_trace_search with {q:\"...\"} instead of {query:\"...\"}, or leftovers like {verbose:true}.","commonSituations":"Prompt drift after a tool schema rename; agents hallucinating parameter names; copy-paste of arguments between different tools with overlapping but not identical schemas.","solutions":["Remove the offending key(s) listed in the error (they are sorted and joined)","Check the exact argument names for the tool in TOOL_ARGUMENT_KEYS","Fix typos, e.g. rename q to query","Regenerate/refresh the tool schema the calling agent was built from"],"exampleFix":"// before\nawait callTool(client, \"caveman_trace_search\", { q: \"timeout\", limit: 10 });\n// after\nawait callTool(client, \"caveman_trace_search\", { query: \"timeout\", limit: 10 });","handlingStrategy":"validation","validationCode":"const ALLOWED = { caveman_report: new Set([\"report\"]), caveman_trace_search: new Set([\"query\",\"limit\",\"cursor\"]) };\nconst extra = Object.keys(args).filter(k => !ALLOWED[toolName]?.has(k));\nif (extra.length) throw new Error(\"strip keys: \" + extra.join(\",\"));","typeGuard":"null","tryCatchPattern":"try { ... } catch (e) { if (e.message.startsWith(\"unknown argument(s)\")) { const bad = e.message.slice(\"unknown argument(s): \".length).split(\", \"); for (const k of bad) delete args[k]; return retry(); } throw e; }","preventionTips":["Generate tool arguments from the same schema the CLI validates against","Strip unknown keys before calling instead of forwarding raw LLM output","Diff your client tool schemas against the CLI after each upgrade","Avoid spreading arbitrary objects into tool args"],"tags":["validation","cli","argument-validation"],"backgroundTag":"invalid-argument","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}