JuliusBrussee/caveman · error

unknown experiment read action

Error message

unknown experiment read action: ${action}

What it means

Dispatch error in the MCP callTool handler for experiment reads: the action string supplied by the client is not one of the implemented experiment read actions. The switch over known actions fell through, so the requested view cannot be produced.

Solutions

  1. Use action: "list", "get", or "results" exactly
  2. For mutations, find the separate experiment write tool instead of caveman_experiment_get
  3. Fix typos in the action string
  4. Note that "get" and "results" also require experiment_id

Example fix

// before
await callTool(client, "caveman_experiment_get", { action: "fetch", experiment_id: "e1" });
// after
await callTool(client, "caveman_experiment_get", { action: "get", experiment_id: "e1" });
Defensive patterns

Strategy: validation

Validate before calling

const READ_ACTIONS = ["list","get","results"];
if (!READ_ACTIONS.includes(args.action)) throw new Error("action must be one of " + READ_ACTIONS.join("|"));

Type guard

function isExperimentReadAction(a: string): a is "list"|"get"|"results" { return ["list","get","results"].includes(a); }

Try / catch

try { ... } catch (e) { if (e.message.startsWith("unknown experiment read action")) { return callTool(client, "caveman_experiment_get", { action: "list" }); } throw e; }

Prevention

When it happens

Trigger: Calling caveman_experiment_get with {action:"delete"}, {action:"create"}, {action:"fetch"}, or an empty action string.

Common situations: Agents conflating read and write tool variants; typos like 'lists' or 'result'; older prompts referencing actions that were removed from the read tool.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

        value = await client.request(`/api/v1/traces/search?${new URLSearchParams({ project_id: projectId })}`, {
          method: "POST",
          body: args,
        });
        break;
      }
      case "caveman_trace_get": {
        const traceId = encodeURIComponent(stringArg(args, "trace_id"));
        const projectQuery = `?${new URLSearchParams({ project_id: await client.projectId() })}`;
        const [trace, spans] = await Promise.all([
          client.request(`/api/v1/traces/${traceId}${projectQuery}`),
          client.request(`/api/v1/traces/${traceId}/spans${projectQuery}`),
        ]);
        value = { trace: metadataOnlyTrace(trace), spans: metadataOnlySpans(spans) };
        break;
      }
      case "caveman_experiment_get": {
        const action = stringArg(args, "action");
        if (!["list", "get", "results"].includes(action)) throw new Error(`unknown experiment read action: ${action}`);
        if (action === "list") {
          value = await client.request(await withProjectQuery(client, "/api/v1/experiments"));
          break;
        }
        const experimentId = encodeURIComponent(stringArg(args, "experiment_id"));
        const query = new URLSearchParams({ project_id: await client.projectId() });
        value = await client.request(`/api/v1/experiments/${experimentId}${action === "results" ? "/results" : ""}?${query}`);
        break;
      }
      default:
        throw new Error(`unknown tool: ${name}`);
    }
    return result(value);
  } catch (error) {
    outcome = "error";
    return errorResult(error);
  } finally {
    client.recordToolCall?.({ tool: name, result: outcome, durationMs: Date.now() - started });

View on GitHub (pinned to 3ee70a1026)