{"record":{"id":"1f5836b0e2d1915b","repo":"langchain-ai/deepagents","slug":"system-prompt-missing-required-format-slot-s","errorCode":null,"errorMessage":"system_prompt missing required format slot(s): {', '.join(missing)}","messagePattern":"system_prompt missing required format slot\\(s\\): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/skills.py","lineNumber":846,"sourceCode":"                to skip appending entirely (skills are still loaded into\n                `state[\"skills_metadata\"]`).\n\n        Raises:\n            TypeError: If a tuple entry in `sources` is not exactly a\n                `(str, str)` pair, or if `system_prompt` is not `str` or\n                `None`.\n            ValueError: If `system_prompt` is a string missing any of the\n                required format slots.\n        \"\"\"\n        if system_prompt is not None:\n            if not isinstance(system_prompt, str):\n                msg = f\"system_prompt must be str or None, got {type(system_prompt).__name__}\"\n                raise TypeError(msg)\n            required = (\"{skills_locations}\", \"{skills_load_warnings}\", \"{skills_list}\")\n            missing = [slot for slot in required if slot not in system_prompt]\n            if missing:\n                msg = f\"system_prompt missing required format slot(s): {', '.join(missing)}\"\n                raise ValueError(msg)\n        self._backend = backend\n        # `self.sources` remains paths-only (`list[str]`) to preserve\n        # backwards-compat for callers that inspect it directly; label\n        # information is mirrored on `self.source_labels` at the same index.\n        self.sources: list[str] = [_source_path(s) for s in sources]\n        self.source_labels: list[str] = [_derive_source_label(s) for s in sources]\n        self.system_prompt_template = system_prompt\n\n    def _format_skills_locations(self) -> str:\n        \"\"\"Format skills locations for display in system prompt.\"\"\"\n        locations = []\n        last = len(self.sources) - 1\n\n        for i, (source_path, label) in enumerate(zip(self.sources, self.source_labels, strict=True)):\n            suffix = \" (higher priority)\" if i == last else \"\"\n            locations.append(f\"**{label} Skills**: `{source_path}`{suffix}\")\n\n        return \"\\n\".join(locations)","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/skills.py#L828-L864","documentation":"A custom `system_prompt` for SkillsMiddleware must contain the three format slots {skills_locations}, {skills_load_warnings}, and {skills_list}, because the middleware interpolates discovered skill paths, load warnings, and the skill listing into the prompt at runtime. A prompt missing any slot would silently drop that information, so it's rejected with ValueError listing the missing slots.","triggerScenarios":"SkillsMiddleware(backend=..., system_prompt=\"You have skills available.\") — no slots; a partially customized prompt containing only {skills_list}.","commonSituations":"Trimming the default prompt for brevity and cutting slots; rewriting the prompt from scratch; copying a prompt from an older version whose slot names changed.","solutions":["Add all three slots: {skills_locations}, {skills_load_warnings}, {skills_list}.","Start from the library's default prompt and edit around it rather than rewriting.","Read the ValueError message — it names exactly which slot(s) are missing.","If you don't need customization, pass system_prompt=None to use the default."],"exampleFix":"// before\nsystem_prompt=\"You can load skills.\"\n// after\nsystem_prompt=\"You can load skills.\\nLocations: {skills_locations}\\nWarnings: {skills_load_warnings}\\n{skills_list}\"","handlingStrategy":"validation","validationCode":"REQUIRED = (\"{skills_locations}\", \"{skills_load_warnings}\", \"{skills_list}\")\nmissing = [s for s in REQUIRED if s not in system_prompt]\nif missing:\n    raise ValueError(f\"system_prompt missing: {missing}\")","typeGuard":"def prompt_has_slots(p: str) -> bool:\n    return all(slot in p for slot in (\"{skills_locations}\", \"{skills_load_warnings}\", \"{skills_list}\"))","tryCatchPattern":"try:\n    mw = SkillsMiddleware(backend=b, system_prompt=custom_prompt)\nexcept ValueError as e:\n    if \"missing required format slot\" in str(e):\n        mw = SkillsMiddleware(backend=b)  # fall back to default prompt\n    else:\n        raise","preventionTips":["Start from the library default prompt and edit incrementally.","Keep a module-level prompt constant containing all three slots; test it with prompt_has_slots.","Read the ValueError — it lists exactly which slots are missing.","Pass None if you don't need prompt customization."],"tags":["python","skills","validation","value-error"],"backgroundTag":"missing-template-slot","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}