Skip to content

fix(langgraph): carry ToolMessage.error onto the LangChain status flag - #2263

Open
TheSeydiCharyyev wants to merge 1 commit into
ag-ui-protocol:mainfrom
TheSeydiCharyyev:fix/2226-langgraph-toolmessage-error-status
Open

fix(langgraph): carry ToolMessage.error onto the LangChain status flag#2263
TheSeydiCharyyev wants to merge 1 commit into
ag-ui-protocol:mainfrom
TheSeydiCharyyev:fix/2226-langgraph-toolmessage-error-status

Conversation

@TheSeydiCharyyev

Copy link
Copy Markdown
Contributor

Fixes #2226.

Problem

Both langgraph adapters drop AG-UI's ToolMessage.error when they convert an incoming tool message to a LangChain ToolMessage. LangChain has a status field ("success" | "error") for exactly this, and providers such as langchain_anthropic map it onto the model's tool-result flag. With the field dropped, a client-reported tool failure reaches the model as a success. The impact is provider-dependent, so it is invisible on Gemini and shows up on Anthropic.

Fix

Map error onto status in both adapters: "error" when the AG-UI error field is set, else "success".

  • TypeScript — integrations/langgraph/typescript/src/utils.ts, the tool branch of aguiMessagesToLangChain. The langgraph-sdk ToolMessage type already types status?: "error" | "success".
  • Python — integrations/langgraph/python/ag_ui_langgraph/utils.py, the tool branch of agui_messages_to_langchain.

The AG-UI ToolMessage schema already has error in both languages, so no type changes are needed.

Scope

This PR maps the flag only. The two open questions from the issue — preserving the error text and round-tripping it back to the client — look like a separate protocol topic and are left out here.

Tests

A test is added on each side, next to the existing tool-message conversion tests.

  • TS: message-conversion.test.ts — full package suite green, 265 tests.
  • Python: test_message_conversion.pyunittest discover tests green, 43 tests.

Both langgraph adapters dropped AG-UI's ToolMessage.error when converting an incoming tool message to a LangChain ToolMessage. LangChain has a status field (success/error) for this, and providers such as langchain_anthropic map it onto the model's tool-result flag. With the field dropped, a client-reported tool failure reached the model as a success. The impact is provider-dependent, so it was invisible on Gemini.

Map error onto status in both adapters (TypeScript and Python): status is error when the AG-UI error field is set, else success. A test is added on each side.

Scope: the status flag only. Preserving the error text and round-tripping it back to the client are separate questions raised in the issue and left out here.

Fixes ag-ui-protocol#2226
@TheSeydiCharyyev
TheSeydiCharyyev requested a review from a team as a code owner July 29, 2026 06:22
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]: LangGraph adapters drop ToolMessage.error, so a client-reported tool failure reaches the model as a success

1 participant