Skip to content

feat: Multi-Agent Orchestration System - #2036

Closed
emoubarak wants to merge 1 commit into
agentscope-ai:mainfrom
emoubarak:feat/workflow-orchestration-engine
Closed

emoubarak wants to merge 1 commit into
agentscope-ai:mainfrom
emoubarak:feat/workflow-orchestration-engine

Conversation

@emoubarak

Copy link
Copy Markdown
Contributor

Summary

This PR implements a complete multi-agent orchestration system that allows agents to dynamically spawn and coordinate with other agents. It includes:

  1. Backend: Orchestration configuration API, workflow engine, and spawn_agent tool
  2. Frontend: UI for configuring orchestration settings and provider/model selection in Agent Management
  3. Tests: Comprehensive unit tests for the spawn tool and workflow engine

Features

Backend

Feature Description
spawn_agent Tool Async tool allowing agents to spawn other agents with permission checks
OrchestrationConfig Pydantic model with can_spawn_agents, allowed_agents, max_spawn_depth
API Endpoint GET/PUT /api/agent/orchestration-config for runtime configuration
Context Tracking ContextVar pattern for spawn depth tracking
Permission Checks Self-spawning prevention, allowed list validation, depth limits

Frontend

Feature Description
OrchestrationCard New component in Agent Config page for orchestration settings
Agent Management Modal Orchestration fields + provider/model cascade selection
Provider Filtering Show only eligible providers (configured with API key and models)
i18n Full English and Chinese translations

Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Agent (caller)                          │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  spawn_agent(agent_id, prompt, timeout)            │    │
│  │    ↓                                                │    │
│  │  Permission Checks:                                 │    │
│  │    - can_spawn_agents?                              │    │
│  │    - agent_id in allowed_agents?                    │    │
│  │    - spawn_depth < max_spawn_depth?                 │    │
│  │    - agent_id != current_agent_id? (no self-spawn)  │    │
│  │    ↓                                                │    │
│  │  MultiAgentManager.get_agent(agent_id)              │    │
│  │    ↓                                                │    │
│  │  workspace.runner.query_handler(prompt)             │    │
│  │    ↓                                                │    │
│  │  [Agent: agent_id] Response                         │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

Files Changed

Backend (Python):
  src/copaw/agents/tools/spawn_agent.py          # Core spawn tool
  src/copaw/agents/react_agent.py               # Tool registration
  src/copaw/app/agent_context.py                # ContextVar for spawn depth
  src/copaw/app/orchestration/                  # Workflow engine + schema
  src/copaw/app/routers/agent.py                # Orchestration config API
  src/copaw/config/config.py                    # OrchestrationConfig model

Frontend (TypeScript):
  console/src/pages/Agent/Config/               # OrchestrationCard component
  console/src/pages/Settings/Agents/            # Agent modal with orchestration

Tests:
  tests/unit/agents/tools/test_spawn_agent.py   # 24 unit tests
  tests/unit/app/orchestration/                  # Engine + schema tests

Test Coverage

Component Tests Description
spawn_agent tool 24 Input validation, permissions, self-spawning, timeout, response handling
Workflow engine 11 Permission checks, depth validation

Usage Example

# Agent configuration (YAML or API)
orchestration:
  can_spawn_agents: true
  allowed_agents: ["researcher", "writer"]
  max_spawn_depth: 3

# In agent's tool call
spawn_agent(
    agent_id="researcher",
    prompt="Find information about quantum computing",
    timeout=120
)

API

# Get orchestration config
GET /api/agent/orchestration-config

# Update orchestration config
PUT /api/agent/orchestration-config
{
  "can_spawn_agents": true,
  "allowed_agents": ["researcher"],
  "max_spawn_depth": 3
}

Note for Reviewers

If anything needs to be changed, or if you think a different approach would be better, please don't hesitate to leave a comment with your feedback. I'm open to refactoring, adjusting the architecture, or taking an entirely different direction if that makes more sense for the project. Your feedback is very welcome! 🙏

@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 01:58 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:02 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:05 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:14 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:14 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:25 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:26 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:39 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:40 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:49 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 02:51 — with GitHub Actions Failure
Implement a complete multi-agent orchestration system allowing agents to
dynamically spawn and coordinate with other agents.

Backend:
- Add spawn_agent async tool with permission checks
- Add OrchestrationConfig model (can_spawn_agents, allowed_agents, max_spawn_depth)
- Add GET/PUT /api/agent/orchestration-config endpoint
- Use ContextVar pattern for spawn depth tracking
- Prevent self-spawning and enforce depth limits

Frontend:
- Add OrchestrationCard component in Agent Config page
- Add provider/model cascade selection in Agent Management modal
- Filter providers to show only eligible ones (with API key, models)
- Add i18n translations (EN/ZH)

Tests:
- Add 24 unit tests for spawn_agent tool
- Add 11 tests for workflow engine
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 03:00 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 03:13 — with GitHub Actions Failure
@emoubarak
emoubarak had a problem deploying to maintainer-approved March 22, 2026 03:23 — with GitHub Actions Failure
@github-project-automation github-project-automation Bot moved this to Todo in QwenPaw Mar 25, 2026
@emoubarak emoubarak closed this Mar 31, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in QwenPaw Mar 31, 2026

This branch had an error being deployed

1 failed deployment
maintainer-approved — 59b727cf Deployed Mar 22, 2026 by emoubarak via Maintainer Approval #1035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants