feat(FN-975): add agent spawning support for hierarchical task delegation

- Add spawn settings (maxSpawnedAgentsPerParent, maxSpawnedAgentsGlobal) to ProjectSettings type
- Implement AgentStore access and spawned agent tracking in TaskExecutor
- Add spawn_agent tool with child agent execution in isolated worktrees
- Wire up child termination on parent session end and system prompt generation
- Add comprehensive test suite (554 lines) covering spawning, limits, termination, and error handling
- Document agent spawning architecture, IPC protocol, and usage in AGENTS.md
This commit is contained in:
gsxdsm
2026-04-05 11:53:35 -07:00
parent 169acbc7a2
commit 4c5f7a5ff3
4 changed files with 868 additions and 1 deletions

View File

@@ -830,6 +830,14 @@ export interface ProjectSettings {
/** Maximum number of times the stuck-task detector can kill and re-queue a task
* before it is marked as permanently failed. Default: 3. */
maxStuckKills?: number;
/** Maximum number of child agents a single parent agent can spawn.
* Limits the fan-out per executor task to prevent resource exhaustion.
* Default: 5. */
maxSpawnedAgentsPerParent?: number;
/** Maximum total spawned agents across all parent agents in a single executor instance.
* Provides a global safety cap regardless of how many parent agents are running.
* Default: 20. */
maxSpawnedAgentsGlobal?: number;
/** Interval in milliseconds for periodic maintenance (worktree pruning, WAL checkpoint,
* orphan cleanup). 0 disables. Default: 900000 (15 min). */
maintenanceIntervalMs?: number;
@@ -962,6 +970,8 @@ export const DEFAULT_PROJECT_SETTINGS: ProjectSettings = {
autoUnpauseBaseDelayMs: 300_000,
autoUnpauseMaxDelayMs: 3_600_000,
maxStuckKills: 3,
maxSpawnedAgentsPerParent: 5,
maxSpawnedAgentsGlobal: 20,
maintenanceIntervalMs: 900_000,
autoUpdatePrStatus: false,
autoCreatePr: false,
@@ -1055,6 +1065,8 @@ export const PROJECT_SETTINGS_KEYS: ReadonlyArray<keyof ProjectSettings> = [
"insightExtractionSchedule",
"insightExtractionMinIntervalMs",
"memoryEnabled",
"maxSpawnedAgentsPerParent",
"maxSpawnedAgentsGlobal",
] as const;
export interface BoardConfig {