Guide for working with the multi-agent orchestration system in DEVS. Use this when asked to modify task orchestration, agent coordination, or workflow execution.
The DEVS orchestration system coordinates multiple AI agents to complete complex tasks autonomously.
User Request → WorkflowOrchestrator → TaskAnalyzer → Agent Execution → Validation
↓
Strategy Selection
(single-pass / multi-pass)
↓
Team Building → Coordinated Execution → Artifact Creation
src/lib/orchestrator.ts)Central coordination hub that:
src/lib/task-analyzer.ts)LLM-powered analysis that:
src/lib/requirement-validator.ts)Validates task deliverables against requirements:
For simple tasks that one agent can complete:
async function executeSinglePass(task: Task, agent: Agent): Promise<void> {
// 1. Execute with enhanced context
const result = await executeTaskWithAgent(task, agent, task.description)
// 2. Create artifact from result
await createArtifact({
taskId: task.id,
agentId: agent.id,
type: 'deliverable',
content: result,
})
// 3. Validate against requirements
const validation = await validateRequirements(task, [artifact])
// 4. Handle validation failures
if (!validation.allSatisfied) {
await createRefinementTask(task, validation.failures)
}
}
For complex tasks requiring multiple agents:
async function executeMultiPass(task: Task): Promise<void> {
// 1. Break down into subtasks
const subtasks = await taskAnalyzer.breakdown(task)
// 2. Build specialized team
const team = await buildTeam(subtasks)
// 3. Execute with dependency resolution
await coordinateTeamExecution(subtasks, team)
// 4. Validate all deliverables
const validation = await validateAllRequirements(task, subtasks)
}
async function coordinateTeamExecution(
tasks: Task[],
team: Agent[],
): Promise<void> {
const executedTasks = new Set<string>()
while (executedTasks.size < tasks.length) {
// Find tasks with satisfied dependencies
const readyTasks = tasks.filter(
(task) =>
!executedTasks.has(task.id) &&
task.dependencies.every((depId) => executedTasks.has(depId)),
)
// Execute in parallel batches
const batch = readyTasks.slice(0, team.length)
await Promise.all(
batch.map((task, index) => {
const agent = team[index % team.length]
return executeTaskWithAgent(task, agent, task.description)
}),
)
batch.forEach((task) => executedTasks.add(task.id))
}
}
The ContextBroker enables inter-agent communication:
import { ContextBroker } from '@/lib/context-broker'
// Agent publishes context
await ContextBroker.publish({
type: 'finding',
agentId: agent.id,
content: 'Discovered that the API requires authentication',
keywords: ['api', 'authentication', 'security'],
})
// Another agent retrieves relevant context
const relevantContext = await ContextBroker.getRelevant(['api', 'design'])
type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed'
State transitions:
pending → in_progress (when assigned to agent)in_progress → completed (when validated successfully)in_progress → failed (when validation fails after retries)failed → in_progress (when retry initiated)interface Requirement {
id: string
type: 'functional' | 'non-functional' | 'constraint'
description: string
priority: 'must' | 'should' | 'could' | 'wont'
source: 'explicit' | 'implicit' | 'inferred'
validationStatus?: 'satisfied' | 'pending' | 'failed'
evidence?: string[]
}
When extending orchestration:
import { WorkflowOrchestrator } from '@/lib/orchestrator'
import { TaskAnalyzer } from '@/lib/task-analyzer'
import { getAgentById, createAgent } from '@/stores/agentStore'
async function customOrchestration(prompt: string): Promise<void> {
// 1. Analyze the task
const analysis = await TaskAnalyzer.analyze(prompt)
// 2. Find or create suitable agent
let agent = await findAgentWithSkills(analysis.requiredSkills)
if (!agent) {
agent = await createAgent({
name: 'Dynamic Agent',
role: analysis.suggestedRole,
instructions: analysis.suggestedInstructions,
})
}
// 3. Create task with requirements
const task = await createTask({
title: analysis.title,
description: prompt,
complexity: analysis.complexity,
requirements: analysis.requirements,
assignedAgentId: agent.id,
})
// 4. Execute based on complexity
if (analysis.complexity === 'simple') {
await executeSinglePass(task, agent)
} else {
await executeMultiPass(task)
}
}
The orchestrator implements multi-level error handling:
try {
await orchestrator.execute(prompt)
} catch (error) {
if (error instanceof DuplicatePromptError) {
// Already processing this prompt
return existingWorkflow
}
if (error instanceof AgentNotFoundError) {
// Create fallback agent
const fallbackAgent = await createFallbackAgent(requiredSkills)
await orchestrator.execute(prompt, fallbackAgent)
}
// Log and notify user
console.error('Orchestration failed:', error)
toast.error('Task execution failed. Please try again.')
}
import { describe, it, expect, vi } from 'vitest'
import { WorkflowOrchestrator } from '@/lib/orchestrator'
vi.mock('@/lib/llm')
vi.mock('@/stores/agentStore')
vi.mock('@/stores/taskStore')
describe('WorkflowOrchestrator', () => {
it('should select single-pass for simple tasks', async () => {
const result = await WorkflowOrchestrator.analyze('Write a hello world')
expect(result.strategy).toBe('single-pass')
})
it('should build team for complex tasks', async () => {
const result = await WorkflowOrchestrator.analyze(
'Build a complete e-commerce platform',
)
expect(result.strategy).toBe('multi-pass')
expect(result.requiredAgents.length).toBeGreaterThan(1)
})
})
npx skills add codename-co/orchestration-workflow下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer