ag-ui-protocol / ag-ui-protocol/ag-ui

[Feature]: Support LangChain Inprocess ReAct Agents

未關閉
#1,640 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Python
星號
15.9k
分支
1.4k
平均合併
1 天 17 小時
30 天內合併 PR
163

描述

### Pre-flight Checklist

- [x] I have searched existing issues and this hasn't been requested yet.

### Problem or Motivation

In v1 LangChain introduced the new `createAgent` API and ReAct-style, tool-using agents for JavaScript/TypeScript. These in-process agents are a natural fit for AG-UI, but there is currently no first-class TypeScript integration that lets an app plug a `createAgent`-based LangChain agent directly into AG-UI.

Right now, the available integrations have gaps:

@ag-ui/langchain targets the older LangChain core (0.3.x) and expects a chainFn that yields a stream of message chunks, not a v1 createAgent instance.

@ag-ui/langgraph supports LangChain v1 via LangGraph, but the TypeScript integration is focused on graphs that are accessed over deploymentUrl (remote LangGraph Cloud) or a StateGraph, not directly on a local createAgent ReAct agent.

As confirmed in [community discussion](https://discord.com/channels/1379082175625953370/1501116878922317875), this means an in-process LangChain v1 ReAct agent created via createAgent does not “slot into” either integration cleanly today.

### Proposed Solution

Introduce a new TypeScript integration that makes an in-process LangChain v1 createAgent ReAct agent a first-class AG-UI agent:

- Provide a new adapter (for example, LangChainReactAgent) that extends AbstractAgent from @ag-ui/client and accepts a createAgent-style LangChain v1 agent instance.

- Translate AG-UI runAgent inputs (messages, tools, context) into LangChain v1 message formats and tool definitions, then route them into the createAgent executor.

- Stream all relevant outputs from the LangChain agent as AG-UI events:
- Text deltas as TEXT_MESSAGE_CONTENT
- ReAct/tool invocations as AG-UI tool call events
- Optional thinking / reasoning messages as “thinking” events when available

- Pure in-process execution (agent and AG-UI running in the same Node.js process)

### Alternatives Considered

There are two practical workarounds, but both are suboptimal in common TypeScript app scenarios:

- Deploy the agent via LangGraph (dev or LangGraph Cloud) and point LangGraphAgent at the deploymentUrl. This works, but requires a separate deployment even when the app already runs everything in-process.

or

- Wrap the createAgent graph in a chainFn that streams with { streamMode: "messages" } and then manually map the [chunk, metadata] tuples into a chunk stream compatible with @ag-ui/langchain. This can stream text, but loses richer event semantics like tools and state updates that AG-UI is designed to surface.

### Additional Context

I also think a support for LangChains `deepagents` could use the new integration because afaik they use the same interface.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。