subagent: make a missed continue the tool call's own error
`continue` returned "started" the instant `Claude::spawn` handed back a pid, and a resume that matched nothing only surfaced later, as an end-of-turn todo. By then the caller had moved on believing it had a running subagent. A pid is proof enough for `start`, which creates its session: the spawn succeeding is the whole story. It is not proof for a resume — claude exits non-zero a fraction of a second *after* the process exists. So `continue` now waits for the first real answer and reports a miss as its own `Err`, carrying claude's message and the directory searched. The wait ends on whichever comes first, so a successful `continue` pays no fixed delay: the turn's first non-terminal stream event settles it at about the same moment a miss's exit would have. Measured on this box: 14 runs of the driver's own invocation against a missing session took 550-1087 ms spawn to exit, and a healthy turn's first event lands at roughly 500 ms. The five-second cap is ~4.6x the slowest miss and is only ever reached by a child that neither speaks nor exits. The underway signal reads the event's kind, not its content: a missed resume is not silent — it emits a terminal `result` event and stderr before exiting — so "any sink callback" would have reported every miss as a successful start. Liveness still counts all three callbacks. The end-of-turn todo is unchanged for every failure later in the turn; the only one it no longer repeats is the miss the caller was just handed. Refs #4405
This commit is contained in:
parent
31c76ddf32
commit
6e2de33f26
5 changed files with 385 additions and 52 deletions
|
|
@ -30,9 +30,13 @@ status(name)
|
|||
interrupt(name, force?)
|
||||
```
|
||||
|
||||
`start` and `continue` return as soon as the process is confirmed
|
||||
running, not once it finishes — a completion lands as a todo
|
||||
(`get_loose_ends`), same as any other producer. Use `status` for a
|
||||
`start` and `continue` return once the turn is under way, not once it
|
||||
finishes — a completion lands as a todo (`get_loose_ends`), same as any
|
||||
other producer. `continue` takes the extra moment to confirm the resume
|
||||
actually attached, so a `continue` naming a session that isn't there
|
||||
fails the tool call outright instead of looking like it worked; the error
|
||||
says which directory it searched, which is usually the fix (pass `dir`).
|
||||
Use `status` for a
|
||||
zero-cost "is it still going" check — for a running subagent it also
|
||||
reports how long since that turn last produced output, so a few seconds
|
||||
means it's working and an age climbing into the minutes means it's
|
||||
|
|
|
|||
Loading…
Reference in a new issue