getcosmos

cosmos-delegate-to-agent

0
0
# Install this skill:
npx skills add getcosmos/agent-skills --skill "cosmos-delegate-to-agent"

Install specific skill from multi-skill repository

# Description

Teaches agents how to effectively use the delegateToAgent tool for orchestrating multi-agent work. Covers dependency graph analysis, parallel vs serial execution patterns, and progress tracking. Use when an agent needs to delegate tasks to specialist agents, especially when working with plans, todos, or multi-step requests.

# SKILL.md


name: cosmos-delegate-to-agent
description: Teaches agents how to effectively use the delegateToAgent tool for orchestrating multi-agent work. Covers dependency graph analysis, parallel vs serial execution patterns, and progress tracking. Use when an agent needs to delegate tasks to specialist agents, especially when working with plans, todos, or multi-step requests.


Delegate to Agent Skill

Master the delegateToAgent tool to orchestrate work across specialist agents efficiently.

Tool Overview

The delegateToAgent tool allows you to delegate tasks to other specialist agents. Key capabilities:

delegateToAgent({
  agentName: string,  // Name of the agent to delegate to
  task: string        // Specific task or question for that agent
})

Critical Feature: Multiple delegateToAgent calls can run in parallel. The tool uses immutable context branching - each call is isolated and doesn't interfere with others.

Discovering Available Agents

Before delegating, you need to know which agents are available. Use manageAgent with the list action:

manageAgent({ action: "list" })

This returns all specialist agents defined in the project. If you're unsure which agent is appropriate for a task, ask the user which agent they'd like you to delegate to.

Workflow:
1. Run manageAgent({ action: "list" }) to see available agents
2. Match task requirements to agent specializations
3. If unclear, ask the user: "Which agent should handle this task? Available: [agent1, agent2, ...]"
4. Proceed with delegateToAgent using the chosen agent

Core Principle: Dependency-Driven Execution

Before delegating, always analyze task dependencies to determine:
- Parallel tasks: Independent work that can run simultaneously
- Serial tasks: Work that depends on prior task completion

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   EXECUTION STRATEGY                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                         β”‚
β”‚   Independent tasks?  ──YES──►  Delegate in PARALLEL    β”‚
β”‚          β”‚                                              β”‚
β”‚          NO                                             β”‚
β”‚          β”‚                                              β”‚
β”‚          β–Ό                                              β”‚
β”‚   Has dependencies?   ──YES──►  Delegate in SERIAL      β”‚
β”‚          β”‚                      (wait for dependency)   β”‚
β”‚          NO                                             β”‚
β”‚          β”‚                                              β”‚
β”‚          β–Ό                                              β”‚
β”‚   Single task         ──────►  Delegate immediately     β”‚
β”‚                                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dependency Detection

Explicit Markers

Look for dependency markers in plans and task lists:

Marker Example Meaning
Depends on: Depends on: Phase 1 Must complete Phase 1 first
Requires: Requires: Task 2.1 Must complete Task 2.1 first
After: After: API implementation Sequential dependency
Task numbering 3.2 follows 3.1 Implicit ordering within phase

Implicit Dependencies

Infer dependencies from task semantics when markers are absent:

First Task Dependent Task Reasoning
Create schema/types Use schema/types Definition before usage
Implement feature Write tests for feature Code before tests
Design API Implement API Design before implementation
Build component Integrate component Build before integration
Research/analyze Implement based on research Information before action

Heuristic: If Task B references output, artifacts, or decisions from Task A, then B depends on A.

Execution Patterns

For detailed sequence diagrams showing parallel, serial, and mixed execution with plan updates, see assets/EXAMPLE.md.

Pattern 1: Parallel Independent Tasks

When tasks have no dependencies on each other, delegate simultaneously:

User: "Review the auth module for security, performance, and code style"

Analysis:
- Security review: independent
- Performance review: independent  
- Code style review: independent

Execution: Call all three delegateToAgent in parallel
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  delegateToAgent(security, "review")    │──┐
β”‚  delegateToAgent(performance, "review") │──┼──► All run simultaneously
β”‚  delegateToAgent(codestyle, "review")   β”‚β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Pattern 2: Serial Dependent Tasks

When tasks have dependencies, execute sequentially:

User: "Design the API, then implement it, then write tests"

Analysis:
- Design API: no dependencies
- Implement API: depends on design
- Write tests: depends on implementation

Execution: Sequential chain
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  delegateToAgent(architect, "design API")            β”‚
β”‚         β”‚                                            β”‚
β”‚         β–Ό (wait for completion)                      β”‚
β”‚  delegateToAgent(developer, "implement API")         β”‚
β”‚         β”‚                                            β”‚
β”‚         β–Ό (wait for completion)                      β”‚
β”‚  delegateToAgent(developer, "write tests")           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Pattern 3: Mixed Parallel/Serial (Dependency Graph)

Complex work often has parallel branches with serial dependencies:

Plan Phase 2:
- Task 2.1: Create database schema (no deps)
- Task 2.2: Create API types (no deps)
- Task 2.3: Implement API endpoints (requires 2.1, 2.2)
- Task 2.4: Write integration tests (requires 2.3)

Execution:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  WAVE 1 (parallel):                                 β”‚
β”‚    delegateToAgent(developer, "create schema")      β”‚
β”‚    delegateToAgent(developer, "create API types")   β”‚
β”‚         β”‚                                           β”‚
β”‚         β–Ό (wait for both)                           β”‚
β”‚  WAVE 2 (serial):                                   β”‚
β”‚    delegateToAgent(developer, "implement endpoints")β”‚
β”‚         β”‚                                           β”‚
β”‚         β–Ό (wait)                                    β”‚
β”‚  WAVE 3 (serial):                                   β”‚
β”‚    delegateToAgent(developer, "write tests")        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Progress Tracking

With a Plan Document

When executing tasks from a plan markdown file, update it as work progresses:

Checkbox Updates:

Before: - [ ] Create user schema
After:  - [x] Create user schema

Status Field Updates:

Before: **Status**: ☐ Not Started
After:  **Status**: βœ“ Complete

Phase Status:

Before: **Status**: In Progress
After:  **Status**: Complete

Timestamp Comments (optional, for audit trail):

##### 2.1 Create Database Schema
**Status**: βœ“ Complete  
**Completed**: 2026-01-31 14:32

Without a Plan Document

When given a general request without a plan, use available tracking tools:

  1. Analyze the request - Break into discrete tasks
  2. Build mental dependency graph - Determine parallel/serial
  3. Use todo tool (if available) - Track progress
  4. Execute systematically - Parallel waves, then serial chains

Example mental model:

User: "Set up authentication with JWT, add user roles, and create admin dashboard"

Dependency analysis:
β”œβ”€β”€ JWT auth implementation (independent)
β”œβ”€β”€ User roles system (depends on auth? check...)
β”‚   └── Roles need users β†’ depends on auth
└── Admin dashboard (depends on roles)

Execution order:
1. delegateToAgent(developer, "implement JWT auth")
2. delegateToAgent(developer, "add user roles system") 
3. delegateToAgent(developer, "create admin dashboard")

Best Practices

DO

  • Analyze before executing - Spend time understanding dependencies
  • Maximize parallelism - Independent tasks should run simultaneously
  • Provide clear task context - Each delegated task should be self-contained
  • Update progress immediately - Mark tasks complete as delegations return
  • Include relevant context - Pass outputs from dependencies to dependent tasks

DON'T

  • Don't serialize everything - Unnecessary sequential execution wastes time
  • Don't parallelize blindly - Dependent tasks will fail or produce inconsistent results
  • Don't forget to track - Progress visibility helps with long-running orchestration
  • Don't delegate circular chains - The tool prevents Aβ†’Bβ†’A but design your graph correctly

Tool Constraints

The delegateToAgent tool has built-in safeguards:

Constraint Limit Error
Max depth 5 levels MAX_DEPTH_EXCEEDED
Circular reference A→B→A CIRCULAR_REFERENCE
Missing context No session CONTEXT_NOT_INITIALIZED

If you hit max depth, the task is too deeply nested. Consider restructuring to reduce delegation layers.

Quick Reference

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ORCHESTRATION CHECKLIST                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  1. β–‘ Parse tasks from plan/request                         β”‚
β”‚  2. β–‘ Identify explicit dependency markers                  β”‚
β”‚  3. β–‘ Infer implicit dependencies from semantics            β”‚
β”‚  4. β–‘ Group into parallel waves                             β”‚
β”‚  5. β–‘ Execute wave 1 (all parallel)                         β”‚
β”‚  6. β–‘ Wait for wave 1 completion                            β”‚
β”‚  7. β–‘ Update plan/todos with completed tasks                β”‚
β”‚  8. β–‘ Execute wave 2 (may be parallel or serial)            β”‚
β”‚  9. β–‘ Repeat until all tasks complete                       β”‚
β”‚ 10. β–‘ Final plan/status update                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.