{"record":{"id":"124f8cf4ada05c84","repo":"JuliusBrussee/caveman","slug":"assemble-requires-model-and-session-id","errorCode":null,"errorMessage":"assemble requires model and session_id","messagePattern":"assemble requires model and session_id","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/sdk/python/caveman_cloud/core.py","lineNumber":438,"sourceCode":"        \"\"\"A fresh :class:`RetryLoopBreaker` that interrupts a repeated identical\n        tool-call loop after ``threshold`` consecutive repeats.\n        \"\"\"\n        return RetryLoopBreaker(threshold=threshold)\n\n    def assemble(self, options: AssembleOptions) -> AssemblyResult:\n        \"\"\"Build a provider request with stable/session content above volatile.\n\n        Pure client-side: no account and no network call. The hash ledger is\n        in-process and scoped by ``session_id``; deterministic slot content\n        across processes remains the builder's obligation.\n\n        ``emit_cache_hints=\"gateway\"`` (default) emits no provider hint so the\n        gateway optimizer retains attribution. ``\"self\"`` places provider\n        hints for direct calls but mints nothing.\n        \"\"\"\n        provider = options.provider.strip().lower()\n        if not options.model or not options.session_id:\n            raise ValueError(\"assemble requires model and session_id\")\n        if options.emit_cache_hints not in {\"gateway\", \"self\", \"none\"}:\n            raise ValueError(f\"unknown emit_cache_hints value {options.emit_cache_hints!r}\")\n\n        ids: set[str] = set()\n        normalized: list[AssemblySlot] = []\n        for slot in options.slots:\n            if not slot.id or slot.id in ids:\n                raise ValueError(f\"assembly slot id must be non-empty and unique: {slot.id!r}\")\n            ids.add(slot.id)\n            if slot.stability not in {\"stable\", \"session\", \"volatile\"}:\n                raise ValueError(\n                    f\"assembly slot {slot.id!r} has unknown stability {slot.stability!r}\"\n                )\n            try:\n                content_json = _canonical_json(slot.content)\n                content = json.loads(content_json)\n            except (TypeError, ValueError):\n                raise ValueError(","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/sdk/python/caveman_cloud/core.py#L420-L456","documentation":"`assemble()` requires both `model` and `session_id` in the options because the assembly cache/stability ledger is keyed per session and per model. It raises this ValueError immediately when either field is empty or missing.","triggerScenarios":"Calling `cave.assemble(AssembleOptions(...))` with `model=\"\"`, `session_id=\"\"`, or omitting these fields on the options object.","commonSituations":"Building options dynamically where the model name comes from an unset env var or a failed lookup, or forgetting to generate a session id on a new session.","solutions":["Set both `model` and `session_id` to non-empty strings before calling `assemble()`.","Generate a session id at session start (e.g. `uuid4().hex`) if one is missing.","Fail fast in your own code: validate options before invoking `assemble()`."],"exampleFix":"// before\nopts = AssembleOptions(provider=\"anthropic\", model=\"\", session_id=sid)\ncave.assemble(opts)\n// after\nopts = AssembleOptions(provider=\"anthropic\", model=\"claude-sonnet-4\", session_id=sid)\ncave.assemble(opts)","handlingStrategy":"validation","validationCode":"def can_assemble(opts) -> bool:\n    return bool(opts.model) and bool(opts.session_id)","typeGuard":null,"tryCatchPattern":"try:\n    result = cave.assemble(opts)\nexcept ValueError as e:\n    logger.error(\"assemble options invalid: %s\", e)\n    raise","preventionTips":["Generate a session id (uuid4) at session start","Resolve the model name from a single config constant","Validate options objects before every assemble() call"],"tags":["python","validation","assembly"],"backgroundTag":"missing-required-argument","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"}