Migrating from LangChain
Adopting SwarmD doesn’t require rewriting your LangChain agents. Your tools, prompts, and graph stay the same — what changes is how agents discover and connect to each other.Before: Hardcoded remote agents as tools
With standalone LangChain, you’d typically wire up a remote agent by writing a custom tool that posts to its URL directly:- Agent URLs are hardcoded — adding or removing agents requires a code change and redeployment
- No centralized authentication between agents
- No A2A protocol — each remote tool reinvents request/response shape
- No polling for long-running tasks; the LLM blocks until the remote replies
- No visibility into inter-agent traffic
- No policy enforcement or approval workflows
After: Discovery through SwarmD
With SwarmD, remote agents are discovered from the registry at startup and exposed as standard LangChainBaseTool instances. Your agent logic is identical — only the wiring changes:
.env
create_llm_agent + serve — these wrap the boilerplate above and add an A2A server with admin endpoints:
- Agents are discovered at runtime from the registry — no hardcoded URLs
- OAuth2 authentication is handled by the SDK
- Each remote agent is a
PollingA2aToolthat handles A2Amessage/sendand pollstasks/getuntil terminal state, so long-running sub-agents don’t block your LLM - All traffic routes through the relay with audit logging, policy enforcement, and HITL approval support
- Adding or removing agents is a subscription change in the dashboard, not a code change
What stays the same
- Your
create_agentgraph (model, tools, system prompt) - Your tool functions and
@tool-decorated callables - Your downstream invocation patterns —
agent.ainvoke({"messages": [...]})works identically - Your existing LangChain integrations (chat history, memory, structured output)
Migration steps
- Install the SDK —
pip install swarmd-langchain - Register your agent on SwarmD via the dashboard or Registry API
- Subscribe to the downstream agents your agent needs
- Set credentials — add
SWARMD_AGENT_ID,SWARMD_CLIENT_SECRET,SWARMD_BASE_URL, andSWARMD_TOKEN_URLto your environment - Replace hardcoded HTTP tools with
fetch_remote_agents(runtime)(or switch tocreate_llm_agent+servefor the full SwarmD-managed setup)
