Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(langgraph): keep tool calls after text chunks#1829

Merged
ranst91 merged 5 commits into
ag-ui-protocol:mainag-ui-protocol/ag-ui:mainfrom
he-yufeng:fix/langgraph-text-tool-transition-1678he-yufeng/ag-ui:fix/langgraph-text-tool-transition-1678Copy head branch name to clipboard
Jun 5, 2026
Merged

fix(langgraph): keep tool calls after text chunks#1829
ranst91 merged 5 commits into
ag-ui-protocol:mainag-ui-protocol/ag-ui:mainfrom
he-yufeng:fix/langgraph-text-tool-transition-1678he-yufeng/ag-ui:fix/langgraph-text-tool-transition-1678Copy head branch name to clipboard

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • close the active text message when the next LangGraph stream chunk starts a tool call
  • let the existing tool-call path emit the start, args, and end events for that same chunk
  • add a regression for text-to-tool-call transitions

Fixes #1678

To verify

  • .\.venv\Scripts\python.exe -m py_compile ag_ui_langgraph\agent.py tests\test_nested_tool_end_dedup.py
  • .\.venv\Scripts\python.exe -m pytest tests\test_nested_tool_end_dedup.py -q
  • .\.venv\Scripts\python.exe -m pytest -q

@he-yufeng
he-yufeng requested a review from a team as a code owner May 30, 2026 11:06
@vercel

vercel Bot commented May 30, 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.

@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 for the contribution! A couple things:

  1. A chunk carrying both trailing text content and a tool call would have its text delta dropped. is_message_content_event is False whenever tool_call_data is set, so this block treats the chunk purely as the tool-call boundary and the chunk's content never gets emitted as TEXT_MESSAGE_CONTENT. If some provider emits final text + tool call in a single chunk, that text is lost. If that case doesn't occur in practice, fine, just worth confirming.

  2. The regression asserts ordering and the tool start/args/end, but not that the preceding TEXT_MESSAGE_START / CONTENT were emitted for the text message. Adding that would lock the full transition shape.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Updated, thanks.

  1. The mixed trailing-text + tool-call chunk is now handled explicitly: if a stream chunk carries assistant text and starts a tool call, the text delta is emitted first, the text message is ended, and only then the tool call starts. That keeps the trailing text from being dropped.
  2. The regression now asserts the preceding TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT shape, and adds a mixed chunk case covering the boundary above.

Validated locally against the updated branch:

python -m pytest tests\test_emit_events.py tests\test_nested_tool_end_dedup.py -q
python -m py_compile ag_ui_langgraph\agent.py tests\test_nested_tool_end_dedup.py
git diff --check

The remaining red Vercel status is still the CopilotKit team authorization gate.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Python Preview Packages

Version 0.0.0.dev1780592254 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.dev1780592254' --index testpypi

# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1780592254' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1780592254' --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.dev1780592254' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1780592254' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1780592254' --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.dev1780592254

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


Commit: 9f4af0c

@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@1829

@ag-ui/a2ui-middleware

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

@ag-ui/event-throttle-middleware

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

@ag-ui/mcp-apps-middleware

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

@ag-ui/mcp-middleware

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

@ag-ui/middleware-starter

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

@ag-ui/a2a

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

@ag-ui/adk

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

@ag-ui/ag2

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

@ag-ui/agno

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

@ag-ui/aws-strands

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

@ag-ui/claude-agent-sdk

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

@ag-ui/crewai

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

@ag-ui/langchain

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

@ag-ui/langgraph

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

@ag-ui/langroid

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

@ag-ui/llamaindex

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

@ag-ui/mastra

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

@ag-ui/pydantic-ai

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

@ag-ui/server-starter

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

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

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

@ag-ui/vercel-ai-sdk

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

@ag-ui/watsonx

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

@ag-ui/a2ui-toolkit

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

create-ag-ui-app

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

@ag-ui/client

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

@ag-ui/core

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

@ag-ui/encoder

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

@ag-ui/proto

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

commit: 267665a

@ranst91

ranst91 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution @he-yufeng! 🚢

@ranst91
ranst91 merged commit 9f93bba into ag-ui-protocol:main Jun 5, 2026
1 of 2 checks passed
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.

[Bug]: ag-ui-langgraph drops TOOL_CALL_START/ARGS/END when chat model emits text→tool_call transition in a single chunk

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.