Skip to content

Feature request: native runSubagent / inline sub-agent tool #20172

@tore-unumed

Description

@tore-unumed

Summary

Request native support for an inline sub-agent tool (similar to VS Code Copilot's runSubagent) that allows a workflow agent to:

  1. Spawn an isolated sub-agent with a specific prompt and limited context
  2. Wait synchronously for its completion (blocking, not fire-and-forget)
  3. Receive the sub-agent's output as a return value in the parent agent's context

Motivation

Complex workflows benefit from parallelizing research across large codebases. For example, a specs-reviewer agent needs to search 12+ repositories for relevant patterns — doing this serially is slow and burns tokens on accumulated context.

In VS Code Copilot, runSubagent solves this by spawning stateless child agents that return a single result. Each sub-agent has isolated context, preventing token bloat in the parent.

Current limitations

  • dispatch-workflow: Fire-and-forget — no return values, no waiting, cannot coalesce results
  • workflow_call: Static YAML — cannot dynamically determine number/assignment of sub-tasks at runtime
  • MCP Scripts: Run on the runner host but cannot invoke the Copilot CLI because auth tokens are proxy-held and scrubbed from the agent environment
  • Confirmed: runSubagent tool is not available in the gh-aw Copilot CLI environment (tested in runs 22843694716 and 22843793775)

Proposed behavior

// Pseudocode usage inside a workflow agent
const result = runSubagent({
  prompt: "Search repos/ehr/ and repos/erp/ for all GraphQL resolvers related to billing. Return file paths and brief descriptions.",
  description: "Search billing resolvers",
  // Optional: restrict context (directories, tools, etc.)
});
// result is a string with the sub-agent's findings

Key properties:

  • Synchronous: Parent blocks until sub-agent completes
  • Isolated context: Sub-agent starts fresh, does not see parent's accumulated context
  • Returns output: Sub-agent's final message becomes the return value
  • Respects workflow config: Inherits network rules, MCP servers, permissions from parent workflow
  • Token budget: Sub-agent has its own token/continuation budget

Alternatives considered

  1. Serial execution: Works but is 3-5x slower and accumulates unnecessary context
  2. dispatch-workflow fan-out with collector: Two-phase (dispatcher → workers → collector) pattern works but is complex, requires artifact/issue/comment coordination, and adds significant latency
  3. MCP Script wrapping Copilot CLI: Blocked by the auth proxy architecture that (correctly) isolates API tokens

Environment

  • gh-aw CLI v0.56.2
  • Engine: copilot / claude-sonnet-4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions