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

[Feature]: Support LangChain Inprocess ReAct Agents

Ouverte
#1,640 0 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
enhancement
Langage dominant
Python
Étoiles
15.9k
Forks
1.4k
Merge moyen
1 j 17 h
PR mergées (30 j)
163

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.