Skip to content

@ai-sdk/langchain: Citation Annotations Were Being Silently Dropped

Vercel's AI SDK LangChain adapter v2.0.215 fixes a bug where citation metadata from RAG and web search was silently discarded instead of surfaced as UI message parts.

If you’re piping LangChain RAG or web search results through Vercel’s AI SDK, your citations were vanishing. Version 2.0.215 fixes that.

The patch (dff49ee) changes how the LangChain adapter handles citation annotations attached to text content blocks. Before this release, those annotations were dropped entirely — no error, no warning. Now they’re emitted as spec-compliant source-url and source-document UI message parts.

What’s preserved under providerMetadata.langchain:

  • citedText — the exact snippet the model referenced
  • startIndex / endIndex — character offsets pinpointing the citation span
  • source — the original URL or document reference

This matters for anyone building retrieval-augmented chat interfaces. Without citation passthrough, your UI had no way to show users where an answer came from. You’d get the generated text but lose the audit trail — a problem if you’re building anything where source attribution is a requirement, not a nice-to-have.

The fix aligns the LangChain adapter with how the core AI SDK already handles source parts from other providers. If you were working around the bug by manually extracting citations from LangChain’s raw output, you can likely drop that code.

NOTE

This is a patch release, not a minor bump. No breaking changes — existing providerMetadata consumers won’t need updates. The new fields appear in addition to whatever you were already reading.

Upgrade path is npm i @ai-sdk/langchain@2.0.215. If you’re using RAG or web search chains through the adapter, check your UI rendering — you’ll now receive citation parts you weren’t getting before, and your message rendering logic may need to handle them.