{"record":{"id":"f53b55f1b24bde30","repo":"langchain-ai/langchain","slug":"partial-variables-are-not-supported-for-list-of-te","errorCode":null,"errorMessage":"Partial variables are not supported for list of templates.","messagePattern":"Partial variables are not supported for list of templates\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/prompts/chat.py","lineNumber":451,"sourceCode":"\n        Raises:\n            ValueError: If the template is not a string or list of strings.\n        \"\"\"\n        prompt: (\n            StringPromptTemplate\n            | list[StringPromptTemplate | ImagePromptTemplate | DictPromptTemplate]\n        )\n        if isinstance(template, str):\n            prompt = PromptTemplate.from_template(\n                template,\n                template_format=template_format,\n                partial_variables=partial_variables,\n            )\n            return cls(prompt=prompt, **kwargs)\n        if isinstance(template, Sequence):\n            if (partial_variables is not None) and len(partial_variables) > 0:\n                msg = \"Partial variables are not supported for list of templates.\"\n                raise ValueError(msg)\n            prompt = []\n            for tmpl in template:\n                if isinstance(tmpl, str) or (\n                    isinstance(tmpl, dict)\n                    and \"text\" in tmpl\n                    and set(tmpl.keys()) <= {\"type\", \"text\"}\n                ):\n                    if isinstance(tmpl, str):\n                        text: str = tmpl\n                    else:\n                        text = cast(\"_TextTemplateParam\", tmpl)[\"text\"]  # type: ignore[assignment]\n                    prompt.append(\n                        PromptTemplate.from_template(\n                            text, template_format=template_format\n                        )\n                    )\n                elif (\n                    isinstance(tmpl, dict)","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/prompts/chat.py#L433-L469","documentation":"In BaseChatPromptTemplate.from_template / ChatPromptTemplate.from_messages, when the template is a sequence of message templates (a list), passing non-empty partial_variables raises ValueError. Partials are only wired through the single-string branch (delegated to PromptTemplate.from_template); the list branch has no mechanism to distribute partials across heterogeneous message templates.","triggerScenarios":"Calling ChatPromptTemplate.from_messages([...], partial_variables={'lang': 'en'}) or from_template(list_of_templates, partial_variables={...}) with a non-empty dict and a non-None value.","commonSituations":"Developers trying to share a common partial (like a date or locale) across a multi-message prompt in one call, following the single-string API ergonomics.","solutions":["Drop partial_variables from the from_messages/from_template call and call .partial(**vars) on the resulting ChatPromptTemplate instead","Or bake the partial values directly into the message template strings"],"exampleFix":"# before\nChatPromptTemplate.from_messages(\n    [\"system: Answer in {lang}\", \"human: {q}\"],\n    partial_variables={\"lang\": \"English\"},  # ValueError\n)\n\n# after\n(ChatPromptTemplate.from_messages(\n    [\"system: Answer in {lang}\", \"human: {q}\"],\n).partial(lang=\"English\"))","handlingStrategy":"validation","validationCode":"def build_chat_prompt(messages, partials: dict | None = None):\n    if isinstance(messages, (list, tuple)) and partials:\n        return ChatPromptTemplate.from_messages(messages).partial(**partials)\n    return ChatPromptTemplate.from_messages(messages, partial_variables=partials)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use .partial() on the constructed ChatPromptTemplate instead of passing partial_variables to from_messages with lists"],"tags":["prompts","chat","partial-variables","core"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}