{"record":{"id":"b4d55107da0573bd","repo":"langchain-ai/langchain","slug":"if-multiple-pydantic-schemas-are-provided-then-arg","errorCode":null,"errorMessage":"If multiple pydantic schemas are provided then args_only should be False.","messagePattern":"If multiple pydantic schemas are provided then args_only should be False\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/output_parsers/openai_functions.py","lineNumber":253,"sourceCode":"            values: The values to validate.\n\n        Returns:\n            The validated values.\n\n        Raises:\n            ValueError: If the schema is not a Pydantic schema.\n        \"\"\"\n        schema = values[\"pydantic_schema\"]\n        if \"args_only\" not in values:\n            values[\"args_only\"] = isinstance(schema, type) and issubclass(\n                schema, BaseModel\n            )\n        elif values[\"args_only\"] and isinstance(schema, dict):\n            msg = (\n                \"If multiple pydantic schemas are provided then args_only should be\"\n                \" False.\"\n            )\n            raise ValueError(msg)\n        return values\n\n    @override\n    def parse_result(self, result: list[Generation], *, partial: bool = False) -> Any:\n        \"\"\"Parse the result of an LLM call to a JSON object.\n\n        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","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/output_parsers/openai_functions.py#L235-L271","documentation":"Validation error from PydanticOutputFunctionsParser's field validator: you passed a dict of multiple named Pydantic schemas (function-name -> model mapping) together with args_only=True. With multiple schemas the parser must return the function name plus arguments, so returning arguments alone is ambiguous and rejected at init time.","triggerScenarios":"Constructing PydanticOutputFunctionsParser(pydantic_schema={'fn_a': ModelA, 'fn_b': ModelB}, args_only=True) — the args_only=True combined with a dict schema trips the validator.","commonSituations":"Copy-pasting args_only=True from a single-schema example while switching to a multi-schema dict; assuming args_only applies per-function after a refactor.","solutions":["Set args_only=False (or omit it — it is auto-derived from the schema type) when passing a dict of schemas","If you truly want arguments only, use a single Pydantic schema, not a dict of them"],"exampleFix":"# before\nparser = PydanticOutputFunctionsParser(\n    pydantic_schema={\"create_person\": Person, \"create_book\": Book},\n    args_only=True,\n)\n\n# after\nparser = PydanticOutputFunctionsParser(\n    pydantic_schema={\"create_person\": Person, \"create_book\": Book},\n    args_only=False,\n)","handlingStrategy":"validation","validationCode":"if isinstance(pydantic_schema, dict):\n    assert not args_only, \"multi-schema dicts require args_only=False\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let args_only auto-derive: omit it when constructing with a dict schema","Add a startup smoke test that constructs all configured parsers"],"tags":["openai-functions","pydantic","configuration","validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}