Overview
Concrete tool for activating swarm mode and decomposing a user request into parallel subtask plans provided by the jcode server.
Description
The run_swarm_message function is the entry point for swarm activation. When the coordinator agent receives a message with /effort swarm, this function prompts the coordinator LLM to parse the user request into a JSON array of subtask plans. Each subtask has a description, prompt, and subagent_type. The resulting plans are used to spawn worker agents and register SwarmMember entries.
Usage
- Activate swarm: Triggered when the user message contains
/effort swarm.
- Decompose task: The coordinator LLM parses the request into independent subtasks.
Code Reference
Source Location
- Repository: jcode
- File: crates/jcode-app-core/src/server/swarm.rs
Signature
pub async fn run_swarm_message(
agent: Arc<Mutex<Agent>>,
message: &str,
) -> Result<String>
Import
// Internal server function, called from swarm activation dispatch:
// crates/jcode-app-core/src/server/swarm.rs
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| agent |
Arc<Mutex<Agent>> |
Yes |
The coordinator agent
|
| message |
&str |
Yes |
User request with swarm activation prompt
|
Outputs
| Name |
Type |
Description
|
| return |
Result<String> |
JSON array of subtask plans with description, prompt, subagent_type fields
|
Usage Examples
Swarm Activation
User: /effort swarm Refactor the authentication module and add tests for each function
# The coordinator decomposes this into subtasks like:
# 1. "Refactor auth/login.rs" (worker type: rust-dev)
# 2. "Refactor auth/token.rs" (worker type: rust-dev)
# 3. "Write tests for login" (worker type: test-writer)
# 4. "Write tests for token" (worker type: test-writer)
Related Pages
Implements Principle
Requires Environment
Uses Heuristics
Page Connections
Double-click a node to navigate. Hold to expand connections.