Yes, there is exactly such a concept, and it is native to the LangChain/LangGraph ecosystem. It is officially called a RemoteGraph.A RemoteGraph acts as a proxy for an agent deployed on a remote server (such as LangSmith Deployment, formerly LangGraph Cloud). It exposes standard HTTP/REST endpoints for invocation while perfectly mirroring the local graph interface.How Remote Agents Work in LangGraphWhen you build a multi-agent system, writing one massive graph can become chaotic. LangGraph allows graph composability, meaning a graph can be added as a node inside another graph.If that subgraph lives on a different server, you use RemoteGraph to wrap its HTTP API endpoint. The parent graph interacts with it as if it were a local node, while LangGraph manages the HTTP calls and response streaming under the hood.pythonfrom langgraph.graph import StateGraph
from langgraph.pregel.remote import RemoteGraph
# 1. Connect to the remote agent via its deployed HTTP URL
remote_research_agent = RemoteGraph(
graph_id="research-expert",
url="https://your-langgraph-server-url.com",
api_key="your_api_key"
)
# 2. Build your local orchestrator graph
builder = StateGraph(MyState)
# 3. Use the remote agent directly as a node!
builder.add_node("orchestrator", orchestrator_node)
builder.add_node("research_team", remote_research_agent) # Invoked via HTTP automatically
builder.add_edge("orchestrator", "research_team")
Use code with caution.Key Features of RemoteGraphThread-Level Persistence: Just like local agents, RemoteGraph supports stateful operations. If you pass a thread_id in the configuration, the remote agent remembers the conversation history across separate HTTP calls.Streaming Support: It natively streams tokens and node transitions over HTTP (via Server-Sent Events / SSE) back to the parent graph.Language Agnostic Separation: Because the interface is fundamentally an HTTP API, your remote agent can be updated, redeployed, or scaled independently without breaking the orchestrator graph.Alternative: LangGraph Agents as MCP ToolsIf you want to use the literal Model Context Protocol (MCP), you can also wrap a LangGraph agent inside an MCP server transport layer. This exposes the entire LangGraph workflow as an MCP Tool. A parent agent can then query the MCP server, discover the remote agent tool dynamically via HTTP/SSE, and invoke it during its reasoning cycle.Would you like to see how to configure a langgraph.json file to deploy an agent to a server, or would you prefer a breakdown of how to convert a LangGraph agent into an MCP server?
No comments:
Post a Comment