Multi-Agent Collaboration
Build multi-agent systems with AgenticX.
Multi-Agent Collaboration
Overview
AgenticX is designed from the ground up for multi-agent systems. Multiple agents can collaborate on complex tasks through delegation, parallel execution, and structured communication protocols.
Agent Teams
1from agenticx.runtime import AgentTeamManager2from agenticx import Agent3from agenticx.llms import OpenAIProvider45llm = OpenAIProvider(model="gpt-4o")67# Define team members8researcher = Agent(id="researcher", name="Researcher", role="Information Gatherer",9 goal="Find accurate information", organization_id="team")10analyst = Agent(id="analyst", name="Analyst", role="Data Analyst",11 goal="Analyze and interpret data", organization_id="team")12writer = Agent(id="writer", name="Writer", role="Content Writer",13 goal="Produce clear written content", organization_id="team")1415# Team manager handles concurrency, session isolation, and agent lifecycle16team = AgentTeamManager(agents=[researcher, analyst, writer], max_concurrency=3)
Meta-Agent Pattern
The Meta-Agent acts as a CEO/project manager, dispatching work to specialized sub-agents:
1User Request2 ↓3Meta-Agent (analyzes, plans, delegates)4 ↓5┌───────────────────────────────┐6│ Researcher │ Analyst │ Writer │ ← Sub-agents running concurrently7└───────────────────────────────┘8 ↓9Meta-Agent (aggregates, synthesizes)10 ↓11Final Response to User
The Meta-Agent maintains an active snapshot of all running sub-agents and injects their status into its system prompt each turn.
A2A Communication Protocol
Agents can communicate directly using the A2A (Agent-to-Agent) protocol:
1from agenticx.protocols.a2a import A2AClient, A2AServer, AgentCard23# Publish an agent as an A2A service4card = AgentCard(5 agent_id="researcher",6 skills=["web_search", "document_analysis"],7 endpoint="http://localhost:8001"8)9server = A2AServer(agent=researcher, card=card)10server.start()1112# Another agent calls it13client = A2AClient()14result = client.invoke_skill(15 agent_id="researcher",16 skill="web_search",17 params={"query": "latest AI papers"}18)
Parallel Execution
Run multiple agents simultaneously:
1from agenticx.flow import ParallelExecutor23executor = ParallelExecutor(max_workers=4)45tasks = [6 (researcher, Task(description="Research topic A")),7 (researcher, Task(description="Research topic B")),8 (researcher, Task(description="Research topic C")),9]1011results = executor.run_all(tasks)
Human-in-the-Loop
Pause agent execution to get human approval:
1from agenticx.runtime import HumanInTheLoop23hitl = HumanInTheLoop(4 trigger_on=["tool_call:delete_file", "tool_call:send_email"],5 timeout_seconds=300,6 default_action="reject" # auto-reject if no human response7)89executor = AgentExecutor(agent=agent, llm=llm, human_in_the_loop=hitl)
Session Isolation
Each agent team run is isolated by owner_session_id, preventing cross-contamination between concurrent sessions. The global registry allows looking up agent status across sessions for monitoring purposes.