{"record":{"id":"562d0e6ac69cccc1","repo":"JuliusBrussee/caveman","slug":"assembly-slot-json-stringify-slotid-changed-af","errorCode":null,"errorMessage":"assembly slot ${JSON.stringify(slotId)} changed after being declared stable","messagePattern":"assembly slot (.+?) changed after being declared stable","errorType":"exception","errorClass":"AssemblyStabilityError","httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":1831,"sourceCode":"    assemblyHashLedgers.set(cave, ledger);\n  }\n  const normalized = options.slots.map((slot) => {\n    if (!slot.id || ids.has(slot.id)) throw new Error(`assembly slot id must be non-empty and unique: ${JSON.stringify(slot.id)}`);\n    ids.add(slot.id);\n    if (![\"stable\", \"session\", \"volatile\"].includes(slot.stability)) {\n      throw new Error(`assembly slot ${JSON.stringify(slot.id)} has unknown stability ${JSON.stringify(slot.stability)}`);\n    }\n    let contentJSON: string;\n    try {\n      contentJSON = canonicalJSON(slot.content);\n    } catch {\n      throw new Error(`assembly slot ${JSON.stringify(slot.id)} content is not JSON-serializable`);\n    }\n    const contentHash = sha256Hex(contentJSON);\n    if (slot.stability !== \"volatile\") {\n      const key = `${options.sessionId}\\0${slot.id}`;\n      const previous = ledger.get(key);\n      if (previous !== undefined && previous !== contentHash) throw new AssemblyStabilityError(slot.id);\n      ledger.set(key, contentHash);\n    }\n    return { ...slot, content: JSON.parse(contentJSON) as unknown };\n  });\n\n  const ordered = ([\"stable\", \"session\", \"volatile\"] as const)\n    .flatMap((stability) => normalized.filter((slot) => slot.stability === stability));\n  const prefixSlots = ordered.filter((slot) => slot.stability !== \"volatile\");\n  const volatileSlots = ordered.filter((slot) => slot.stability === \"volatile\");\n\n  let request: Record<string, unknown>;\n  let prefixBytes: string;\n  let breakpoints: string[] = [];\n\n  if (provider === \"anthropic\") {\n    const toolsSlot = prefixSlots.find((slot) => slot.id === \"tools\" && Array.isArray(slot.content));\n    const systemSlots = prefixSlots.filter((slot) => slot !== toolsSlot);\n    const system = systemSlots.map((slot) => ({ type: \"text\", text: assemblyText(slot.content) }));","sourceCodeStart":1813,"sourceCodeEnd":1849,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/sdk/typescript/src/index.ts#L1813-L1849","documentation":"Error \"assembly slot ${JSON.stringify(slotId)} changed after being declared stable\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:1831 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not mutate a slot after declaring it stable; create a new slot version instead."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}