langchain - 💡(How to fix) Fix `langchain_core.exceptions.OutputParserException` [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#36603Fetched 2026-04-09 07:51:01
View on GitHub
Comments
3
Participants
2
Timeline
10
Reactions
1
Author
Participants
Timeline (top)
labeled ×5commented ×3issue_type_added ×1renamed ×1

Trying to use a larger Ollama model, gpt-oss:120b-cloud and it hits the pydantic parser exception that happens in langchain_core. Langsmith trace: https://smith.langchain.com/public/01750368-ab65-4d63-a6e0-f704562537af/r

Error Message

Traceback (most recent call last): File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 28, in _parse_obj return self.pydantic_object.model_validate(obj) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/pydantic/main.py", line 716, in model_validate return cls.pydantic_validator.validate_python( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ obj, ^^^^ ...<5 lines>... by_name=by_name, ^^^^^^^^^^^^^^^^ ) ^ pydantic_core._pydantic_core.ValidationError: 1 validation error for EmailModel required_changes Input should be a valid string [type=string_type, input_value=['Replace or properly sec... structural stability.'], input_type=list] For further information visit https://errors.pydantic.dev/2.12/v/string_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 329, in <module> asyncio.run(main()) ~~~~~~~~~~~^^^^^^^^ File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run return runner.run(main) ~~~~~~~~~~^^^^^^ File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete return future.result() ~~~~~~~~~~~~~^^ File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 322, in main result = await rag.Chat("There's an immediate risk of electrical, water, or fire damage", email_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 290, in Chat async for step in self._agent.with_config(config).astream( ...<5 lines>... step["messages"][-1].pretty_print() File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3128, in astream async for _ in runner.atick( ...<16 lines>... yield o File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_runner.py", line 304, in atick await arun_with_retry( ...<15 lines>... ) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_retry.py", line 242, in arun_with_retry return await task.proc.ainvoke(task.input, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 705, in ainvoke input = await asyncio.create_task( ^^^^^^^^^^^^^^^^^^^^^^^^^^ step.ainvoke(input, config, **kwargs), context=context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 473, in ainvoke ret = await self.afunc(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 853, in _afunc outputs = await asyncio.gather(*coros) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1207, in _arun_one content = _handle_tool_error(e, flag=self._handle_tool_errors) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 432, in _handle_tool_error content = flag(e) # type: ignore [assignment, call-arg] File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 389, in _default_handle_tool_errors raise e File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1198, in _arun_one return await self._awrap_tool_call(tool_request, execute) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/deepagents/middleware/filesystem.py", line 1376, in awrap_tool_call tool_result = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1189, in execute return await self._execute_tool_async(req, input_type, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1133, in _execute_tool_async content = _handle_tool_error(e, flag=self._handle_tool_errors) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 432, in _handle_tool_error content = flag(e) # type: ignore [assignment, call-arg] File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 389, in _default_handle_tool_errors raise e File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1090, in _execute_tool_async response = await tool.ainvoke(call_args, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/structured.py", line 70, in ainvoke return await super().ainvoke(input, config, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 652, in ainvoke return await self.arun(tool_input, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 1131, in arun raise error_to_raise File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 1097, in arun response = await coro_with_context(coro, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/structured.py", line 124, in _arun return await self.coroutine(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/deepagents/middleware/subagents.py", line 463, in atask result = await subagent.ainvoke(subagent_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3479, in ainvoke async for chunk in self.astream( ...<29 lines>... chunks.append(chunk) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3128, in astream async for _ in runner.atick( ...<16 lines>... yield o File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_runner.py", line 304, in atick await arun_with_retry( ...<15 lines>... ) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_retry.py", line 242, in arun_with_retry return await task.proc.ainvoke(task.input, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 705, in ainvoke input = await asyncio.create_task( ^^^^^^^^^^^^^^^^^^^^^^^^^^ step.ainvoke(input, config, **kwargs), context=context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 473, in ainvoke ret = await self.afunc(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 169, in ParseEmail state["extract"] = await self.email_parser_chain.with_config(config).ainvoke({"email": state["email"]}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5708, in ainvoke return await self.bound.ainvoke( ^^^^^^^^^^^^^^^^^^^^^^^^^ ...<3 lines>... ) ^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3197, in ainvoke input = await coro_with_context(part(), context, create_task=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/base.py", line 230, in ainvoke return await self._acall_with_config( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<6 lines>... ) ^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2111, in _acall_with_config output: Output = await coro_with_context(coro, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/base.py", line 297, in aparse_result return await run_in_executor(None, self.parse_result, result, partial=partial) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 636, in run_in_executor return await asyncio.get_running_loop().run_in_executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<2 lines>... ) ^ File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 627, in wrapper return func(*args, **kwargs) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 76, in parse_result return self._parse_obj(json_object) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 35, in _parse_obj raise self._parser_exception(e, obj) from e langchain_core.exceptions.OutputParserException: Failed to parse EmailModel from completion {"date": "03-04-2026", "from_name": "City of Los Angeles Building and Safety Department", "from_email": "[email protected]", "project_id": "345678123", "phone_number": "(555) 456-7890", "site_location": "Los Angeles, CA", "violation_types": ["Electrical Wiring", "Fire Safety", "Structural Integrity"], "required_changes": ["Replace or properly secure exposed wiring to meet electrical safety standards.", "Install additional fire extinguishers in compliance with fire code requirements.", "Reinforce or replace temporary support beams to ensure structural stability."], "compliance_deadline": "December 31"}. Got: 1 validation error for EmailModel required_changes Input should be a valid string [type=string_type, input_value=['Replace or properly sec... structural stability.'], input_type=list] For further information visit https://errors.pydantic.dev/2.12/v/string_type For troubleshooting, visit: https://docs.langchain.com/oss/python/langchain/errors/OUTPUT_PARSING_FAILURE

Root Cause

Trying to use a larger Ollama model, gpt-oss:120b-cloud and it hits the pydantic parser exception that happens in langchain_core. Langsmith trace: https://smith.langchain.com/public/01750368-ab65-4d63-a6e0-f704562537af/r

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

aiohttp: 3.13.5 anthropic: 0.89.0 asyncpg: 0.31.0 blockbuster: 1.5.26 click: 8.3.2 cloudpickle: 3.1.2 croniter: 6.2.2 cryptography: 46.0.6 dataclasses-json: 0.6.7 filetype: 1.2.0 google-genai: 1.70.0 grpcio: 1.80.0 grpcio-health-checking: 1.80.0 grpcio-tools: 1.75.1 httpx: 0.28.1 httpx-sse: 0.4.3 jsonpatch: 1.33 jsonschema-rs: 0.29.1 langgraph: 1.1.6 langgraph-checkpoint: 4.0.1 neo4j: 6.1.0 neo4j-graphrag: 1.14.1 numpy: 2.4.4 ollama: 0.6.1 openai: 2.30.0 opentelemetry-api: 1.40.0 opentelemetry-exporter-otlp-proto-http: 1.40.0 opentelemetry-sdk: 1.40.0 orjson: 3.11.8 packaging: 26.0 pgvector: 0.3.6 protobuf: 6.33.6 psycopg: 3.3.3 psycopg-pool: 3.3.0 pydantic: 2.12.5 pydantic-settings: 2.13.1 pyjwt: 2.12.1 pytest: 9.0.2 python-dotenv: 1.2.2 pyyaml: 6.0.3 PyYAML: 6.0.3 requests: 2.33.1 requests-toolbelt: 1.0.0 sqlalchemy: 2.0.49 SQLAlchemy: 2.0.49 sse-starlette: 2.1.3 starlette: 1.0.0 structlog: 25.5.0 tenacity: 9.1.4 tiktoken: 0.12.0 truststore: 0.10.4 typing-extensions: 4.15.0 uuid-utils: 0.14.1 uvicorn: 0.43.0 watchfiles: 1.1.1 wcmatch: 10.1 websockets: 16.0 xxhash: 3.6.0 zstandard: 0.25.0

Code Example

Traceback (most recent call last):
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 28, in _parse_obj
    return self.pydantic_object.model_validate(obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/pydantic/main.py", line 716, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        obj,
        ^^^^
    ...<5 lines>...
        by_name=by_name,
        ^^^^^^^^^^^^^^^^
    )
    ^
pydantic_core._pydantic_core.ValidationError: 1 validation error for EmailModel
required_changes
  Input should be a valid string [type=string_type, input_value=['Replace or properly sec... structural stability.'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 329, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 322, in main
    result = await rag.Chat("There's an immediate risk of electrical, water, or fire damage", email_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 290, in Chat
    async for step in self._agent.with_config(config).astream(
    ...<5 lines>...
        step["messages"][-1].pretty_print()
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3128, in astream
    async for _ in runner.atick(
    ...<16 lines>...
            yield o
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_runner.py", line 304, in atick
    await arun_with_retry(
    ...<15 lines>...
    )
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_retry.py", line 242, in arun_with_retry
    return await task.proc.ainvoke(task.input, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 705, in ainvoke
    input = await asyncio.create_task(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        step.ainvoke(input, config, **kwargs), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 473, in ainvoke
    ret = await self.afunc(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 853, in _afunc
    outputs = await asyncio.gather(*coros)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1207, in _arun_one
    content = _handle_tool_error(e, flag=self._handle_tool_errors)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 432, in _handle_tool_error
    content = flag(e)  # type: ignore [assignment, call-arg]
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 389, in _default_handle_tool_errors
    raise e
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1198, in _arun_one
    return await self._awrap_tool_call(tool_request, execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/deepagents/middleware/filesystem.py", line 1376, in awrap_tool_call
    tool_result = await handler(request)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1189, in execute
    return await self._execute_tool_async(req, input_type, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1133, in _execute_tool_async
    content = _handle_tool_error(e, flag=self._handle_tool_errors)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 432, in _handle_tool_error
    content = flag(e)  # type: ignore [assignment, call-arg]
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 389, in _default_handle_tool_errors
    raise e
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1090, in _execute_tool_async
    response = await tool.ainvoke(call_args, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/structured.py", line 70, in ainvoke
    return await super().ainvoke(input, config, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 652, in ainvoke
    return await self.arun(tool_input, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 1131, in arun
    raise error_to_raise
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 1097, in arun
    response = await coro_with_context(coro, context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/structured.py", line 124, in _arun
    return await self.coroutine(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/deepagents/middleware/subagents.py", line 463, in atask
    result = await subagent.ainvoke(subagent_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3479, in ainvoke
    async for chunk in self.astream(
    ...<29 lines>...
            chunks.append(chunk)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3128, in astream
    async for _ in runner.atick(
    ...<16 lines>...
            yield o
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_runner.py", line 304, in atick
    await arun_with_retry(
    ...<15 lines>...
    )
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_retry.py", line 242, in arun_with_retry
    return await task.proc.ainvoke(task.input, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 705, in ainvoke
    input = await asyncio.create_task(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        step.ainvoke(input, config, **kwargs), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 473, in ainvoke
    ret = await self.afunc(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 169, in ParseEmail
    state["extract"] = await self._email_parser_chain.with_config(config).ainvoke({"email": state["email"]})
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5708, in ainvoke
    return await self.bound.ainvoke(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3197, in ainvoke
    input_ = await coro_with_context(part(), context, create_task=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/base.py", line 230, in ainvoke
    return await self._acall_with_config(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<6 lines>...
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2111, in _acall_with_config
    output: Output = await coro_with_context(coro, context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/base.py", line 297, in aparse_result
    return await run_in_executor(None, self.parse_result, result, partial=partial)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 636, in run_in_executor
    return await asyncio.get_running_loop().run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
    )
    ^
  File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 627, in wrapper
    return func(*args, **kwargs)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 76, in parse_result
    return self._parse_obj(json_object)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 35, in _parse_obj
    raise self._parser_exception(e, obj) from e
langchain_core.exceptions.OutputParserException: Failed to parse EmailModel from completion {"date": "03-04-2026", "from_name": "City of Los Angeles Building and Safety Department", "from_email": "[email protected]", "project_id": "345678123", "phone_number": "(555) 456-7890", "site_location": "Los Angeles, CA", "violation_types": ["Electrical Wiring", "Fire Safety", "Structural Integrity"], "required_changes": ["Replace or properly secure exposed wiring to meet electrical safety standards.", "Install additional fire extinguishers in compliance with fire code requirements.", "Reinforce or replace temporary support beams to ensure structural stability."], "compliance_deadline": "December 31"}. Got: 1 validation error for EmailModel
required_changes
  Input should be a valid string [type=string_type, input_value=['Replace or properly sec... structural stability.'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
For troubleshooting, visit: https://docs.langchain.com/oss/python/langchain/errors/OUTPUT_PARSING_FAILURE

---

System Information
------------------
> OS:  Linux
> OS Version:  #20-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 20:07:29 UTC 2026
> Python Version:  3.13.7 (main, Mar  3 2026, 12:19:54) [GCC 15.2.0]

Package Information
-------------------
> langchain_core: 1.2.26
> langchain: 1.2.15
> langchain_community: 0.4.1
> langsmith: 0.7.25
> deepagents: 0.4.12
> langchain_anthropic: 1.4.0
> langchain_classic: 1.0.3
> langchain_google_genai: 4.2.1
> langchain_neo4j: 0.9.0
> langchain_ollama: 1.0.1
> langchain_openai: 1.1.12
> langchain_postgres: 0.0.17
> langchain_text_splitters: 1.1.1
> langgraph_api: 0.7.27
> langgraph_cli: 0.4.19
> langgraph_runtime_inmem: 0.24.1
> langgraph_sdk: 0.3.12

Optional packages not installed
-------------------------------
> deepagents-cli

Other Dependencies
------------------
> aiohttp: 3.13.5
> anthropic: 0.89.0
> asyncpg: 0.31.0
> blockbuster: 1.5.26
> click: 8.3.2
> cloudpickle: 3.1.2
> croniter: 6.2.2
> cryptography: 46.0.6
> dataclasses-json: 0.6.7
> filetype: 1.2.0
> google-genai: 1.70.0
> grpcio: 1.80.0
> grpcio-health-checking: 1.80.0
> grpcio-tools: 1.75.1
> httpx: 0.28.1
> httpx-sse: 0.4.3
> jsonpatch: 1.33
> jsonschema-rs: 0.29.1
> langgraph: 1.1.6
> langgraph-checkpoint: 4.0.1
> neo4j: 6.1.0
> neo4j-graphrag: 1.14.1
> numpy: 2.4.4
> ollama: 0.6.1
> openai: 2.30.0
> opentelemetry-api: 1.40.0
> opentelemetry-exporter-otlp-proto-http: 1.40.0
> opentelemetry-sdk: 1.40.0
> orjson: 3.11.8
> packaging: 26.0
> pgvector: 0.3.6
> protobuf: 6.33.6
> psycopg: 3.3.3
> psycopg-pool: 3.3.0
> pydantic: 2.12.5
> pydantic-settings: 2.13.1
> pyjwt: 2.12.1
> pytest: 9.0.2
> python-dotenv: 1.2.2
> pyyaml: 6.0.3
> PyYAML: 6.0.3
> requests: 2.33.1
> requests-toolbelt: 1.0.0
> sqlalchemy: 2.0.49
> SQLAlchemy: 2.0.49
> sse-starlette: 2.1.3
> starlette: 1.0.0
> structlog: 25.5.0
> tenacity: 9.1.4
> tiktoken: 0.12.0
> truststore: 0.10.4
> typing-extensions: 4.15.0
> uuid-utils: 0.14.1
> uvicorn: 0.43.0
> watchfiles: 1.1.1
> wcmatch: 10.1
> websockets: 16.0
> xxhash: 3.6.0
> zstandard: 0.25.0
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

https://github.com/khteh/rag-agent/blob/master/src/rag_agent/EmailRAG.py

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 28, in _parse_obj
    return self.pydantic_object.model_validate(obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/pydantic/main.py", line 716, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        obj,
        ^^^^
    ...<5 lines>...
        by_name=by_name,
        ^^^^^^^^^^^^^^^^
    )
    ^
pydantic_core._pydantic_core.ValidationError: 1 validation error for EmailModel
required_changes
  Input should be a valid string [type=string_type, input_value=['Replace or properly sec... structural stability.'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 329, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 322, in main
    result = await rag.Chat("There's an immediate risk of electrical, water, or fire damage", email_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 290, in Chat
    async for step in self._agent.with_config(config).astream(
    ...<5 lines>...
        step["messages"][-1].pretty_print()
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3128, in astream
    async for _ in runner.atick(
    ...<16 lines>...
            yield o
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_runner.py", line 304, in atick
    await arun_with_retry(
    ...<15 lines>...
    )
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_retry.py", line 242, in arun_with_retry
    return await task.proc.ainvoke(task.input, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 705, in ainvoke
    input = await asyncio.create_task(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        step.ainvoke(input, config, **kwargs), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 473, in ainvoke
    ret = await self.afunc(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 853, in _afunc
    outputs = await asyncio.gather(*coros)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1207, in _arun_one
    content = _handle_tool_error(e, flag=self._handle_tool_errors)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 432, in _handle_tool_error
    content = flag(e)  # type: ignore [assignment, call-arg]
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 389, in _default_handle_tool_errors
    raise e
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1198, in _arun_one
    return await self._awrap_tool_call(tool_request, execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/deepagents/middleware/filesystem.py", line 1376, in awrap_tool_call
    tool_result = await handler(request)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1189, in execute
    return await self._execute_tool_async(req, input_type, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1133, in _execute_tool_async
    content = _handle_tool_error(e, flag=self._handle_tool_errors)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 432, in _handle_tool_error
    content = flag(e)  # type: ignore [assignment, call-arg]
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 389, in _default_handle_tool_errors
    raise e
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/prebuilt/tool_node.py", line 1090, in _execute_tool_async
    response = await tool.ainvoke(call_args, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/structured.py", line 70, in ainvoke
    return await super().ainvoke(input, config, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 652, in ainvoke
    return await self.arun(tool_input, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 1131, in arun
    raise error_to_raise
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/base.py", line 1097, in arun
    response = await coro_with_context(coro, context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/tools/structured.py", line 124, in _arun
    return await self.coroutine(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/deepagents/middleware/subagents.py", line 463, in atask
    result = await subagent.ainvoke(subagent_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3479, in ainvoke
    async for chunk in self.astream(
    ...<29 lines>...
            chunks.append(chunk)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/main.py", line 3128, in astream
    async for _ in runner.atick(
    ...<16 lines>...
            yield o
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_runner.py", line 304, in atick
    await arun_with_retry(
    ...<15 lines>...
    )
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/pregel/_retry.py", line 242, in arun_with_retry
    return await task.proc.ainvoke(task.input, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 705, in ainvoke
    input = await asyncio.create_task(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        step.ainvoke(input, config, **kwargs), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/_internal/_runnable.py", line 473, in ainvoke
    ret = await self.afunc(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/src/rag_agent/EmailRAG.py", line 169, in ParseEmail
    state["extract"] = await self._email_parser_chain.with_config(config).ainvoke({"email": state["email"]})
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5708, in ainvoke
    return await self.bound.ainvoke(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3197, in ainvoke
    input_ = await coro_with_context(part(), context, create_task=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/base.py", line 230, in ainvoke
    return await self._acall_with_config(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<6 lines>...
    )
    ^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2111, in _acall_with_config
    output: Output = await coro_with_context(coro, context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/base.py", line 297, in aparse_result
    return await run_in_executor(None, self.parse_result, result, partial=partial)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 636, in run_in_executor
    return await asyncio.get_running_loop().run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
    )
    ^
  File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 627, in wrapper
    return func(*args, **kwargs)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 76, in parse_result
    return self._parse_obj(json_object)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langchain_core/output_parsers/pydantic.py", line 35, in _parse_obj
    raise self._parser_exception(e, obj) from e
langchain_core.exceptions.OutputParserException: Failed to parse EmailModel from completion {"date": "03-04-2026", "from_name": "City of Los Angeles Building and Safety Department", "from_email": "[email protected]", "project_id": "345678123", "phone_number": "(555) 456-7890", "site_location": "Los Angeles, CA", "violation_types": ["Electrical Wiring", "Fire Safety", "Structural Integrity"], "required_changes": ["Replace or properly secure exposed wiring to meet electrical safety standards.", "Install additional fire extinguishers in compliance with fire code requirements.", "Reinforce or replace temporary support beams to ensure structural stability."], "compliance_deadline": "December 31"}. Got: 1 validation error for EmailModel
required_changes
  Input should be a valid string [type=string_type, input_value=['Replace or properly sec... structural stability.'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
For troubleshooting, visit: https://docs.langchain.com/oss/python/langchain/errors/OUTPUT_PARSING_FAILURE

Description

Trying to use a larger Ollama model, gpt-oss:120b-cloud and it hits the pydantic parser exception that happens in langchain_core. Langsmith trace: https://smith.langchain.com/public/01750368-ab65-4d63-a6e0-f704562537af/r

System Info

System Information
------------------
> OS:  Linux
> OS Version:  #20-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 20:07:29 UTC 2026
> Python Version:  3.13.7 (main, Mar  3 2026, 12:19:54) [GCC 15.2.0]

Package Information
-------------------
> langchain_core: 1.2.26
> langchain: 1.2.15
> langchain_community: 0.4.1
> langsmith: 0.7.25
> deepagents: 0.4.12
> langchain_anthropic: 1.4.0
> langchain_classic: 1.0.3
> langchain_google_genai: 4.2.1
> langchain_neo4j: 0.9.0
> langchain_ollama: 1.0.1
> langchain_openai: 1.1.12
> langchain_postgres: 0.0.17
> langchain_text_splitters: 1.1.1
> langgraph_api: 0.7.27
> langgraph_cli: 0.4.19
> langgraph_runtime_inmem: 0.24.1
> langgraph_sdk: 0.3.12

Optional packages not installed
-------------------------------
> deepagents-cli

Other Dependencies
------------------
> aiohttp: 3.13.5
> anthropic: 0.89.0
> asyncpg: 0.31.0
> blockbuster: 1.5.26
> click: 8.3.2
> cloudpickle: 3.1.2
> croniter: 6.2.2
> cryptography: 46.0.6
> dataclasses-json: 0.6.7
> filetype: 1.2.0
> google-genai: 1.70.0
> grpcio: 1.80.0
> grpcio-health-checking: 1.80.0
> grpcio-tools: 1.75.1
> httpx: 0.28.1
> httpx-sse: 0.4.3
> jsonpatch: 1.33
> jsonschema-rs: 0.29.1
> langgraph: 1.1.6
> langgraph-checkpoint: 4.0.1
> neo4j: 6.1.0
> neo4j-graphrag: 1.14.1
> numpy: 2.4.4
> ollama: 0.6.1
> openai: 2.30.0
> opentelemetry-api: 1.40.0
> opentelemetry-exporter-otlp-proto-http: 1.40.0
> opentelemetry-sdk: 1.40.0
> orjson: 3.11.8
> packaging: 26.0
> pgvector: 0.3.6
> protobuf: 6.33.6
> psycopg: 3.3.3
> psycopg-pool: 3.3.0
> pydantic: 2.12.5
> pydantic-settings: 2.13.1
> pyjwt: 2.12.1
> pytest: 9.0.2
> python-dotenv: 1.2.2
> pyyaml: 6.0.3
> PyYAML: 6.0.3
> requests: 2.33.1
> requests-toolbelt: 1.0.0
> sqlalchemy: 2.0.49
> SQLAlchemy: 2.0.49
> sse-starlette: 2.1.3
> starlette: 1.0.0
> structlog: 25.5.0
> tenacity: 9.1.4
> tiktoken: 0.12.0
> truststore: 0.10.4
> typing-extensions: 4.15.0
> uuid-utils: 0.14.1
> uvicorn: 0.43.0
> watchfiles: 1.1.1
> wcmatch: 10.1
> websockets: 16.0
> xxhash: 3.6.0
> zstandard: 0.25.0

extent analysis

TL;DR

The issue is likely due to a validation error in the EmailModel where the required_changes field expects a string but is receiving a list, and a workaround would be to modify the EmailModel to accept a list for required_changes.

Guidance

  • Check the EmailModel definition in langchain_core to see if the required_changes field is defined as a string, and consider modifying it to accept a list.
  • Verify that the input data being passed to the EmailModel is correct and that the required_changes field is indeed a list.
  • If modifying the EmailModel is not feasible, consider converting the required_changes list to a string before passing it to the model.
  • Review the LangChain documentation and Pydantic documentation to understand how to handle validation errors and define models with list fields.

Example

from pydantic import BaseModel

class EmailModel(BaseModel):
    required_changes: list[str]  # Define required_changes as a list of strings

Notes

  • The issue seems to be related to a mismatch between the expected input type and the actual input type for the required_changes field in the EmailModel.
  • Modifying the EmailModel to accept a list for required_changes may require changes to other parts of the code that rely on this model.

Recommendation

Apply workaround: Modify the EmailModel to accept a list for required_changes, or convert the required_changes list to a string before passing it to the model, as this will allow the code to handle the input data correctly and avoid the validation error.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING