← All Patterns

Motivation

The K9-AIF Squad executes agents sequentially — the right model for dependent steps. But many workflows contain independent work units that do not need to wait on each other: generating 20 scaffold files, extracting independent data slices, validating a transaction across multiple systems simultaneously.

Sequential execution in these cases is pure waste. The Sub-Agent Pattern introduces K9AgentSpawner — a parent agent that spawns lightweight ChildAgents in parallel, sequential, or tree mode, then merges their results. The Squad sees one agent. The spawning is entirely encapsulated.

Structure

Key Concepts

K9AgentSpawner ChildAgent ChildRegistry K9TransactionAgent K9Newfoundland spawn_parallel spawn_sequential merge_results 2-Phase Commit No-orphan guarantee

Used in K9-AIF

K9AgentSpawner ChildAgent K9TransactionAgent K9Newfoundland K9X StudioX — ScaffoldGenerationSquad K9X StudioX — SpecParserAgent