Skip to content

Introduce multiagent pattern practices and docs. - #910

Merged
LearningGp merged 12 commits into
agentscope-ai:mainfrom
chickenlj:multiagent-patterns
Mar 17, 2026
Merged

LearningGp merged 12 commits into
agentscope-ai:mainfrom
chickenlj:multiagent-patterns

Conversation

@chickenlj

Copy link
Copy Markdown
Collaborator

Multi-agent systems coordinate specialized agents or components to handle complex workflows. Not every complex task needs multiple agents—a single agent with the right tools and prompt can often suffice.

This pull request introduces several supervisor, handoffs, routing, etc. multiagent patterns that are built on Spring AI Alibaba Graph and AgentScope.

Examples

1. Supervisor

  • Location: agentscope-examples/multiagent-patterns/supervisor
  • Description: A central supervisor ReActAgent exposes calendar and email as tools (schedule_event, manage_email), invokes them from user requests, and combines results. Specialist capabilities are implemented as AgentScope ReActAgents with Model and registered via Toolkit.registration().subAgent().
  • Run: ./mvnw -pl agentscope-examples/multiagent-patterns/supervisor spring-boot:run. Optionally set supervisor.run-examples=true to run two sample conversations (calendar + email) on startup.

2. Pipeline

  • Location: agentscope-examples/multiagent-patterns/pipeline
  • Description: Uses Spring AI Alibaba SequentialAgent, ParallelAgent, and LoopAgent with AgentScopeAgent sub-agents and AgentScope Model (DashScopeChatModel).
    • SequentialAgent (sequential_sql_agent): Natural language → SQL generation → SQL scoring.
    • ParallelAgent (parallel_research_agent): One topic researched in parallel from technology, finance, and market angles; results merged into one report.
    • LoopAgent (loop_sql_refinement_agent): Loops “generate SQL → score” until score > 0.5.
  • Run: ./mvnw -pl agentscope-examples/multiagent-patterns/pipeline spring-boot:run. Optionally set pipeline.runner.enabled=true to run all three pipeline demos on startup.

3. Routing

  • Location: agentscope-examples/multiagent-patterns/routing
  • Description: Classifies the user query, invokes specialist AgentScopeAgents (GitHub, Notion, Slack) in parallel, and synthesizes results into one answer.
    • Simple: AgentScopeRoutingAgent + RouterService (invoke router then synthesize).
    • Graph: StateGraph with preprocess → routing node (LlmRoutingAgent) → postprocess.
  • Run: ./mvnw -pl agentscope-examples/multiagent-patterns/routing spring-boot:run. Optionally set routing.runner.enabled=true or routing-graph.runner.enabled=true for the corresponding demo.

4. Skills (progressive disclosure)

  • Location: agentscope-examples/multiagent-patterns/skills
  • Description: A single SQL assistant ReActAgent loads skills from classpath skills/ (e.g. sales_analytics, inventory_management) via AgentScope ClasspathSkillRepository and SkillBox. The model sees only skill descriptions first and loads full SKILL.md on demand with the read_skill tool.
  • Run: ./mvnw -pl agentscope-examples/multiagent-patterns/skills spring-boot:run. Optionally set skills.runner.enabled=true to run one sample query on startup.

5. Subagent

  • Location: agentscope-examples/multiagent-patterns/subagent
  • Description: A central orchestrator (AgentScopeAgent) delegates work to multiple sub-agents (e.g. codebase-explorer, web-researcher, dependency-analyzer) via Task / TaskOutput tools. Sub-agents can be defined in Markdown or in code (ReActAgent/AgentScopeAgent); the orchestrator is exposed via a CompiledGraph.
  • Run: ./mvnw -pl agentscope-examples/multiagent-patterns/subagent spring-boot:run. Optionally set subagent.run-interactive=true for interactive chat.

6. Handoffs

  • Location: agentscope-examples/multiagent-patterns/handoffs
  • Description: Sales and support AgentScopeAgents as separate graph nodes. Tools (e.g. transfer_to_support, transfer_to_sales) update state (e.g. active_agent); the graph routes between nodes based on that state for role handoffs over multiple turns.
  • Run: ./mvnw -pl agentscope-examples/multiagent-patterns/handoffs spring-boot:run. Optionally set agentscope.runner.enabled=true for the demo. Default port 8089; can be used with the chat UI.

7. Workflow (custom)

  • Location: agentscope-examples/multiagent-patterns/workflow
  • Description: Custom multi-step flows with StateGraph; two sub-examples:
    • RAG (workflow.rag.enabled=true): Query → rewrite → retrieve → prepare → Agent (ReActAgent + context) → response.
    • SQL (workflow.sql.enabled=true): list_tables → get_schema → generate_query (AgentScopeAgent + SQL tools), using H2 in-memory with a Chinook-like schema.
  • Run:
    • RAG: ./mvnw -pl agentscope-examples/multiagent-patterns/workflow spring-boot:run -Dspring-boot.run.arguments="--workflow.rag.enabled=true --workflow.runner.enabled=true"
    • SQL: Same, but use --workflow.sql.enabled=true instead of --workflow.rag.enabled=true.

@chickenlj
chickenlj requested review from a team and Copilot March 10, 2026 11:19
@cla-assistant

cla-assistant Bot commented Mar 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces seven multi-agent pattern examples for AgentScope (Supervisor, Pipeline, Routing, Skills, Subagent, Handoffs, and Workflow), along with corresponding documentation updates in both English and Chinese.

Changes:

  • Added seven new Spring Boot example modules under agentscope-examples/multiagent-patterns/ demonstrating various multi-agent orchestration patterns built on Spring AI Alibaba Graph and AgentScope.
  • Added new documentation pages in docs/en/multi-agent/ and docs/zh/multi-agent/ covering each pattern, plus a new agent-as-tool.md feature doc.
  • Updated docs/_toc.yml to reorganize the Multi Agent section and add the new pattern pages, and corrected cross-reference links in existing docs.

Reviewed changes

Copilot reviewed 137 out of 139 changed files in this pull request and generated 29 comments.

Show a summary per file
File Description
agentscope-examples/pom.xml Registers the 7 new multiagent-patterns submodules
agentscope-examples/multiagent-patterns/supervisor/ Supervisor pattern: central ReActAgent delegates calendar/email tasks as sub-agent tools
agentscope-examples/multiagent-patterns/pipeline/ Pipeline patterns: SequentialAgent, ParallelAgent, LoopAgent with AgentScopeAgent sub-agents
agentscope-examples/multiagent-patterns/routing/ Routing pattern: classifies queries, invokes GitHub/Notion/Slack specialist agents in parallel
agentscope-examples/multiagent-patterns/skills/ Skills (progressive disclosure) pattern: SQL assistant loads skill schemas on demand
agentscope-examples/multiagent-patterns/subagent/ Subagent pattern: orchestrator delegates to Markdown/API-defined sub-agents via Task tools
agentscope-examples/multiagent-patterns/workflow/ Custom workflow pattern: RAG and SQL agents using StateGraph with H2 in-memory DB
agentscope-examples/multiagent-patterns/handoffs/ Handoffs pattern: sales/support agents with state-driven routing between graph nodes
agentscope-examples/quarkus/src/main/resources/application.properties Adds native build configuration
docs/_toc.yml Adds new multi-agent pattern pages to TOC, reorganizes the Multi Agent section
docs/en/task/agent-as-tool.md New English documentation for Agent as Tool feature
docs/en/multi-agent/supervisor.md, skills.md New English pattern documentation
docs/zh/multi-agent/supervisor.md, skills.md New Chinese pattern documentation
docs/en/multi-agent/multiagent-debate.md, docs/zh/multi-agent/multiagent-debate.md Updated links to new patterns
docs/en/task/tool.md, docs/zh/task/tool.md Fixed relative links to agent-as-tool.md
docs/en/task/msghub.md, docs/zh/task/msghub.md Fixed cross-directory links to pipeline/multiagent-debate
docs/en/intro.md, docs/zh/intro.md Removed MsgHub from top-level multi-agent section

Comment thread docs/en/multi-agent/supervisor.md Resolved
@codecov

codecov Bot commented Mar 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LearningGp
LearningGp merged commit ca712c8 into agentscope-ai:main Mar 17, 2026
5 checks passed
liangxingguang pushed a commit to liangxingguang/agentscope-java that referenced this pull request May 21, 2026
…tscope-ai#910)

Multi-agent systems coordinate specialized agents or components to
handle complex workflows. Not every complex task needs multiple agents—a
single agent with the right tools and prompt can often suffice.

This pull request introduces several supervisor, handoffs, routing, etc.
multiagent patterns that are built on Spring AI Alibaba Graph and
AgentScope.

## Examples

### 1. Supervisor

- **Location**: `agentscope-examples/multiagent-patterns/supervisor`
- **Description**: A central supervisor ReActAgent exposes calendar and
email as tools (`schedule_event`, `manage_email`), invokes them from
user requests, and combines results. Specialist capabilities are
implemented as AgentScope ReActAgents with Model and registered via
`Toolkit.registration().subAgent()`.
- **Run**: `./mvnw -pl
agentscope-examples/multiagent-patterns/supervisor spring-boot:run`.
Optionally set `supervisor.run-examples=true` to run two sample
conversations (calendar + email) on startup.

---

### 2. Pipeline

- **Location**: `agentscope-examples/multiagent-patterns/pipeline`
- **Description**: Uses Spring AI Alibaba **SequentialAgent**,
**ParallelAgent**, and **LoopAgent** with **AgentScopeAgent** sub-agents
and AgentScope Model (DashScopeChatModel).
- **SequentialAgent** (`sequential_sql_agent`): Natural language → SQL
generation → SQL scoring.
- **ParallelAgent** (`parallel_research_agent`): One topic researched in
parallel from technology, finance, and market angles; results merged
into one report.
- **LoopAgent** (`loop_sql_refinement_agent`): Loops “generate SQL →
score” until score > 0.5.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/pipeline
spring-boot:run`. Optionally set `pipeline.runner.enabled=true` to run
all three pipeline demos on startup.

---

### 3. Routing

- **Location**: `agentscope-examples/multiagent-patterns/routing`
- **Description**: Classifies the user query, invokes specialist
AgentScopeAgents (GitHub, Notion, Slack) in parallel, and synthesizes
results into one answer.
- **Simple**: `AgentScopeRoutingAgent` + `RouterService` (invoke router
then synthesize).
- **Graph**: StateGraph with preprocess → routing node (LlmRoutingAgent)
→ postprocess.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/routing
spring-boot:run`. Optionally set `routing.runner.enabled=true` or
`routing-graph.runner.enabled=true` for the corresponding demo.

---

### 4. Skills (progressive disclosure)

- **Location**: `agentscope-examples/multiagent-patterns/skills`
- **Description**: A single SQL assistant ReActAgent loads skills from
classpath `skills/` (e.g. sales_analytics, inventory_management) via
AgentScope **ClasspathSkillRepository** and **SkillBox**. The model sees
only skill descriptions first and loads full SKILL.md on demand with the
**read_skill** tool.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/skills
spring-boot:run`. Optionally set `skills.runner.enabled=true` to run one
sample query on startup.

---

### 5. Subagent

- **Location**: `agentscope-examples/multiagent-patterns/subagent`
- **Description**: A central orchestrator (AgentScopeAgent) delegates
work to multiple sub-agents (e.g. codebase-explorer, web-researcher,
dependency-analyzer) via Task / TaskOutput tools. Sub-agents can be
defined in Markdown or in code (ReActAgent/AgentScopeAgent); the
orchestrator is exposed via a CompiledGraph.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/subagent
spring-boot:run`. Optionally set `subagent.run-interactive=true` for
interactive chat.

---

### 6. Handoffs

- **Location**: `agentscope-examples/multiagent-patterns/handoffs`
- **Description**: Sales and support AgentScopeAgents as separate graph
nodes. Tools (e.g. `transfer_to_support`, `transfer_to_sales`) update
state (e.g. `active_agent`); the graph routes between nodes based on
that state for role handoffs over multiple turns.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/handoffs
spring-boot:run`. Optionally set `agentscope.runner.enabled=true` for
the demo. Default port 8089; can be used with the chat UI.

---

### 7. Workflow (custom)

- **Location**: `agentscope-examples/multiagent-patterns/workflow`
- **Description**: Custom multi-step flows with StateGraph; two
sub-examples:
- **RAG** (`workflow.rag.enabled=true`): Query → rewrite → retrieve →
prepare → Agent (ReActAgent + context) → response.
- **SQL** (`workflow.sql.enabled=true`): list_tables → get_schema →
generate_query (AgentScopeAgent + SQL tools), using H2 in-memory with a
Chinook-like schema.
- **Run**:
- RAG: `./mvnw -pl agentscope-examples/multiagent-patterns/workflow
spring-boot:run -Dspring-boot.run.arguments="--workflow.rag.enabled=true
--workflow.runner.enabled=true"`
- SQL: Same, but use `--workflow.sql.enabled=true` instead of
`--workflow.rag.enabled=true`.
wzl521 pushed a commit to wzl521/agentscope-java that referenced this pull request Aug 12, 2026
…tscope-ai#910)

Multi-agent systems coordinate specialized agents or components to
handle complex workflows. Not every complex task needs multiple agents—a
single agent with the right tools and prompt can often suffice.

This pull request introduces several supervisor, handoffs, routing, etc.
multiagent patterns that are built on Spring AI Alibaba Graph and
AgentScope.

## Examples

### 1. Supervisor

- **Location**: `agentscope-examples/multiagent-patterns/supervisor`
- **Description**: A central supervisor ReActAgent exposes calendar and
email as tools (`schedule_event`, `manage_email`), invokes them from
user requests, and combines results. Specialist capabilities are
implemented as AgentScope ReActAgents with Model and registered via
`Toolkit.registration().subAgent()`.
- **Run**: `./mvnw -pl
agentscope-examples/multiagent-patterns/supervisor spring-boot:run`.
Optionally set `supervisor.run-examples=true` to run two sample
conversations (calendar + email) on startup.

---

### 2. Pipeline

- **Location**: `agentscope-examples/multiagent-patterns/pipeline`
- **Description**: Uses Spring AI Alibaba **SequentialAgent**,
**ParallelAgent**, and **LoopAgent** with **AgentScopeAgent** sub-agents
and AgentScope Model (DashScopeChatModel).
- **SequentialAgent** (`sequential_sql_agent`): Natural language → SQL
generation → SQL scoring.
- **ParallelAgent** (`parallel_research_agent`): One topic researched in
parallel from technology, finance, and market angles; results merged
into one report.
- **LoopAgent** (`loop_sql_refinement_agent`): Loops “generate SQL →
score” until score > 0.5.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/pipeline
spring-boot:run`. Optionally set `pipeline.runner.enabled=true` to run
all three pipeline demos on startup.

---

### 3. Routing

- **Location**: `agentscope-examples/multiagent-patterns/routing`
- **Description**: Classifies the user query, invokes specialist
AgentScopeAgents (GitHub, Notion, Slack) in parallel, and synthesizes
results into one answer.
- **Simple**: `AgentScopeRoutingAgent` + `RouterService` (invoke router
then synthesize).
- **Graph**: StateGraph with preprocess → routing node (LlmRoutingAgent)
→ postprocess.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/routing
spring-boot:run`. Optionally set `routing.runner.enabled=true` or
`routing-graph.runner.enabled=true` for the corresponding demo.

---

### 4. Skills (progressive disclosure)

- **Location**: `agentscope-examples/multiagent-patterns/skills`
- **Description**: A single SQL assistant ReActAgent loads skills from
classpath `skills/` (e.g. sales_analytics, inventory_management) via
AgentScope **ClasspathSkillRepository** and **SkillBox**. The model sees
only skill descriptions first and loads full SKILL.md on demand with the
**read_skill** tool.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/skills
spring-boot:run`. Optionally set `skills.runner.enabled=true` to run one
sample query on startup.

---

### 5. Subagent

- **Location**: `agentscope-examples/multiagent-patterns/subagent`
- **Description**: A central orchestrator (AgentScopeAgent) delegates
work to multiple sub-agents (e.g. codebase-explorer, web-researcher,
dependency-analyzer) via Task / TaskOutput tools. Sub-agents can be
defined in Markdown or in code (ReActAgent/AgentScopeAgent); the
orchestrator is exposed via a CompiledGraph.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/subagent
spring-boot:run`. Optionally set `subagent.run-interactive=true` for
interactive chat.

---

### 6. Handoffs

- **Location**: `agentscope-examples/multiagent-patterns/handoffs`
- **Description**: Sales and support AgentScopeAgents as separate graph
nodes. Tools (e.g. `transfer_to_support`, `transfer_to_sales`) update
state (e.g. `active_agent`); the graph routes between nodes based on
that state for role handoffs over multiple turns.
- **Run**: `./mvnw -pl agentscope-examples/multiagent-patterns/handoffs
spring-boot:run`. Optionally set `agentscope.runner.enabled=true` for
the demo. Default port 8089; can be used with the chat UI.

---

### 7. Workflow (custom)

- **Location**: `agentscope-examples/multiagent-patterns/workflow`
- **Description**: Custom multi-step flows with StateGraph; two
sub-examples:
- **RAG** (`workflow.rag.enabled=true`): Query → rewrite → retrieve →
prepare → Agent (ReActAgent + context) → response.
- **SQL** (`workflow.sql.enabled=true`): list_tables → get_schema →
generate_query (AgentScopeAgent + SQL tools), using H2 in-memory with a
Chinook-like schema.
- **Run**:
- RAG: `./mvnw -pl agentscope-examples/multiagent-patterns/workflow
spring-boot:run -Dspring-boot.run.arguments="--workflow.rag.enabled=true
--workflow.runner.enabled=true"`
- SQL: Same, but use `--workflow.sql.enabled=true` instead of
`--workflow.rag.enabled=true`.
xzxiaoshan added a commit that referenced this pull request Oct 14, 2026
Follow-up to #3526, from the same CI build-time investigation.

## Summary

- Build both the Linux and Windows jobs in parallel with `-T1C` (one
thread per core) using the standard Maven preinstalled on both runners,
replacing the single-threaded `-T1` (Windows previously ran mvnd pinned
to `-T1`, so it never actually built in parallel).
- Drop mvnd entirely from the Windows job: `MVND_VERSION`, the `Cache
mvnd` / `Install mvnd` steps, `mvnd-cache-path` in the matrix, and
`-Dmvnd.maxLostKeepAlive=120`.
- Companion commit (deliberately separate from the workflow change):
raise the hardcoded 10s `.block(...)` timeout in
`AnthropicChatModelAuthenticationTest.assertExchange` to 30s. This was
the only failure observed under heavy parallel test load (32 concurrent
test JVMs) — a test-robustness issue unrelated to build correctness, but
one that would pollute the CI signal under `-T1C`.

## Why `-T1` can be lifted

- `-T1` was introduced in #910 to keep reactor order so agentscope-core
is built before the modules that resolve it. That rationale does not
hold: `clean verify` never installs anything, and Maven's parallel
builder schedules modules by the dependency graph, so reactor ordering
is guaranteed at any thread count.
- The failure `-T1` actually papered over was spotless lock contention
under mvnd's parallel execution (`spotless-maven-plugin:check failed:
Could not acquire lock(s)`, about a dozen modules). Reproduced locally
on the #910 tree with mvnd 1.0.3 at default parallelism; the same tree
with standard Maven at `-T1C` (32 threads) builds clean, and spotless
3.3.0/3.4.0 under 12-way standard-Maven concurrency shows no lock
errors. The module that originally triggered it was removed in cc3b2ee
(2026-06).
- Linux already builds with standard Maven because of mvnd problems (the
embedded distribution broke Surefire IPC, #3080). Moving Windows to
standard `mvn` removes the remaining mvnd-specific failure sources plus
the mvnd install/cache overhead.

## Rollback

Workflow/command-line-level change only — no artifact content changes;
reverting the commit fully rolls back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants