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

[Feature]: Support LangChain Inprocess ReAct Agents

Đang mở
#1,640 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
15.9k
Fork
1.4k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
163

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.