{"record":{"id":"f8d64561eb69e773","repo":"JuliusBrussee/caveman","slug":"cave-cache-volatile-stable-slot","errorCode":"cave_cache_volatile_stable_slot","errorMessage":"cave_cache_volatile_stable_slot","messagePattern":"cave_cache_volatile_stable_slot","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":1405,"sourceCode":"      provider: routedModel.provider,\n      model: routedModel.id,\n      api: routedModel.api,\n      prefixDigest,\n      buildIdentity: buildIdentity ?? null,\n      lockedPlanSHA256: buildIdentity?.planSha256 ?? null,\n      executionPlanSHA256: efficiencyPlan === undefined\n        ? null\n        : sha256(stableStringify(efficiencyPlan)),\n    }));\n    if (conversation?.fingerprint !== undefined &&\n        conversation.fingerprint !== conversationFingerprint) {\n      conversation.cachePrefixDigest = undefined;\n      conversation.providerFrozen = undefined;\n      conversation.originalFrozen = undefined;\n    }\n    if (conversation) conversation.fingerprint = conversationFingerprint;\n    if (efficiencyPlan?.segment_routes.length && volatileStablePrefix(instructions, definition.tools)) {\n      throw new Error(\"cave_cache_volatile_stable_slot\");\n    }\n    // Every x-cave-* header exists for the Caveman gateway: x-cave-api-key is\n    // an account credential, and agent/workflow/session/cache-epoch/prefix\n    // digest/context bill/build+plan digests are account-linked identifiers and\n    // internal telemetry. A request that does not go through the gateway goes to\n    // a third party, so it carries none of them.\n    const headers = gatewayActive\n      ? runtimeHeaders(\n        definition.id,\n        options.workflow ?? definition.id,\n        sessionId,\n        buildIdentity,\n        bill,\n        appliedPlan.appliedTransformIDs,\n        prefixDigest,\n        conversationFingerprint,\n        executionContext.invocationState.batch?.apiKey,\n        executionContext.invocationState.batch === undefined ? undefined : executionContext.invocationTrace,","sourceCodeStart":1387,"sourceCodeEnd":1423,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/runtime.ts#L1387-L1423","documentation":"Thrown when an efficiency plan routes multiple prompt segments but the instructions/tools prefix is \"volatile stable\" — content that changes between calls yet sits in a prefix position that caching depends on. Caching such a slot would produce unreliable cache hits, so the library refuses the plan up front.","triggerScenarios":"Calling streamAgent with an efficiencyPlan whose segment_routes.length > 0 while volatileStablePrefix(instructions, definition.tools) reports the stable-but-volatile prefix condition (e.g. instructions or tool definitions contain nondeterministic content like timestamps or generated IDs).","commonSituations":"Building instructions with Date.now(), random IDs, or per-run content while also enabling efficiency-plan segment routing; a cache-epoch change that cleared the prefix digest right before planning.","solutions":["Make the instructions and tool definitions byte-stable across calls (remove timestamps/random content) when using an efficiency plan","Disable segment routing in the efficiencyPlan (empty segment_routes)","Regenerate the instructions deterministically or freeze them for the run"],"exampleFix":"// before\nconst instructions = `You are X. Run ${Date.now()}`;\nstreamAgent({ instructions, efficiencyPlan });\n// after\nconst instructions = `You are X.`;\nstreamAgent({ instructions, efficiencyPlan });","handlingStrategy":"validation","validationCode":"if (efficiencyPlan?.segment_routes.length && /Date\\.now|Math\\.random|crypto\\.randomUUID/.test(instructions)) {\n  throw new Error(\"instructions must be byte-stable for segment routing\");\n}","typeGuard":null,"tryCatchPattern":"try { await streamAgent(opts); } catch (e) { if (e.message === \"cave_cache_volatile_stable_slot\") { /* stabilize prefix or drop segment routing */ } else throw e; }","preventionTips":["Keep instructions and tool definitions deterministic across calls","Never embed timestamps/random IDs in cached prefix positions","Enable segment routing only on frozen, stable prefixes"],"tags":["caching","prompt-prefix","efficiency-plan","configuration"],"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"}