Creating Advanced Multi-Agent Workflows with ReAct
Build a robust multi-agent incident response system using AgentScope and OpenAI models.
Overview
In this tutorial, we build an advanced multi-agent incident response system using AgentScope. We orchestrate multiple ReAct agents, each with a clearly defined role such as routing, triage, analysis, writing, and review, and connect them through structured routing and a shared message hub. By integrating OpenAI models, lightweight tool calling, and a simple internal runbook, we demonstrate how complex, real-world agentic workflows can be composed in pure Python without heavy infrastructure or brittle glue code.
Setting Up the Environment
We set up the execution environment and install all required dependencies so the tutorial runs reliably on Google Colab. We securely load the OpenAI API key and initialize the core AgentScope components that will be shared across all agents. Here’s how to install the dependencies:
!pip -q install "agentscope>=0.1.5" pydantic nest_asyncioImplementing the Runbook
We define a lightweight internal runbook and implement a simple relevance-based search tool over it. This allows agents to retrieve policy knowledge or compute results dynamically:
RUNBOOK = [
{"id": "P0", "title": "Severity Policy", "text": "P0 critical outage, P1 major degradation, P2 minor issue"},
{"id": "IR1", "title": "Incident Triage Checklist", "text": "Assess blast radius, timeline, deployments, errors, mitigation"},
{"id": "SEC7", "title": "Phishing Escalation", "text": "Disable account, reset sessions, block sender, preserve evidence"},
]Constructing Agents
We construct multiple specialized ReAct agents and a structured router that decides how each user request should be handled:
triager = ReActAgent(
name="Triager",
sys_prompt="Classify severity and immediate actions using runbook search when useful.",
model=make_model(),
formatter=OpenAIChatFormatter(),
memory=InMemoryMemory(),
toolkit=toolkit,
)Orchestrating the Workflow
We orchestrate the full workflow by routing the request, executing the appropriate agent, and running a collaborative refinement loop using a message hub:
async def run_demo(user_request: str):
route_msg = await router(Msg("user", user_request, "user"), structured_model=Route)
# Handle the request based on routing
# (Further implementation)By coordinating multiple agents in sequence, we improve the final output before returning it to the user. This pattern illustrates how we can scale from simple agent experiments to production-style reasoning pipelines.
Conclusion
We demonstrated how AgentScope enables robust, modular, and collaborative agent systems that go beyond single-prompt interactions. We routed tasks dynamically and refined outputs through multi-agent coordination, all within a clean and reproducible Colab setup.
Full Codes
Check out the FULL CODES here.
Сменить язык
Читать эту статью на русском