AllTopicsTodayAllTopicsToday
Notification
Font ResizerAa
  • Home
  • Tech
  • Investing & Finance
  • AI
  • Entertainment
  • Wellness
  • Gaming
  • Movies
Reading: A Coding Guide to Design and Orchestrate Advanced ReAct-Based Multi-Agent Workflows with AgentScope and OpenAI
Share
Font ResizerAa
AllTopicsTodayAllTopicsToday
  • Home
  • Blog
  • About Us
  • Contact
Search
  • Home
  • Tech
  • Investing & Finance
  • AI
  • Entertainment
  • Wellness
  • Gaming
  • Movies
Have an existing account? Sign In
Follow US
©AllTopicsToday 2026. All Rights Reserved.
AllTopicsToday > Blog > AI > A Coding Guide to Design and Orchestrate Advanced ReAct-Based Multi-Agent Workflows with AgentScope and OpenAI
Blog banner23 7.png
AI

A Coding Guide to Design and Orchestrate Advanced ReAct-Based Multi-Agent Workflows with AgentScope and OpenAI

AllTopicsToday
Last updated: January 5, 2026 7:37 pm
AllTopicsToday
Published: January 5, 2026
Share
SHARE

On this tutorial, you’ll use AgentScope to construct a sophisticated multi-agent incident response system. We coordinate a number of ReAct brokers, every with clearly outlined roles reminiscent of routing, triage, evaluation, writing, and reviewing, and join them by structured routing and a shared message hub. By integrating OpenAI fashions, light-weight software calls, and easy inside runbooks, we present how advanced real-world agent workflows may be configured in pure Python with out heavy infrastructure or brittle glue code. Take a look at the whole code right here.

!pip -q set up “agentscope>=0.1.5” pydantic net_asyncio import os, json, re from getpass import getpass from Typing import pydantic import BaseModel, Subject import net_asyncio nest_asyncio.apply() from Agentscope.agent import ReActAgent from Agentscope.message import Msg, TextBlock from Agentscope.mannequin import OpenAIChatModel from Agentscope.formatter import OpenAIChatFormatter from Agentscope.reminiscence Import InMemoryMemory from Agentscope.software Import Toolkit, ToolResponse, execute_python_code from Agentscope.pipeline Import MsgHub, sequential_pipeline os.environ.get(“OPENAI_API_KEY”): os.environ[“OPENAI_API_KEY”] = getpass(“Enter OPENAI_API_KEY (hidden): “) OPENAI_MODEL = os.environ.get(“OPENAI_MODEL”, “gpt-4o-mini”)

Arrange the execution atmosphere and set up all required dependencies to make sure the tutorial runs on Google Colab. Securely hundreds the OpenAI API key and initializes the core AgentScope element that’s shared between all brokers. Take a look at the whole code right here.

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”},
]

def _score(q, d): q = set(re.findall(r”[a-z0-9]+”, q. decrease())) d = re.findall(r”[a-z0-9]+”, d. decrease()) return sum(1 for w in d if w in q) / max(1, len(d)) async def search_runbook(question: str, top_k: int = 2) -> ToolResponse: Rank =sorted(RUNBOOK, key=lambda r: _score(question, r)[“title”] +r[“text”]), reverse = True)[: max(1, int(top_k))]
textual content = “nn”.be a part of(f”[{r[‘id’]}]{r[‘title’]}n{r[‘text’]}” for ranked r) return ToolResponse(content material=[TextBlock(type=”text”, text=text)]) Toolkit = Toolkit() Toolkit.register_tool_function(search_runbook) Toolkit.register_tool_function(execute_python_code)

Outline a light-weight inside runbook and implement a easy relevance-based search software on prime of it. Registering this perform with a Python execution software permits the agent to acquire coverage information and dynamically compute outcomes. This exhibits how brokers may be enhanced with exterior capabilities past pure linguistic reasoning. Take a look at the whole code right here.

def make_model(): return OpenAIChatModel(model_name=OPENAI_MODEL, api_key=os.environ[“OPENAI_API_KEY”]generate_kwargs={“temperature”: 0.2},) class Route(BaseModel): lane: literal[“triage”, “analysis”, “report”, “unknown”] = Subject(…) Purpose: str = Subject(…) router = ReActAgent( title=”Router”, sys_prompt=”Route requests to triage, evaluation, or reporting, and output solely structured JSON.”, mannequin=make_model(), formatter=OpenAIChatFormatter(),reminiscence=InMemoryMemory(), ) triager = ReActAgent( title=”Triager”, sys_prompt=”If useful, use runbook search to categorize severity and rapid actions.”, mannequin=make_model(), formatter=OpenAIChatFormatter(),reminiscence=InMemoryMemory(), toolkit=toolkit, )analyst = ReActAgent( title=”Analyst”, sys_prompt=”Python Use instruments to research logs and calculate summaries. Create a report. “, mannequin=make_model(), formatter=OpenAIChatFormatter(), reminiscence=InMemoryMemory(),) reviewer = ReActAgent( title=”Reviewer”, sys_prompt=”Critique the report and make particular corrections to enhance it.”, mannequin=make_model(), formatter=OpenAIChatFormatter(),reminiscence=InMemoryMemory(), )

Construct a number of specialised ReAct brokers and a structured router that decides easy methods to deal with every person’s requests. We assign clear duties to triage, evaluation, writing, and reviewers to make sure separation of considerations. Take a look at the whole code right here.

LOGS = “”” timestamp, service, standing, latency_ms, error 2025-12-18T12:00:00Z, checkout, 200,180, false 2025-12-18T12:00:05Z, checkout, 500,900, true 2025-12-18T12:00:10Z,auth,200,120,false 2025-12-18T12:00:12Z,checkout,502,1100,true 2025-12-18T12:00:20Z,search,200,140,false 2025-12-18T12:00:25Z,checkout,500,950,true “”” def msg_text(m: Msg) -> str:blocks = m.get_content_blocks(“textual content”) If block is None: return “” if isinstance(blocks, str): return block if isinstance(blocks, checklist): return “n”.be a part of(x in block str(x)) return str(blocks)

We current pattern log information and a utility perform that normalizes agent output to scrub textual content. It ensures that downstream brokers can safely use and enhance on earlier responses with out introducing formatting points. It focuses on making communication between brokers strong and predictable. Take a look at the whole code right here.

async def run_demo(user_request: str):route_msg = await router(Msg(“person”, user_request, “person”), Structured_model=Route) LANE = (route_msg.metadata or {}).get(“lane”, “unknown”) if LANE == “triage”: first = await triager(Msg(“person”, user_request, “person”)) elif LANE == “Evaluation”: first = Look ahead to Analyst(Msg(“person”, user_request + “nnLogs:n” + LOGS, “person”)) elif LANE == “Report”: Draft = Look ahead to Author(Msg(“person”, user_request, “person”)) first = Look ahead to Reviewer(Msg(“person”, “Assessment and Enchancment:nn” + msg_text(draft), “Consumer”)) and so on: first = Msg(“System”, “Request couldn’t be routed.”, “System”) MsgHub(Async with Participant =)[triager, analyst, writer, reviewer]annance=Msg(“Host”, “Work collectively to refine the ultimate reply.”, “Assistant”), ): await sequence_pipeline([triager, analyst, writer, reviewer]) return {“route”:route_msg.metadata, “initial_output”:msg_text(first)} consequence = await run_demo( “Checkout encountered repeated 5xx errors. Categorize the severity, analyze the logs, and create an incident report.” ) print(json.dumps(consequence, indent=2))

Coordinate your complete workflow by routing requests, working the suitable brokers, and utilizing message hubs to carry out collaborative coordination loops. Tune a number of brokers in sequence to enhance the ultimate output earlier than returning it to the person. This integrates all earlier elements right into a constant end-to-end agent pipeline.

In conclusion, now we have proven that AgentScope can be utilized to design strong, modular, and collaborative agent techniques that transcend single-prompt interactions. Inside a clear and reproducible Colab setup, we dynamically routed duties, invoked instruments solely when mandatory, and refined outputs by multi-agent coordination. This sample exhibits easy methods to scale from easy agent experiments to production-style inference pipelines whereas sustaining readability, management, and scalability for agent AI functions.

Take a look at the whole code right here. Additionally, be happy to observe us on Twitter. Additionally, do not forget to hitch the 100,000+ ML SubReddit and subscribe to our e-newsletter. grasp on! Are you on telegram? Now you can additionally take part by telegram.

Asif Razzaq is the CEO of Marktechpost Media Inc. As a visionary entrepreneur and engineer, Asif is dedicated to harnessing the potential of synthetic intelligence for social good. His newest endeavor is the launch of Marktechpost, a man-made intelligence media platform. It stands out for its thorough protection of machine studying and deep studying information, which is technically sound and simply understood by a large viewers. The platform boasts over 2 million views per 30 days, demonstrating its recognition amongst viewers.

How a Haystack-Powered Multi-Agent System Detects Incidents, Investigates Metrics and Logs, and Produces Production-Grade Incident Reviews End-to-End
Coca-Cola (KO) Q4 2025 earnings
Structured Outputs vs. Function Calling: Which Should Your Agent Use?
Run GLM 4.6 with an API
Building ReAct Agents with LangGraph: A Beginner’s Guide
TAGGED:AdvancedAgentScopeCodingDesignGuideMultiAgentOpenaiOrchestrateReActBasedWorkflows
Share This Article
Facebook Email Print
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow US

Find US on Social Medias
FacebookLike
XFollow
YoutubeSubscribe
TelegramFollow

Weekly Newsletter

Subscribe to our newsletter to get our newest articles instantly!
Popular News
5017473d54cb4f84b842f64ddd75265a xl.jpg
Entertainment

Greg Biffle’s Holiday Card Arrives In Mail After Family Dies in Plane Crash

AllTopicsToday
AllTopicsToday
December 24, 2025
Reducing GPU Memory and Accelerating Transformers
Macaulay Culkin & Brenda Song Purchase L.A. Area Home for $10.3M
Golden Shield Announces Closing of Non-Brokered Private Placement Raising CAD $2 Million
How to Run AI Models Locally (2025): Tools, Setup & Tips
- Advertisement -
Ad space (1)

Categories

  • Tech
  • Investing & Finance
  • AI
  • Entertainment
  • Wellness
  • Gaming
  • Movies

About US

We believe in the power of information to empower decisions, fuel curiosity, and spark innovation.
Quick Links
  • Home
  • Blog
  • About Us
  • Contact
Important Links
  • About Us
  • Privacy Policy
  • Terms and Conditions
  • Disclaimer
  • Contact

Subscribe US

Subscribe to our newsletter to get our newest articles instantly!

©AllTopicsToday 2026. All Rights Reserved.
1 2
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?