Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(langgraph): preserve input metadata#1832

Merged
ranst91 merged 3 commits into
ag-ui-protocol:mainfrom
he-yufeng:fix/langgraph-preserve-input-metadata-1809-clean
Jun 5, 2026
Merged

fix(langgraph): preserve input metadata#1832
ranst91 merged 3 commits into
ag-ui-protocol:mainfrom
he-yufeng:fix/langgraph-preserve-input-metadata-1809-clean

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • preserve AG-UI InputContent.metadata when converting text and media blocks into LangChain multimodal content
  • keep the existing URL/drop behavior unchanged for unsupported media sources
  • add regression coverage for text and image metadata blocks

To verify

  • .\.venv\Scripts\python.exe -m pytest tests\test_multimodal.py -q from integrations/langgraph/python

@he-yufeng he-yufeng requested a review from a team as a code owner May 31, 2026 03:27
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Closed the older #1817 so this is now the single active branch for #1809.

Revalidated this branch locally:

uv run python -m unittest tests.test_multimodal
# Ran 31 tests: OK

uv run python -m py_compile ag_ui_langgraph\utils.py tests\test_multimodal.py
git diff --check origin/main...HEAD

The only remote red status is the Vercel team authorization gate, which is unrelated to this Python integration change.

@ranst91 ranst91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Clean, focused change. One thing:

BinaryInputContent branch is not covered. The legacy branch builds content_dict and appends it directly, so metadata is dropped there while text/media preserve it. BinaryInputContent has the same optional metadata field, so wrap its append in _attach_input_metadata too for consistency.

@he-yufeng he-yufeng force-pushed the fix/langgraph-preserve-input-metadata-1809-clean branch from 9737fbc to c636239 Compare June 2, 2026 18:17
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

@he-yufeng is attempting to deploy a commit to the CopilotKit Team on Vercel.

A member of the Team first needs to authorize it.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Updated, thanks. The legacy BinaryInputContent path now uses the same metadata attachment helper as text and typed media content, and the regression test covers that branch too.

Validated locally from integrations/langgraph/python:

.\.venv\Scripts\python.exe -m unittest tests.test_multimodal
.\.venv\Scripts\python.exe -m py_compile ag_ui_langgraph\utils.py tests\test_multimodal.py
git -C ..\..\.. diff --check

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Python Preview Packages

Version 0.0.0.dev1780424251 published to TestPyPI.

Warning: These packages are built from contributor code that may not yet have been vetted for correctness or security. Install at your own risk and do not use in production.

Install with uv

Add the TestPyPI index to your pyproject.toml:

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = true

Then install the packages you need:

# Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1780424251' --index testpypi

# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1780424251' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1780424251' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1780424251' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1780424251' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1780424251' --index testpypi

Install with pip

pip install \
  --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ \
  ag-ui-protocol==0.0.0.dev1780424251

Use --extra-index-url https://pypi.org/simple/ so pip can resolve
transitive dependencies (pydantic, fastapi, etc.) from real PyPI.


Commit: a4c8d06

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@ag-ui/a2a-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a-middleware@1832

@ag-ui/a2ui-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-middleware@1832

@ag-ui/event-throttle-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/event-throttle-middleware@1832

@ag-ui/mcp-apps-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-apps-middleware@1832

@ag-ui/mcp-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-middleware@1832

@ag-ui/middleware-starter

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/middleware-starter@1832

@ag-ui/a2a

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a@1832

@ag-ui/adk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/adk@1832

@ag-ui/ag2

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/ag2@1832

@ag-ui/agno

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/agno@1832

@ag-ui/aws-strands

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/aws-strands@1832

@ag-ui/claude-agent-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/claude-agent-sdk@1832

@ag-ui/crewai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/crewai@1832

@ag-ui/langchain

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langchain@1832

@ag-ui/langgraph

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langgraph@1832

@ag-ui/langroid

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langroid@1832

@ag-ui/llamaindex

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/llamaindex@1832

@ag-ui/mastra

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mastra@1832

@ag-ui/pydantic-ai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/pydantic-ai@1832

@ag-ui/server-starter

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/server-starter@1832

@ag-ui/server-starter-all-features

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/server-starter-all-features@1832

@ag-ui/vercel-ai-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/vercel-ai-sdk@1832

@ag-ui/watsonx

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/watsonx@1832

@ag-ui/a2ui-toolkit

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-toolkit@1832

create-ag-ui-app

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/create-ag-ui-app@1832

@ag-ui/client

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/client@1832

@ag-ui/core

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/core@1832

@ag-ui/encoder

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/encoder@1832

@ag-ui/proto

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/proto@1832

commit: c636239

@ranst91

ranst91 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution @he-yufeng! 🚢

@ranst91 ranst91 merged commit 425e08e into ag-ui-protocol:main Jun 5, 2026
1 of 2 checks passed
nadine-nguyen added a commit to gojasper/ag-ui that referenced this pull request Jun 22, 2026
…round-trip

The two multimodal converters in utils.ts were lossy: forward collapsed every
image/audio/video/document part to image_url and dropped InputContent.metadata,
and reverse re-emitted every image_url as type "image" with no metadata. An
attachment could not survive an AG-UI -> LangGraph -> AG-UI round-trip.

Forward now carries metadata (parity with merged Python ag-ui-protocol#1832) plus
the original media type stashed as __agui_type inside the metadata object, and
reverse restores both with a "image" fallback for untagged legacy blocks. The
extra key is inert for LangChain/model providers and survives the LangGraph
checkpoint JSON round-trip.

Closes ag-ui-protocol#2011.
nadine-nguyen added a commit to gojasper/ag-ui that referenced this pull request Jun 22, 2026
…round-trip

The two multimodal converters in utils.ts were lossy: forward collapsed every
image/audio/video/document part to image_url and dropped InputContent.metadata,
and reverse re-emitted every image_url as type "image" with no metadata. An
attachment could not survive an AG-UI -> LangGraph -> AG-UI round-trip.

Forward now carries metadata (parity with merged Python ag-ui-protocol#1832) plus
the original media type stashed as __agui_type inside the metadata object, and
reverse restores both with a "image" fallback for untagged legacy blocks. The
extra key is inert for LangChain/model providers and survives the LangGraph
checkpoint JSON round-trip.

Closes ag-ui-protocol#2011.
nadine-nguyen added a commit to gojasper/ag-ui that referenced this pull request Jun 22, 2026
…round-trip

The two multimodal converters in utils.ts were lossy: forward collapsed every
image/audio/video/document part to image_url and dropped InputContent.metadata,
and reverse re-emitted every image_url as type "image" with no metadata. An
attachment could not survive an AG-UI -> LangGraph -> AG-UI round-trip.

Forward now carries metadata (parity with merged Python ag-ui-protocol#1832) plus
the original media type stashed as __agui_type inside the metadata object, and
reverse restores both with a "image" fallback for untagged legacy blocks. The
extra key is inert for LangChain/model providers and survives the LangGraph
checkpoint JSON round-trip.

Closes ag-ui-protocol#2011.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants