{"record":{"id":"4ebba53584a473ef","repo":"langchain-ai/langchain","slug":"dict-pydantic-schema-unsupported-with-args-only","errorCode":null,"errorMessage":"Dict Pydantic schema unsupported with args_only: {self.pydantic_schema}","messagePattern":"Dict Pydantic schema unsupported with args_only: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/output_parsers/openai_functions.py","lineNumber":278,"sourceCode":"        Args:\n            result: The result of the LLM call.\n            partial: Whether to parse partial JSON objects.\n\n        Raises:\n            ValueError: If the Pydantic schema is not valid.\n\n        Returns:\n            The parsed JSON object.\n        \"\"\"\n        result_ = super().parse_result(result)\n        pydantic_args: PydanticBaseModel\n        if self.args_only:\n            if isinstance(self.pydantic_schema, dict):\n                msg = (\n                    \"Dict Pydantic schema unsupported with args_only: \"\n                    f\"{self.pydantic_schema}\"\n                )\n                raise ValueError(msg)\n            if issubclass(self.pydantic_schema, BaseModel):\n                pydantic_args = self.pydantic_schema.model_validate_json(result_)\n            elif issubclass(self.pydantic_schema, BaseModelV1):\n                pydantic_args = self.pydantic_schema.parse_raw(result_)\n            else:\n                msg = (  # type: ignore[unreachable]\n                    \"Unsupported Pydantic schema with args_only: \"\n                    f\"{self.pydantic_schema}\"\n                )\n                raise ValueError(msg)\n        else:\n            fn_name = result_[\"name\"]\n            args = result_[\"arguments\"]\n            if isinstance(self.pydantic_schema, dict):\n                pydantic_schema = self.pydantic_schema[fn_name]\n            else:\n                pydantic_schema = self.pydantic_schema\n            if issubclass(pydantic_schema, BaseModel):","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/output_parsers/openai_functions.py#L260-L296","documentation":"Runtime error in PydanticOutputFunctionsParser.parse_result with args_only=True when pydantic_schema is a dict. This state is normally blocked by the init-time validator (error 185), so seeing it at parse time means the validator was bypassed — e.g. the field was mutated after construction (parser.pydantic_schema = {...}) or object was created via model_construct / deserialization that skips validation.","triggerScenarios":"Assigning a dict to parser.pydantic_schema after construction while args_only stays True; building the parser with Pydantic model_construct or deserializing state that skips field validators.","commonSituations":"Dynamically swapping schemas at runtime on an existing parser instance; loading parser configs from serialized state without revalidation.","solutions":["Set args_only=False whenever the schema is (or becomes) a dict of multiple schemas","Recreate the parser instance instead of mutating pydantic_schema in place","Revalidate configuration after deserialization (e.g. call model_validate on the reconstructed parser)"],"exampleFix":"# before\nparser = PydanticOutputFunctionsParser(pydantic_schema=Person, args_only=True)\nparser.pydantic_schema = {\"a\": A, \"b\": B}  # mutation skips validator\n\n# after\nparser = PydanticOutputFunctionsParser(pydantic_schema={\"a\": A, \"b\": B}, args_only=False)","handlingStrategy":"validation","validationCode":"if parser.args_only and isinstance(parser.pydantic_schema, dict):\n    raise ValueError(\"reconfigure parser with args_only=False\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mutate pydantic_schema after construction; build a new parser","Re-run model validation when restoring parsers from serialized state"],"tags":["openai-functions","pydantic","mutation","validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}