{"record":{"id":"c9278e87c68c6b05","repo":"JuliusBrussee/caveman","slug":"cave-subagent-framework-runner-required","errorCode":"cave_subagent_framework_runner_required","errorMessage":"cave_subagent_framework_runner_required","messagePattern":"cave_subagent_framework_runner_required","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/index.ts","lineNumber":204,"sourceCode":"  }\n  return tool({\n    name: options.name,\n    description: options.description,\n    input: schema.object({ task: schema.string() }),\n    effect: \"read\",\n    result: \"auto\",\n    ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),\n    runtime: {\n      kind: \"subagent\",\n      definition: options.agent,\n      maxInputChars,\n      maxCalls,\n      maxCostUsd,\n      ...(options.maxTokens === undefined ? {} : { maxTokens: options.maxTokens }),\n      maxContextTokens,\n    },\n    async execute() {\n      throw new Error(\"cave_subagent_framework_runner_required\");\n    },\n  });\n}\n","sourceCodeStart":186,"sourceCodeEnd":208,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/index.ts#L186-L208","documentation":"The `subagent()` tool's execute body is a deliberate placeholder that always throws `cave_subagent_framework_runner_required`. Subagent execution requires a framework-level runner (the host agent/SDK integration) to be wired in; the plain tool returned by `subagent()` cannot run the child loop itself. Hitting this error means the tool was invoked without that runner being installed.","triggerScenarios":"Calling the subagent tool directly (e.g. `tool.execute({ task })`) outside the framework that patches in a real runner; using `subagent()` in a standalone script or custom loop that never attaches the caveman runtime/runner.","commonSituations":"Testing the subagent tool in isolation with a hand-rolled agent loop; running under an older or custom harness that predates runner wiring; forgetting to call the framework bootstrap (e.g. ensureCaveRuntime or equivalent) before running the agent.","solutions":["Run the agent through the caveman framework entrypoint so the runner is attached before the subagent tool executes.","In tests, substitute a stub executor or use the framework's provided test harness instead of invoking execute directly.","Check for a newer/patched version of the caveman runtime if you believe the runner should already be wired (internal invariant breach)."],"exampleFix":"// before\nconst subagentTool = subagent({ name: \"helper\" });\nawait subagentTool.execute({ task: \"do work\" }); // throws\n// after\nimport { createAgent } from \"@caveman/agent\"; // framework bootstrap wires the runner\nconst agent = createAgent({ tools: [subagent({ name: \"helper\" })] });\nawait agent.run(\"delegate: do work\");","handlingStrategy":"try-catch","validationCode":"// Detect the placeholder executor before invoking:\nasync function runSubagentTool(t, input) {\n  let fired = false;\n  const probe = (...a) => { fired = true; throw new Error(\"abort-probe\"); };\n  // simpler: only call execute inside the framework-hosted agent\n  return t.execute(input);\n}","typeGuard":"const isPlaceholderSubagent = (t) => t.execute.length === 0 && t.name != null; // heuristic; prefer running via framework","tryCatchPattern":"try {\n  result = await subagentTool.execute({ task });\n} catch (e) {\n  if (e.message === \"cave_subagent_framework_runner_required\") {\n    throw new Error(\"Subagent tool used outside the caveman framework; run via createAgent/ensureCaveRuntime\", { cause: e });\n  }\n  throw e;\n}","preventionTips":["Never invoke tool.execute directly for subagent tools; always run through the framework's agent loop","In tests, register a stub runner or use the framework's test harness","Pin and bootstrap the runtime (ensureCaveRuntime) before dispatching any tool calls","Treat this error as an integration bug: it should be unreachable in production wiring"],"tags":["runner","framework","unsupported-operation"],"backgroundTag":"method-not-implemented","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"}