Skip to content

Teams autopilot

The team autopilot turns a Hive team's leader from a vanilla CLI agent PTY into an orchestrator that can spawn workers, broadcast tasks, collect results, and complete the team - all from within the leader agent's own loop, driven by a skill file the daemon drops into the team's working directory plus a small set of hive team subcommands the agent invokes via its Bash tool.

There is no MCP server, no Anthropic SDK linkage, and no hived-side LLM loop. The agent stays in charge; the daemon exposes a deterministic CLI surface and the skill teaches the agent how to use it.

Mechanism

  1. Skill materialisation at team creation. When the daemon spawns the leader PTY (and again on each worker spawn) it writes - idempotently, using a hash-sidecar pattern so user edits are preserved:
    • For Claude sessions: .claude/skills/hive-team/SKILL.md, .claude/skills/hive-team/coordinator.md, and .claude/settings.json to pre-approve Bash(hive team *) and wire a Stop hook calling hive internal stop
    • For Codex sessions: .codex/skills/hive-team/SKILL.md and .codex/skills/hive-team/coordinator.md
    • .hive/team.json - read-only daemon-owned snapshot of team state for shell-fork resilience
    • .hive/<file>.sha256 sidecars for each managed file
  2. Identity bootstrapping. The PTY's env is populated with HIVE_TEAM_ID, HIVE_SESSION_ID, HIVE_TEAM_ROLE (leader | worker), HIVE_DAEMON_SOCKET. After PTY readiness a single __HIVE_BOOTSTRAP__:{json} line is injected so the skill can confirm wiring on the first turn.
  3. Asymmetric channels. Daemon → agent uses PTY-injected __STATUS__:{json} lines for relayed messages. Agent → daemon uses the hive team CLI only - never stdout sentinels. This is the single most important rule; the failure mode of letting agents write sentinels is universal across surveyed projects.
  4. Outbox persistence. Every relayed message is written to a team_outbox(team_id, session_id, seq, payload, delivered_at) row in the daemon's SQLite before PTY injection, so a worker that wasn't attached can replay missed messages with hive team inbox --since <seq>.
  5. Sync primitives. Three vocabulary verbs lifted from AWS CAO's orchestrator design:
    • hive team handoff - spawn worker + block until report
    • hive team assign - spawn worker, return immediately
    • hive team send - fan-out or DM via the existing relay path
  6. Completion via Stop hook. Claude's Stop hook fires when the worker's agent loop ends. It calls hive internal stop, which reads the env-derived identity plus the transcript path from the hook payload on stdin (or --transcript when passed explicitly) and issues ReportWorkerResult{success: true}. The leader's hive team wait unblocks. No stdout sentinels, no idle heuristic - the deterministic signal the harness already provides. Codex sessions now get the same hive-team orchestration skill, but not this automatic exit hook yet.

CLI surface

CommandPurpose
hive team handoff <team> <worker-name> --prompt <p>Spawn worker, block until it reports, print result
hive team assign <team> <worker-name> --prompt <p>Spawn worker, return immediately
hive team send <team> [--to <id>|--broadcast] --message <s>DM or fan-out
hive team inbox <team> [--since <seq>]At-least-once inbox replay; NDJSON
hive team workers <team>Roster + status per worker
hive team report <team> --success|--failure [--result <s>]Worker-side result reporting (≤4 KB)
hive team complete <team> [--result <s>]Leader marks team done
hive team wait <team> [--for <ids>] [--timeout 60] [--wait-id <id>]Bounded block with resume token
hive team statusPrint env-derived identity and team summary

Workers default to a fresh git worktree under .hive/worktrees/<worker-id> rooted in the leader's working_dir. Hard worker cap: 5 per team.

Cross-references

Hive - remote AI coding agents over WebSocket.