{"record":{"id":"a8b428f29fa75d63","repo":"JuliusBrussee/caveman","slug":"cave-gateway-required-for-locked-plan","errorCode":"cave_gateway_required_for_locked_plan","errorMessage":"cave_gateway_required_for_locked_plan: Cave Build execution routes through the Caveman gateway; run unlocked for observe-only","messagePattern":"cave_gateway_required_for_locked_plan: Cave Build execution routes through the Caveman gateway; run unlocked for observe-only","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":5094,"sourceCode":"    billingProofRequired?: boolean;\n  },\n  planPresent: boolean,\n): Promise<ResolvedCaveRoute> {\n  if (options.caveRoute !== undefined) {\n    if (!options.billingProofRequired || !options.caveRoute.useGateway ||\n        options.caveRoute.providerBilling === \"managed\" ||\n        options.caveRoute.providerBilling === \"byok\") {\n      return options.caveRoute;\n    }\n    const identity = await gatewayIdentity(gatewayURL, options.fetch ?? globalThis.fetch);\n    return {\n      ...options.caveRoute,\n      providerBilling: identity?.providerBilling ?? \"unknown\",\n    };\n  }\n  if (options.cave === \"off\") {\n    if (planPresent) {\n      throw new Error(\n        \"cave_gateway_required_for_locked_plan: Cave Build execution routes through the Caveman gateway; run unlocked for observe-only\",\n      );\n    }\n    return { useGateway: false, providerBilling: \"unknown\" };\n  }\n  if (options.ensureRuntime === false) {\n    try {\n      const url = new URL(gatewayURL);\n      if (isLoopbackHostname(url.hostname)) {\n        const providerBilling = options.billingProofRequired\n          ? (await gatewayIdentity(gatewayURL, options.fetch ?? globalThis.fetch))?.providerBilling ??\n            \"unknown\"\n          : \"unknown\";\n        return { useGateway: true, providerBilling };\n      }\n      // Remote gateways still have to prove Caveman identity. `ensureCaveRuntime`\n      // never starts a process for non-loopback URLs; it only enforces HTTPS and\n      // performs the content-blind ownership handshake.","sourceCodeStart":5076,"sourceCodeEnd":5112,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/runtime.ts#L5076-L5112","documentation":"A run carrying a locked build or candidate plan (`planPresent`) was explicitly configured with `cave: \"off\"`. Locked-plan execution routes through the Caveman gateway by contract; silently degrading to observe-only would break the plan's guarantees, so the runtime throws. Without a plan, `cave: \"off\"` is fine and yields observe-only mode.","triggerScenarios":"Calling `run()`/`startCodingSession()` with `cave: \"off\"` while the options (or session defaults) include a locked build or candidate plan — e.g. explicitly disabling the gateway on an optimized run, or a config file that sets `cave: \"off\"` globally while the build compiler attached a plan.","commonSituations":"Setting `CAVE=off`-style config to 'save money' while still running an optimized/locked build, a shared config that disables cave for all runs including locked ones, or upgrading from an unlocked workflow to a locked one without re-enabling the gateway.","solutions":["Remove `cave: \"off\"` (or set `cave` to the gateway mode) so the locked plan can route through the gateway","Run unlocked (drop the locked build/candidate plan) if you deliberately want an observe-only, non-gateway run","Separate configs: keep locked-plan runs on gateway routing and use `cave: \"off\"` only for plain unlocked runs"],"exampleFix":"// before\nawait run({ ...planOptions, cave: \"off\" });\n// after\nawait run({ ...planOptions }); // gateway routing for the locked plan\n// or, for observe-only:\nawait run({ prompt }); // no locked plan, cave off allowed","handlingStrategy":"validation","validationCode":"if (options.cave === 'off' && (options.lockedBuild || options.candidatePlan || 'efficiencyPlan' in options)) throw new Error('cave: \"off\" cannot be combined with a locked plan');","typeGuard":null,"tryCatchPattern":"try { await run(options); } catch (e) { if (String((e as Error).message).startsWith('cave_gateway_required_for_locked_plan')) { /* either enable gateway routing or drop the plan */ } else throw e; }","preventionTips":["Keep cave on (gateway routing) for all locked-plan/optimized runs","Use cave: \"off\" only for plain unlocked runs","Audit shared config for a global cave-off setting before attaching plans"],"tags":["configuration","gateway","locked-plan"],"backgroundTag":"conflicting-config-options","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"}