Skip to content

feat: Nested agent composition with parent-child execution graphs #93

Description

@aecs4u

Summary

Enable agents to compose other agents as sub-tasks, forming a parent-child execution tree with result aggregation and error propagation.

Prior Art

  • AutoGPT implements nested agent composition as a core feature — agent graphs can contain "Agent Executor" blocks that run other agents as sub-steps. Parent agents receive structured results from child agents and can branch/retry based on outcomes. Supports up to 3 levels of nesting with shared context propagation.
  • Moltis has a similar concept via its multi-agent orchestration layer.
  • RustyClaw already has sessions_spawn (feat: Sub-agent / spawn_agent tool for parallel task delegation #66) for basic sub-agent delegation.

Motivation

The current sub-agent system (#66) supports spawning independent sessions, but lacks structured composition — a parent agent can't easily define "run agent A, then if successful run agent B with A's output, otherwise run agent C". Nested composition enables complex workflows like: research agent → analysis agent → report-writing agent, with the parent orchestrating the pipeline.

Proposed Design

  1. Extend sessions_spawn with composition semantics:
    struct AgentComposition {
        steps: Vec<CompositionStep>,
        error_strategy: ErrorStrategy, // Retry, Fallback, Abort
        max_depth: u8,                 // Default: 3
    }
    
    enum CompositionStep {
        Sequential(Vec<AgentTask>),
        Parallel(Vec<AgentTask>),
        Conditional { condition: String, if_true: AgentTask, if_false: AgentTask },
    }
  2. Parent agent receives structured results from each step
  3. Resource limits inherited and subdivided (budget, time, sandbox scope)
  4. Execution tree visible in TUI and gateway status

Acceptance Criteria

  • Sequential and parallel agent composition
  • Conditional branching based on sub-agent results
  • Max nesting depth enforced (default: 3)
  • Resource limits (budget, time) subdivided across children
  • Execution tree visualization in TUI

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    ecosystem-analysisFeature identified from cross-project ecosystem analysisenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions