JuliusBrussee/caveman · error · Error

cave_delegate_missing_task

cave_delegate_missing_task

Error message

cave_delegate_missing_task

What it means

The caveman-delegate MCP server's `handle` function throws this when a tools/call request for the delegate tool arrives without a valid `task` string in `params.arguments.task`. The delegate's whole purpose is to run a delegated task string in a worker process; without it there is nothing to execute. It is an input-validation guard before spawning the worker.

Solutions

  1. Include a non-empty string `task` in the tool arguments: {"name": TOOL.name, "arguments": {"task": "..."}}
  2. Check the caller's JSON: ensure params.arguments exists and arguments.task is typeof string with length > 0
  3. If a wrapper produces the call, fix the key name so the prompt lands in `task`
  4. Log the incoming params before the call to confirm what the MCP client actually sent

Example fix

// before
await client.callTool({ name: "delegate", arguments: { prompt: "run tests" } });
// after
await client.callTool({ name: "delegate", arguments: { task: "run tests" } });
Defensive patterns

Strategy: validation

Validate before calling

const args = params?.arguments ?? {};
if (typeof args.task !== "string" || args.task.length === 0) {
  throw new Error("delegate tool requires a non-empty string 'task'");
}

Type guard

const hasTask = (p) => typeof p?.arguments?.task === "string" && p.arguments.task.length > 0;

Try / catch

try {
  await client.callTool({ name: "delegate", arguments: { task } });
} catch (e) {
  if (e.message === "cave_delegate_missing_task") {
    console.error("task argument missing or not a string — check tool call payload");
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the delegate tool with `arguments` missing, with `arguments.task` undefined, or with a non-string value (number, object, empty string) via MCP tools/call.

Common situations: An MCP client sends a hand-built tools/call JSON and omits the task field; a wrapper script serializes the task under a different key; a model hallucinates the tool schema and passes task as an object; empty task after trimming in upstream code.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at agents/delegate/caveman-delegate-mcp.mjs:143

  },
};

async function handle(msg) {
  const { id, method, params } = msg;
  if (method === "initialize") {
    return {
      protocolVersion: params?.protocolVersion || PROTOCOL_FALLBACK,
      capabilities: { tools: { listChanged: false } },
      serverInfo: { name: "caveman-delegate", version: "0.1.0" },
    };
  }
  if (method === "tools/list") return { tools: [TOOL] };
  if (method === "ping") return {};
  if (method === "tools/call") {
    if (params?.name !== TOOL.name) throw new Error(`unknown tool: ${params?.name}`);
    if (process.env.CAVEMAN_DELEGATE_CHILD === "1") throw new Error("cave_delegate_depth_exceeded");
    const task = params?.arguments?.task;
    if (!task || typeof task !== "string") throw new Error("cave_delegate_missing_task");
    const r = await runWorker(task, params?.arguments?.cwd);
    const lines = [r.out || "(worker produced no output)"];
    if (r.usage) {
      const u = r.usage;
      let usageLine = `delegate usage (measured, provider-reported): input ${u.input + u.cacheRead + u.cacheWrite} (cacheRead ${u.cacheRead}, cacheWrite ${u.cacheWrite}), output ${u.output}`;
      if (u.cost > 0) usageLine += `, cost $${u.cost.toFixed(4)}`;
      lines.push("---", usageLine);
    }
    if (r.code !== 0) {
      lines.push("---", `worker exit ${r.code}: ${r.err.slice(-500)}`);
      return { content: [{ type: "text", text: lines.join("\n") }], isError: true };
    }
    return { content: [{ type: "text", text: lines.join("\n") }] };
  }
  if (method?.startsWith("notifications/")) return undefined;
  throw Object.assign(new Error(`method not found: ${method}`), { code: -32601 });
}

View on GitHub (pinned to 3ee70a1026)