LangChain · agent-as-tool
How it works
LangChain's classic AgentExecutor has no first-class concept of
"another agent" — multi-agent collaboration is built by treating the second
agent as a Tool. Two patterns are common:
- Hand-rolled wrapper — a
Toolwhose_runmethod callsother_agent.invoke({"input": ...})and returns the string output. Runnable.as_tool()— any LangChain Runnable (including a compiled agent) can be converted to a Tool with.as_tool(name=..., description=...)(defined inlangchain_core/runnables/base.py).
Agent A's LLM "discovers" Agent B exactly the same way it discovers any other tool: name + description in the tool list. It picks the call by emitting a tool_call. The framework dispatches synchronously, in-process.
Axis coverage
1 · Discovery
Manual: you build the tool list when constructing each agent.
2 · LLM exposure
Native — wrapped agent appears as a tool with name + description, indistinguishable from a normal function tool.
3 · Embedded
Synchronous in-process call. Fast, simple, no scheduling.
4 · Distributed
Not in the framework. You'd write an HTTP-tool yourself or migrate to LangGraph.
Protocol on the wire
None native. In-process Python calls only. For network access: roll your own HTTP tool that POSTs to the remote agent — auth, retries, streaming all on you.
Code anchor
libs/core/langchain_core/runnables/base.py · Runnable.as_tool()
libs/langchain/langchain_classic/agents/agent.py · AgentExecutor