Commit ca712c8
authored
feat(example): Introduce multiagent pattern practices and docs. (agentscope-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`.1 parent 59fa986 commit ca712c8
139 files changed
Lines changed: 10749 additions & 459 deletions
File tree
- .github/workflows
- agentscope-examples
- multiagent-patterns
- handoffs
- src/main
- java/io/agentscope/examples/handoffs/multiagent
- route
- state
- tools
- resources
- pipeline
- src/main
- java/com/alibaba/cloud/ai/examples/multiagents/pipeline
- loop
- parallel
- sequential
- resources
- routing
- src/main
- java/io/agentscope/examples/routing
- graph
- node
- tools
- simple
- state
- tools
- resources
- skills
- src/main
- java/com/alibaba/cloud/ai/examples/multiagents/skills
- resources
- skills
- inventory_management
- sales_analytics
- subagent
- src/main
- java/io/agentscope/examples/subagent
- tools
- task
- resources
- agents
- supervisor
- src/main
- java/io/agentscope/examples/supervisor
- tools
- resources
- workflow
- src/main
- java/com/alibaba/cloud/ai/examples/multiagents/workflow
- ragagent
- node
- tools
- sqlagent
- node
- tools
- resources
- quarkus/src/main/resources
- docs
- en
- multi-agent
- task
- zh
- multi-agent
- task
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | | - | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
Lines changed: 141 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments