80 lines
7.4 KiB
Markdown
80 lines
7.4 KiB
Markdown
# Spawning agents in Claude Code
|
|
|
|
Harness mechanics: dispatch, resume, fork. Other harnesses: own `spawning-<harness>.md` when needed.
|
|
|
|
Status per claim, with date:
|
|
|
|
- **verified**: read from the tool schema text that date; not runtime-tested unless the row says so.
|
|
- **observed**: seen in real runs, source given; mechanism may be assumed.
|
|
- **assumed**: inferred, unchecked; a hypothesis.
|
|
- **unknown**: open; check before relying on it.
|
|
|
|
A claim fails: fix it here with a new date.
|
|
|
|
## Rules of thumb
|
|
|
|
Owner of the harness rules; Igor, Zathras and the Athanor point here.
|
|
|
|
- **Foreground for sequential work.** Next step depends on the result: `run_in_background: false`. Background `Agent` children only for independent leaves whose result may go to the session root. Background Bash is fine for gremlins (it notifies the subagent that started it).
|
|
- **No process matching by pattern.** Never `pgrep -f`, `pkill -f`, `killall` (a `-f` wait loop matches itself). Wait in the foreground; stop only a recorded PID, or `TaskStop` the recorded task.
|
|
- **Resume only from the session root.** Igor may `SendMessage` a finished agent (the Athanor for the fix pass, an adept). A subagent never resumes its own children; it dispatches fresh foreground agents.
|
|
- **Pinned agents: omit `model`.** The per-call alias overrides the frontmatter pin. Override only on purpose, noted in the journal or run log.
|
|
- **Unpinned agents: pass `model`.** Omitted, they inherit the caller's model, possibly Fable.
|
|
- **Stamp the model id.** Every agent reads its exact id from its system prompt and writes it into its output.
|
|
- **Leaf briefs say "do this yourself; do not dispatch further agents."** Only orchestrators (the Athanor) fan out.
|
|
- **Notifications report a turn ending, not a job finishing.** Read the result text before concluding. Check `ListAgents` before resuming.
|
|
|
|
## Dispatch and notification
|
|
|
|
| Claim | Status |
|
|
|---|---|
|
|
| `Agent` calls default to background; `run_in_background: false` runs foreground and returns the result to the caller. | verified 2026-10-05 (Agent tool schema) |
|
|
| Background **Agent-tool** children of a subagent notify the **session root**, not their parent; the parent sees nothing and stalls until the root feeds it the result. | observed 2026-09-24 and 2026-09-28 (spacecraft journals), re-observed 2026-10-21 (dirigent, installed 0.3.0 at 544b69c, version confirmed) and in the ai-developer HI-495/497 runs. Mechanism assumed. |
|
|
| Background Bash started by a subagent notifies that subagent, not the root. | observed 2026-10-21 (5x), plus the dirigent V1 wake probe |
|
|
| A turn-end can look like a hand-back while background work runs. The line `waiting on <job ids>; not a hand-back` (see `athanor.md`) means not done. | observed 2026-10-21 (A3, 6x) |
|
|
| An agent that hands work to a background child and yields notifies `completed` at once, before any deliverable exists. Expect one more notification per background grandchild, each with its own `task-id`. | observed 2026-09-22 (Spire harness notes) |
|
|
| One `task-id` may notify more than once (once per turn). Track the deliverable, not the count. | observed 2026-09-22 |
|
|
| Background Agent-tool grandchildren appear in `ListAgents` as flat top-level agents of the session. One still writing your output path: do not resume its parent (second writer). Abandoning it: `TaskStop` the child first. | observed 2026-09-22 |
|
|
| `TaskList` is the todo list, unrelated to agents. `TaskOutput` on an agent dumps its whole transcript into your context; never use it for agents. | observed 2026-09-22 |
|
|
| A `general-purpose` agent has the Agent tool and delegates if its brief reads like an orchestration brief. | observed 2026-09-22 |
|
|
| Once auto mode ends, a child's hand-back may wait on permission (`SubagentHandback` refused): idle, not hung. Before a long or overnight step: keep auto mode on, defer it with a journal note, or warn the user. | observed once 2026-10-21 (ai-developer bundle D); what the refusal blocks is unverified |
|
|
|
|
## Resume
|
|
|
|
| Claim | Status |
|
|
|---|---|
|
|
| `SendMessage` to a finished agent's name or id resumes it, context intact. A new `Agent` call starts fresh. | verified 2026-10-05 (Agent tool schema) |
|
|
| A resume from inside a subagent runs in the background; its completion goes to the root and the subagent stalls. From the root (Igor) it is safe: the notification lands there. | observed once 2026-10-05 (spacecraft journal: orchestrator resumed its implementer via SendMessage, went background, yielded). Mechanism assumed from the routing above. |
|
|
|
|
## Models
|
|
|
|
| Claim | Status |
|
|
|---|---|
|
|
| Per-call `model` accepts aliases only (`opus`, `sonnet`, `haiku`, `fable`) and overrides the agent definition's `model` frontmatter. | verified 2026-10-05 (Agent tool schema) |
|
|
| `model` omitted: a pinned agent runs on its pin; an unpinned agent inherits the caller's model unless a default subagent model is configured. | verified 2026-10-05 (Agent tool schema) |
|
|
| A full model id (e.g. `claude-opus-5-5`) is settable only in agent frontmatter; pinning by full id = a pinned agent dispatched without `model`. | verified 2026-10-05 (follows from the alias-only parameter) |
|
|
| The `opus` alias overrode 4.6 pins in 184 of 184 spawns (they ran on 5.5). | observed 2026-09-27 (spacecraft MVP retrospective) |
|
|
| A 4.6 Igor passing `model: "opus"` to the then 4.6-pinned Athanor got a 4.6 run (the dirigent end review that passed with zero findings). | observed 2026-10-05 (user's attribution; the dirigent report recorded the model as unknown). |
|
|
| What the `opus` alias resolves to (caller's model, a session default, or newest Opus). | unknown. Check the stamped id of every plan, attack and review instead. |
|
|
| Every agent sees its exact model id in its system prompt. | observed 2026-10-05 for general-purpose agents (prompt shows `claude-opus-5-5`); not checked for plugin agents with their own bodies |
|
|
| Context window of bare `claude-opus-5-5` pin vs `[1m]` suffix (other Spire pins carry `[1m]`). | resolved 2026-10-05: all Opus-pinned Spire agents (igor, adept, athanor, zathras) pinned to `claude-opus-5-5[1m]` (user decision); the ~600k guesstimate in `models.md` assumes the larger window |
|
|
|
|
## Fork
|
|
|
|
Not used by Spire since 2026-10-16 (trunk + gremlins replaces it); rows kept as harness record.
|
|
|
|
| Claim | Status |
|
|
|---|---|
|
|
| The Agent tool schema documents `subagent_type: "fork"`: a fork always inherits the caller's model; `model` is ignored. | verified 2026-10-05 (schema text) |
|
|
| `fork` is actually offered as an agent type in a given session. | unverified: the schema mentions it, but on 2026-10-05 it was not in the list of agent types offered to the reviewer |
|
|
| A fork copies the **caller**, not an arbitrary agent; only the agent holding a context can fork it. | assumed (no parameter names a fork source) |
|
|
| A fork starts with the caller's full transcript, at the caller's token count. | assumed, not measured |
|
|
| Can a fork fork again? Does a foreground fork return its result to the caller? Does it see the caller's preloaded skills? | unknown; check in a throwaway preflight before relying on forks |
|
|
|
|
## Agent types
|
|
|
|
| Claim | Status |
|
|
|---|---|
|
|
| Plugin agent types (`athanor`, `adept`, `researcher`, …) can be missing in remote sessions, where `/reload-plugins` is unavailable. Fallback: `general-purpose` with an explicit `model` and the agent file's body pasted into the brief. | observed 2026-10-05 (reliquary Igor journal, 21:00) |
|
|
| `Explore` and `Plan` are read-only (no Edit/Write); never use them for tasks that must write a file. | observed 2026-09-22 (Spire model tiers) |
|