Skip to content

Commit 18afb2b

Browse files
author
cloudj
committed
refactor: aborting the parent no longer pauses its children
An abort is most often the user interjecting. Pausing every child as a side effect needed admission closure, an interruption epoch, a prompt handshake that could delay or swallow user input, and a reminder turn to undo the pause again. Aborting now stops only the parent. Children keep running, and their replies wait for the next user prompt instead of waking what was just stopped. Pausing is always explicit; the global /sub:pause pauses every child and aborts the parent. pi-sub no longer watches abort signals, aborts parent runs or handles user input on the parent's behalf. Revises ADRs 0002 and 0003.
1 parent 0a93e83 commit 18afb2b

11 files changed

Lines changed: 179 additions & 569 deletions

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ A wait only observes. It ends with a reply or failure, when its task pauses, at
5656

5757
Replies and failures arrive on their own. At the next safe turn boundary, or once when the parent is idle, pi-sub batches unannounced ones into one message; a complete tool return already counts as delivery. Large reports and batches are handed off as a reference to a private temporary file instead of being clipped. These files expire on session switch, fork, reload or shutdown, so preserve relevant findings before leaving the session.
5858

59-
## Interrupt and continue
59+
## Pause and continue
6060

61-
An **interrupt** pauses all children and closes admission until the next user prompt. Aborting an active parent run, for example with Escape, is an interrupt. While the parent is idle, Escape keeps its native meaning; use `/sub:pause`. A new user prompt resumes only the parent, which decides which children to continue. If it would finish while children paused by its abort are still paused, it is reminded once.
61+
Aborting the parent, for example with Escape, stops only the parent. Children keep running; their replies wait and do not wake the parent until your next prompt. To stop children, pause them:
6262

6363
```text
6464
/sub:pause [task-id]
6565
/sub:continue [task-id]
6666
/sub:stop [task-id]
6767
```
6868

69-
No ID means all applicable tasks; `/sub:pause` without an ID is the global interrupt. In RPC, send `prompt("/sub:pause")`: an idle RPC `abort` emits no extension event.
69+
No ID means all applicable tasks. `/sub:pause` without an ID stops everything: it pauses every child and aborts the parent. Paused children stay paused until `/sub:continue`, a `sub_control` continue or a message. In RPC, send `prompt("/sub:pause")`.
7070

7171
Pausing terminates the process (SIGTERM, then SIGKILL) and continuation restarts it on the same session. It does not undo writes or external effects.
7272

‎docs/decisions/0002-process-lifetime-and-interruption.md‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A subagent is an assignment with one native Pi session. Each execution is a fres
99
```text
1010
queued -- admission --> active -- reply or failure + process exit --> ready(reply | error)
1111
| | |
12-
| interrupt | interrupt + process exit +-- message --> queued
12+
| pause | pause + process exit +-- message --> queued
1313
v v +-- accept or stop --> removed
1414
paused <-----------------+
1515
+-- explicit continue --> queued
@@ -19,14 +19,13 @@ Reply/error/stopped are outcomes, not additional states. Retries and automatic c
1919

2020
A failure is the outcome of one execution, not the end of its task. A crash, a non-zero exit, a provider error or a missing response leaves the journal as an interruption does, so the task stays open: a message continues its session and resends input the journal does not prove. Admission failures are the same; nothing ran. Only a lost session is final: a journal that is corrupt, rewritten, substituted or gone after it was observed. Such a task rejects input and can only be read, accepted or stopped. A journal that never existed loses nothing, so a first start may repeat. Nothing retries on its own: the parent receives the failure like a reply and decides.
2121

22-
Active redirection retains the correction, interrupts the old process, waits for closure and final capture, then queues a new process on the same session. It never injects input into a busy native session. An interrupt between these steps prevents restart and retains the correction. Only new saved native user entries prove input persistence, not streamed message events emitted before the write. Instructions without that evidence are retained after interruption or failure; transformed inputs may be conservatively replayed.
22+
Active redirection retains the correction, interrupts the old process, waits for closure and final capture, then queues a new process on the same session. It never injects input into a busy native session. A pause between these steps prevents restart and retains the correction. Only new saved native user entries prove input persistence, not streamed message events emitted before the write. Instructions without that evidence are retained after interruption or failure; transformed inputs may be conservatively replayed.
2323

24-
The controller accepts two user inputs:
24+
Aborting the parent stops the parent. Its children are separate work and keep running: an abort is most often the user interjecting, and stopping work as a side effect would have to be undone by someone. The coordinator therefore holds no interruption state, closes no admission and never delays, cancels or aborts user input or a parent run.
2525

26-
- **Interrupt:** block admission first, pause queued tasks, then terminate active processes. Request native SIGTERM shutdown, escalate to SIGKILL on a bounded deadline and await exit. Failed termination retains ownership and its slot for retry and is reported to the caller; not exiting in time says nothing about the work and is not an outcome of the task. Later replies cannot restart an interrupted parent.
27-
- **Prompt:** before forwarding real interactive/RPC input, wait for pauses in flight to settle or give up, then reopen admission but leave paused tasks paused. An intervening interrupt cancels the prompt. No process state holds user input beyond that bounded wait. Explicit operator continue commands use the same preparation.
26+
One consequence is kept: an aborted parent stays stopped. Replies and failures that arrive afterwards wait in the inbox and do not wake it until real interactive or RPC input, or an operator continue. They join that run at its boundaries.
2827

29-
Aborting the parent is an implicit interrupt: it stops everything, but need not mean the children should rest. If the parent's next completed run would settle while such tasks are still paused, it is told once and gets one more request to continue or stop them. The global `/sub:pause` is an explicit decision and raises nothing. The reminder lives in coordinator memory, not in native history.
28+
Pausing is always explicit, for one task or for all. It requests native SIGTERM shutdown, escalates to SIGKILL on a bounded deadline and awaits exit. Failed termination retains ownership and its slot for retry and is reported to the caller; not exiting in time says nothing about the work and is not an outcome of the task. A paused task stays paused until it is continued or messaged. The global `/sub:pause` is the one command that stops everything: it pauses every task, aborts the parent and holds replies like an abort does.
3029

3130
Replies and failures await an explicit parent decision, not an idle process. Delivery is independent of that decision: a complete handoff (text or the saved-file reference; see [0007](0007-file-backed-handoffs.md)) in the parent's native context is acknowledged by its reply identity and folds its widget row without removing the task. Proposing or announcing a batch without delivery into model context does not acknowledge the reply; an older delivery cannot acknowledge a successor. A new execution produces a fresh reply identity. Accepting or stopping removes the live task and retains a complete idempotent result receipt without workers, promises or listeners for the coordinator's lifetime. Receipts, including responses and pending input, are not bounded in count or size.
3231

@@ -38,7 +37,7 @@ Process exit is decisive for execution lifetime, not success or semantic task co
3837

3938
Continuation restores saved native history and issues another request. It does not resume an interrupted request, retain extension memory, roll back side effects or guarantee exactly-once actions. The coordinator retains an observed native journal identity across executions. A missing journal, changed identity or detected corruption fails explicitly and finally rather than silently becoming a new session. Identity and structural checks do not prove complete history: valid truncation or substitution retaining the same identity between executions may go undetected. Interruption before any journal was created still permits a genuine first start.
4039

41-
Bare RPC `abort` has no extension event when the parent is idle. Raw TUI input precedes focused components, so an extension cannot tell an idle interrupt from Escape closing a selector, dialog or autocomplete menu. The idle global interrupt is therefore `/sub:pause`; active parent runs additionally use abort signals and `agent_settled.aborted`. Compaction has its own public signal. No parent RPC transport interception or SDK patch is introduced.
40+
An abort is observed only as `agent_settled.aborted`. Bare RPC `abort` has no extension event when the parent is idle, and raw TUI input precedes focused components, so an idle Escape cannot be told from one closing a selector, dialog or autocomplete menu: an idle parent has nothing to stop, and replies wake it as usual. No abort signals are watched, and no parent RPC transport interception or SDK patch is introduced.
4241

4342
## Rationale
4443

‎docs/decisions/0003-messages-not-child-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Native JSON/print execution has no interactive UI. Its public defaults return `f
1414

1515
Keep operating guidance in one stable system-prompt section and operation-specific tool contracts. Replace that section when context changes rather than appending tutorials to replies. The section holds no task state and changes only with the ladder or native availability: providers cache the prompt as a prefix, and some resend the whole conversation uncached when it changes. Task state reaches the parent as conversation: tool results and replies, each carrying its task's identity. Nothing restores identities a compaction summary dropped; the widget and the operator commands still reach every task. Notifications carry identity and new information only. TUI reply previews are compact and expandable without reducing the model-visible delivery. The parent uses routine reports internally and does not acknowledge historical deliveries again.
1616

17-
Ready tasks are the reply inbox, not a second queue of frozen reports. A failure is handed off through the same inbox as an answer, names its cause and wakes an idle parent; it has no separate notice or cleanup path. At native turn boundaries, batch the current unannounced replies into one persisted custom message. Complete tool returns suppress redundant announcements before the next request, while native history prevents repeated announcements. Natural continuation satisfies the batch's continuation request; it does not add a second turn. Coalesce idle arrivals once per event-loop turn, without polling or a debounce delay. Interruptions suppress wakeups; native dialogs defer delivery until they close. Oversized batches use one file-backed handoff ([0007](0007-file-backed-handoffs.md)). Delivery remains reply-specific and separate from reading or task acceptance.
17+
Ready tasks are the reply inbox, not a second queue of frozen reports. A failure is handed off through the same inbox as an answer, names its cause and wakes an idle parent; it has no separate notice or cleanup path. At native turn boundaries, batch the current unannounced replies into one persisted custom message. Complete tool returns suppress redundant announcements before the next request, while native history prevents repeated announcements. Natural continuation satisfies the batch's continuation request; it does not add a second turn. Coalesce idle arrivals once per event-loop turn, without polling or a debounce delay. An aborted parent is not woken ([0002](0002-process-lifetime-and-interruption.md)); native dialogs defer delivery until they close. Oversized batches use one file-backed handoff ([0007](0007-file-backed-handoffs.md)). Delivery remains reply-specific and separate from reading or task acceptance.
1818

1919
Waiting observes and must not hold the user back. A steering message reaches the parent only after its current tool calls, so it ends every wait, and no wait blocks while one is queued. A wait also ends when its task pauses: nothing more can arrive. Ended this way, a wait returns the current state, not an error, and does not accept an unfinished task. Pi announces neither the queueing nor the withdrawal of a steering message, so an open wait checks for it while one is expected. Aborting remains an interruption.
2020

0 commit comments

Comments
 (0)