JuliusBrussee/caveman · error

unknown argument(s)

Error message

unknown argument(s): ${unknown.sort().join(", ")}

What it means

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.

Solutions

  1. Remove the offending key(s) listed in the error (they are sorted and joined)
  2. Check the exact argument names for the tool in TOOL_ARGUMENT_KEYS
  3. Fix typos, e.g. rename q to query
  4. Regenerate/refresh the tool schema the calling agent was built from

Example fix

// before
await callTool(client, "caveman_trace_search", { q: "timeout", limit: 10 });
// after
await callTool(client, "caveman_trace_search", { query: "timeout", limit: 10 });
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = { caveman_report: new Set(["report"]), caveman_trace_search: new Set(["query","limit","cursor"]) };
const extra = Object.keys(args).filter(k => !ALLOWED[toolName]?.has(k));
if (extra.length) throw new Error("strip keys: " + extra.join(","));

Type guard

null

Try / catch

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; }

Prevention

When it happens

Trigger: 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}.

Common situations: Prompt drift after a tool schema rename; agents hallucinating parameter names; copy-paste of arguments between different tools with overlapping but not identical schemas.

Understand the failure class

Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/0e5913b7a83c0bde. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/agent-mcp.ts:546

  if (cursor !== undefined) {
    if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) throw new Error("cursor must be an object");
    const unknown = Object.keys(cursor).filter((key) => key !== "sort_value" && key !== "request_id" && key !== "group_key");
    if (unknown.length > 0) throw new Error(`cursor has unknown key(s): ${unknown.sort().join(", ")}`);
    if (typeof cursor.sort_value !== "string" || cursor.sort_value === "") throw new Error("cursor.sort_value is required");
    for (const key of ["request_id", "group_key"]) {
      if (cursor[key] !== undefined && typeof cursor[key] !== "string") throw new Error(`cursor.${key} must be a string`);
    }
  }
}

async function callTool(client: AgentMcpClient, name: string, rawArgs: unknown): Promise<ToolResult> {
  const started = Date.now();
  let outcome: "ok" | "error" = "ok";
  try {
    const args = objectArg(rawArgs);
    const allowed = TOOL_ARGUMENT_KEYS[name];
    const unknown = Object.keys(args).filter((key) => !allowed?.has(key));
    if (unknown.length > 0) throw new Error(`unknown argument(s): ${unknown.sort().join(", ")}`);
    let value: JSONValue;
    switch (name) {
      case "caveman_context": {
        const [identity, projects, selectedProjectId] = await Promise.all([
          client.request("/api/v1/auth/me"),
          client.request("/api/v1/projects"),
          client.projectId(),
        ]);
        value = { identity, projects, selected_project_id: selectedProjectId };
        break;
      }
      case "caveman_report": {
        const report = stringArg(args, "report");
        const reportPath = REPORT_PATHS[report];
        if (!reportPath) throw new Error(`unknown report: ${report}`);
        value = await client.request(await withProjectQuery(client, reportPath));
        break;
      }

View on GitHub (pinned to 3ee70a1026)