todo: close the spawning endpoint

Both modes verified against the live server, not reasoned about.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-23 05:02:45 +00:00
co-authored by Claude Opus 5
parent 66234cd3e0
commit 9b0376ec39
@@ -1,8 +1,8 @@
--- ---
id: sub-agents/an-api-endpoint-for-spawning-an-agent-with-a id: sub-agents/an-api-endpoint-for-spawning-an-agent-with-a
title: "An API endpoint for spawning an agent with a prompt" title: 'An API endpoint for spawning an agent with a prompt'
theme: sub-agents theme: sub-agents
status: open status: done
created: 2026-08-21 created: 2026-08-21
date_source: stated date_source: stated
order: 1 order: 1
@@ -28,7 +28,6 @@ what Officer fixes.
optional.** An endpoint that spawns freely is exactly how a weekly limit gets spent by something nobody optional.** An endpoint that spawns freely is exactly how a weekly limit gets spent by something nobody
was watching. was watching.
--- ---
**2026-08-21, narrowing this considerably.** The endpoint largely exists: **2026-08-21, narrowing this considerably.** The endpoint largely exists:
@@ -43,3 +42,28 @@ already respects the window.
What is genuinely left is the SURFACE an agent can call — MCP tool or authenticated route — and how output What is genuinely left is the SURFACE an agent can call — MCP tool or authenticated route — and how output
returns to the caller. That is the remaining work on this item; the mechanism underneath it is done. returns to the caller. That is the remaining work on this item; the mechanism underneath it is done.
---
**Closed 2026-08-23.** `POST /api/sub-agents/spawn` — prompt, optional cwd and model, and either the session
key immediately or the result if you ask it to wait. `GET /api/sub-agents/budget` answers whether there is
room without consuming any.
Verified both modes against the live server rather than reasoned about: the synchronous call returned the
four words the agent was told to say, and the async call returned in milliseconds with the agent's file on
disk five seconds later.
Three things settled while building it, each worth not re-deriving:
- **The budget check is a precondition, not a refinement.** It runs before the spawn and refuses 429 naming
the window. `checkBudget()` already existed and was already tested, which is the only reason this was a
short job.
- **`confined`, and true on the day it shipped.** The registry test's own comment records that `chat` sat on
that list for a day before its turns actually ran as the member. This one inherits the mechanism rather
than claiming it — `chatIdentity` off the token, `member: { osUser, home }` to the sidecar — and no path in
the endpoint chooses a directory.
- **`member` is passed explicitly, never omitted.** The field is required-but-may-be-undefined on purpose:
optional let a call site forget it, and forgetting it means a member's agent running as the owner in the
owner's home.
What it deliberately is not: a queue, a supervisor, or a retry. One call starts one agent.