Skip to content

Enable multi-agent orchestration and collaboration #10158

@Mossaka

Description

@Mossaka

Description

Implement support for running multiple Copilot agents concurrently with shared coordination, enabling specialized agents to collaborate on complex tasks.

Part of Epic

#10154 - Copilot SDK Integration for Advanced Agentic Workflows

Problem Statement

CLI Limitation:

  • Cannot run multiple agents concurrently in same process
  • Each agent invocation is independent subprocess
  • No coordination between agents
  • Cannot share context between agents programmatically

SDK Opportunity:

// Run multiple specialist agents with coordination
const analyzerAgent = await client.createSession({ role: "code_analyzer" });
const securityAgent = await client.createSession({ role: "security_reviewer" });
const perfAgent = await client.createSession({ role: "perf_optimizer" });

// Parallel execution with result synthesis
const [codeIssues, securityIssues, perfIssues] = await Promise.all([
  analyzerAgent.send({ prompt: "Analyze code quality" }),
  securityAgent.send({ prompt: "Check for vulnerabilities" }),
  perfAgent.send({ prompt: "Identify bottlenecks" })
]);

// Coordinator synthesizes findings
const coordinator = await client.createSession({ role: "synthesizer" });
await coordinator.send({
  prompt: `Consolidate: ${JSON.stringify({ codeIssues, securityIssues, perfIssues })}`
});

Use Cases

1. Specialized Code Review

  • Analyst Agent - Code quality and best practices
  • Security Agent - Vulnerability detection
  • Performance Agent - Bottleneck identification
  • Accessibility Agent - A11y compliance
  • Coordinator - Synthesize findings and prioritize

2. Multi-Repository Changes

  • Discovery Agent - Identify affected repositories
  • Per-Repo Agents - Implement changes in each repo
  • Coordinator - Track status and coordinate merges

3. Test Generation Pipeline

  • Generator Agent - Create test cases
  • Validator Agent - Verify test quality
  • Coverage Agent - Analyze coverage gaps
  • Coordinator - Iterate until coverage goals met

4. Documentation Update

  • Scanner Agent - Find outdated docs
  • Writer Agent - Update documentation
  • Reviewer Agent - Verify accuracy
  • Coordinator - Approve and publish

Design Requirements

1. Agent Definition

engine:
  id: copilot
  mode: sdk
  agents:
    - id: analyzer
      role: "Code quality analyzer"
      model: gpt-5
      tools: [github, bash]
    - id: security
      role: "Security reviewer"
      model: gpt-5
      tools: [github, static-analysis]
    - id: performance
      role: "Performance optimizer"
      model: gpt-5
      tools: [github, profiler]
    - id: coordinator
      role: "Results synthesizer"
      model: claude-sonnet-4-5
      coordinator: true  # Has access to other agent results

2. Coordination Patterns

Pattern A: Parallel + Synthesis

// All agents work independently, coordinator synthesizes
const results = await Promise.all(agents.map(a => a.execute()));
const final = await coordinator.synthesize(results);

Pattern B: Sequential Pipeline

// Each agent builds on previous agent's output
let context = initialContext;
for (const agent of agents) {
  context = await agent.execute(context);
}

Pattern C: Hierarchical Delegation

// Coordinator delegates to specialists as needed
await coordinator.send({
  prompt: task,
  onDelegate: async (subtask) => {
    const specialist = selectAgent(subtask.type);
    return await specialist.execute(subtask);
  }
});

3. Shared Context

Agents should be able to share context through:

  • Shared memory - Common context object
  • Message passing - Inter-agent communication
  • Coordinator - Central state management
const sharedContext = new SharedContext();

const agent1 = await client.createSession({
  context: sharedContext,
  role: "agent1"
});

const agent2 = await client.createSession({
  context: sharedContext,  // Same shared context
  role: "agent2"
});

Implementation Tasks

  • Design multi-agent frontmatter syntax
  • Implement agent lifecycle management
  • Add coordination patterns (parallel, sequential, hierarchical)
  • Implement shared context mechanism
  • Add inter-agent communication
  • Create agent templates library
  • Implement resource limits per agent
  • Add agent-level metrics and logging
  • Update documentation with patterns
  • Create example multi-agent workflows

Example Workflows

1. Comprehensive PR Review

agents:
  - id: code-quality
    prompt: "Review code quality and suggest improvements"
  - id: security
    prompt: "Check for security vulnerabilities"
  - id: performance
    prompt: "Identify performance bottlenecks"
  - id: tests
    prompt: "Verify test coverage and quality"
  - id: coordinator
    coordinator: true
    prompt: "Synthesize all feedback and create actionable review"

2. Multi-Repo Refactoring

agents:
  - id: discovery
    prompt: "Identify all repos affected by API change"
  - id: repo-agents  # Dynamic set based on discovery
    template: per-repo
    prompt: "Update {{repo}} to use new API"
  - id: coordinator
    prompt: "Coordinate PRs and ensure compatibility"

Success Criteria

  • Multi-agent syntax in frontmatter
  • Agent lifecycle management working
  • At least 3 coordination patterns implemented
  • Shared context mechanism functional
  • Example multi-agent workflows
  • Performance testing (resource usage)
  • Documentation with design patterns

Performance Considerations

  • Concurrency Limits - Max N agents simultaneously
  • Resource Allocation - Memory/CPU per agent
  • Token Budgets - Fair distribution across agents
  • Timeout Management - Individual vs total timeouts

Security Considerations

  • Agent Isolation - Agents shouldn't interfere with each other
  • Permission Boundaries - Each agent has own permissions
  • Context Sanitization - Shared context must be sanitized
  • Audit Trail - Track which agent performed which actions

References

  • Multi-agent system design patterns
  • Actor model for concurrency
  • Coordination protocols

Priority: Medium - Advanced capability
Estimated Effort: 10-14 days
Dependencies: #10155 (POC), #10156 (session design), #10157 (event handling)
Skills Required: Distributed systems, concurrency, TypeScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions