Skip to content
Autonomy
AGH RuntimeAutonomy

Safe Spawn

How agent-initiated child sessions are bounded by lineage, TTL, caps, workspace inheritance, and permission narrowing.

Audience
Operators running durable agent work
Focus
Autonomy guidance shaped for scanability, day-two clarity, and operator context.

agh spawn lets a managed session ask the daemon to create a child agent session. Spawn is the delegation surface for the autonomy MVP, but it is safe by default: the daemon owns lineage, TTL, caps, workspace inheritance, permission narrowing, and cleanup.

Required constraints

ConstraintBehavior
Valid parent identityThe caller must be an AGH-managed session resolved from daemon-issued identity.
TTL--ttl-seconds is required and must be positive. Spawned sessions cannot be unbounded.
Depth capThe MVP default max spawn depth is 1.
Child capThe MVP default max children per parent is 5.
Workspace inheritanceChildren inherit the parent workspace. Cross-workspace spawn is rejected in the MVP.
Coordinator role denial--role coordinator is rejected. Coordinators are daemon-managed root sessions, not child sessions.
Permission subsetChild tools, skills, MCP servers, workspace paths, network channels, and sandbox profiles must be a subset of the parent set.
Unknown atomsUnknown child permission atoms count as widening and reject the spawn.
Parent stopChildren auto-stop when the parent stops unless configured otherwise within hard caps.

The daemon rejects invalid spawn requests. It does not silently narrow a child request and continue.

Spawning a worker

agh spawn --agent reviewer --ttl-seconds 1800

Add narrowed permissions and a role when the parent has those atoms:

agh spawn \
  --agent reviewer \
  --role reviewer \
  --ttl-seconds 1800 \
  --prompt-overlay "Review only the implementation diff." \
  --tool read \
  --skill code-review \
  --channel coord-run-123

Permission flags are repeatable:

  • --tool
  • --skill
  • --mcp-server
  • --workspace-path
  • --channel
  • --sandbox-profile

The response includes the child session, lineage, and safe permission projection. It does not create or claim task work by itself.

Cleanup and active leases

The reaper wins over active leases. If TTL expiry or parent-stop cleanup terminates a spawned session, AGH first releases active task-run leases owned by that session with a structured reason, then stops the child. Stale child claim tokens cannot complete or heartbeat recovered work.

Hooks

Spawn exposes these hook events:

  • spawn.pre_create
  • spawn.created
  • spawn.parent_stopped
  • spawn.ttl_expired
  • spawn.reaped

spawn.pre_create may deny or narrow a request, but hook patches cannot widen child permissions. The daemon enforces the permission subset after hook patches.

On this page