kmail.at
← learning

langchain · difficulty ◆◆

XMLOutputParser and PydanticOutputParser Fixes in langchain-core 1.4.9

Structured output that fails loudly and clearly

Structured output was failing with cryptic errors you could not debug.

2026-07-09 · 7 min read

$ pip install -U langchain-core>=1.4.9

What it does

langchain-core 1.4.9 patches two output-parser bugs. XMLOutputParser mishandled continuation lines with colons inside tags, rejecting valid XML. PydanticOutputParser fixed how field validation errors propagate, so ValidationError messages surface clearly when a model’s fields cannot be populated from the LLM text.

Why it matters

These parsers back LangChain’s structured output pipeline: every with_structured_output(PydanticModel) or XML-formatted chain uses one. Bugs here silently corrupt data or crash pipelines at scale. The Pydantic fix alone turns cryptic internal errors into field-level detail.

Example

$ Parse a movie review into a Pydantic model, then parse planets as XML.
=== PydanticOutputParser Result ===
Title:  Inception
Rating: 8.5/10
Pros:   ['visually stunning', 'original story']
Cons:   ['complex', 'slow at times']

=== XMLOutputParser Result ===
<Entities>
  <Entity name="Mercury" type="planet" distance="0.39 AU"/>
  <Entity name="Venus" type="planet" distance="0.72 AU"/>
  ...
</Entities>

With an invalid response you now get a clear ValidationError naming the offending field.

Common flags

PydanticOutputParser
Parses LLM text into a Pydantic v2 model with full validation
XMLOutputParser
Parses LLM text as XML using a configurable schema
JsonOutputParser
Parses LLM text as JSON into a Pydantic or dataclass model
RetryOutputParser
Wraps any parser and retries on parse failure
with_structured_output(Model)
Wires format instructions and a parser automatically

History

Origin

Two long-standing edge cases: colons inside XML continuation lines, and bare ValueErrors without context in the Pydantic path.

The fix

1.4.9 corrected the XML tag parsing and replaced opaque errors with context-rich validation messages.

Fun facts

Pros & cons

pros

  • + Clear ValidationError messages
  • + Fixed XML edge case
  • + Covers the most popular structured-output path

cons

  • − Low-level fixes, no new features
  • − Requires a core upgrade

Takeaways

  1. 1Upgrade langchain-core to 1.4.9
  2. 2Expect field-level validation errors
  3. 3Re-test XML values containing colons

Related commands

← all learning