paseo icon indicating copy to clipboard operation
paseo copied to clipboard

bug: notifyOnFinish interrupts active Codex parent turns and emits a false turn_aborted

Open tonyredondo opened this issue 4 months ago • 5 comments

What's broken

When a Paseo child agent created with notifyOnFinish: true finishes while its parent Codex agent still has an active foreground turn, Paseo interrupts and replaces the parent's current turn to deliver the child result.

Codex then records this synthetic user message:

<turn_aborted>
The user interrupted the previous turn on purpose. Any running unified exec processes may still be running in the background. If any tools/commands were aborted, they may have partially executed.
</turn_aborted>

The user did not interrupt the turn.

Because this is persisted with role: "user", the parent agent can interpret it as an explicit stop request. In observed runs, the agent stopped an ongoing review, closed its remaining child agents, and reported:

I stopped because the system explicitly marked the previous turn as turn_aborted and, according to the active instructions, I had to treat it as an order to stop.

This happened repeatedly during the same review as different child agents finished.

Expected behavior

A child-agent completion notification should not cancel or replace the parent's active foreground turn.

The result should be delivered through an out-of-band event, provider-supported steering mechanism, or another mechanism that preserves the active parent turn.

Actual behavior

The finish notification interrupts the active parent turn, starts a replacement turn containing <paseo-system>, and leaves a false turn_aborted record claiming that the user intentionally interrupted the work.

Impact

  • Long-running parent tasks stop unexpectedly.
  • In-progress reasoning or tool execution can be lost.
  • Remaining child agents may be canceled because the parent believes the user requested a stop.
  • Multiple children finishing at different times can repeatedly interrupt the parent.
  • The transcript incorrectly attributes the interruption to the user.

Steps to reproduce

  1. Enable Inject Paseo tools.
  2. Start a Codex parent agent.
  3. Have the parent create a background child agent with the default notifyOnFinish: true.
  4. Keep the parent foreground turn active while the child works.
  5. Let the child finish.
  6. Inspect the parent Codex rollout JSONL.
  7. Observe that:
    • the active parent turn receives turn_aborted;
    • a replacement turn starts;
    • the replacement turn receives <paseo-system> Agent ... finished;
    • the parent may treat the synthetic abort as an explicit user stop.

This is timing-dependent: it occurs when the child finishes while the parent still has an in-flight turn. If the parent is already idle, no active turn needs to be replaced.

Where did this happen

Daemon

Paseo version

0.1.107

OS version

macOS 26.5.1

Agent provider

Codex

Provider configuration

  • Codex CLI: 0.144.1
  • Provider process: codex app-server --enable goals
  • Daemon Node.js: 26.5.0

Logs

## Raw timeline evidence

Minimal excerpt from the Codex rollout JSONL. Agent IDs, turn IDs, child title, and child response were redacted; timestamps and event ordering are unchanged.


{"timestamp":"2026-07-11T10:07:31.626Z","type":"response_item","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"<turn_aborted>\nThe user interrupted the previous turn on purpose. Any running unified exec processes may still be running in the background. If any tools/commands were aborted, they may have partially executed.\n</turn_aborted>"}]}}
{"timestamp":"2026-07-11T10:07:31.632Z","type":"event_msg","payload":{"type":"turn_aborted","turn_id":"<redacted>","reason":"interrupted"}}
{"timestamp":"2026-07-11T10:07:31.648Z","type":"event_msg","payload":{"type":"task_started","turn_id":"<replacement-turn-id>"}}
{"timestamp":"2026-07-11T10:07:32.559Z","type":"response_item","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"<paseo-system>\nAgent <child-agent-id> (<redacted-title>) finished.\n\n<agent-response>\n<redacted>\n</agent-response>\n</paseo-system>"}]}}


The same sequence occurred again approximately two minutes later when another child finished:


2026-07-11T10:09:53.508Z  synthetic <turn_aborted> user message
2026-07-11T10:09:53.513Z  turn_aborted event
2026-07-11T10:09:53.533Z  replacement task started
2026-07-11T10:09:54.353Z  <paseo-system> child-finished notification

Screenshots or video

Image

tonyredondo avatar Jul 13 '26 08:07 tonyredondo

Keeping this open as a current P1 bug. The report provides repeatable Codex rollout evidence from Paseo 0.1.107 showing that a child finish notification interrupts an active parent turn and records a false user abort.

Current main still routes finish notifications through the shared prompt path, where an in-flight parent run selects replacement and interruption. PR #2068 made rejected cancellations preserve the active turn, but it did not change this replacement behavior. The later PR #2662 also explicitly leaves this Codex replacement-policy issue separate and unchanged.

This issue remains scoped to delivering notifyOnFinish to an active Codex parent without interrupting its foreground turn or attributing an abort to the user.

paseo-bot avatar Jul 31 '26 00:07 paseo-bot

This reproduces on the Claude provider too (Paseo 0.4.0, Linux daemon, Claude agent via the Agent SDK) — same mechanism, different false attribution.

Setup: a long-running Claude parent (a sprint coordinator) with several notifyOnFinish: true children. Three times in one session, a child finished while the parent had a Bash tool call in flight. Each time the notification delivery interrupted the call, and on Claude the transcript records the SDK's canned permission-denial as the tool result:

The user doesn't want to proceed with this tool use. The tool use was rejected (…) STOP what you are doing and wait for the user to tell you how to proceed.

plus a [Request interrupted by user for tool use] marker — while the session was running bypassPermissions, so no permission prompt could even exist, and the operator confirmed they weren't interacting. The correlation was 3/3: every rejection arrived in the same delivery as a <paseo-system> child-finished message; nothing similar ever happened outside one.

The behavioural fallout mirrors the Codex report — the parent obeys the "STOP and wait" text and halts a fleet of otherwise-healthy children — with one extra hazard worth noting for investigation: the interrupted tool call can have already fully executed with its output discarded. In one occurrence the "rejected" command was a gh pr merge chain; the merge, an issue closure, and several file writes had all completed, only the final step and all output were lost. So the synthetic message is wrong twice: no user interrupted, and "was rejected / NOT written" can be false for every side effect that ran before the interrupt landed.

Agreeing with the expected behaviour in the report: on Claude specifically, delivering the notification as a queued/steered message into the active turn (rather than an interrupt-and-replace) would avoid both the false rejection and the discarded-result ambiguity.

roman-yakobnyuk avatar Aug 21 '26 04:08 roman-yakobnyuk

Third provider reproduction: OMP (Oh My Pi) + zai glm-5.3-flash, macOS daemon. Same mechanism as the Codex/Claude reports, plus a compounding propagation hazard this issue doesn't cover yet.

Setup: dispatcher (top-level) → create_agent implementer (notifyOnFinish: true) → implementer spawns two reviewer agents (also notifyOnFinish: true) and waits inside an active turn (sleep / hub-wait loops).

Evidence (implementer rollout JSONL, 2026-08-30, one of 10+ occurrences across four independent tickets):

05:04:42.889  assistant stopReason="aborted" errorMessage="Interrupted by user"
05:04:43.008  <paseo-system> Agent … (Spec review) finished
05:07:33.165  assistant stopReason="aborted" errorMessage="Interrupted by user"
05:07:33.281  <paseo-system> Agent … (Standards review) finished
05:08:20      session continues normally (applies findings, edits, commits)

Every Interrupted by user abort is followed 100–200 ms later by a child-finished <paseo-system> message; the session itself is healthy and keeps working after each one.

The compounding hazard: the interrupted implementer is itself a notifyOnFinish child, and Paseo reported the non-terminal aborted turn to its creator as a terminal error:

<paseo-system>
Agent … errored.
<agent-response>
[System Error] Interrupted by user (stopReason=aborted, model=zai/glm-5.3-flash)
</agent-response>
</paseo-system>

The grandparent dispatcher treated it as a crash, respawned a second implementer on the same worktree, and the original session was disposed mid-edit (session_exit reason=dispose) while applying review fixes — two writers on one checkout.

So the report is wrong twice for OMP: no user interrupted, and the session was not terminal, yet the error notification is emitted as terminal to the creator. Happy to attach fuller JSONL excerpts.

bingfoon avatar Aug 30 '26 08:08 bingfoon

Fourth reproduction, Claude provider on macOS, with two details that may help narrow the fix: (1) the trigger was a plain send_agent_prompt from another agent, not a notifyOnFinish callback, and (2) the interrupted MCP tool call had already executed server-side while the transcript recorded it as user-rejected.

Environment

  • Paseo 0.7.2, daemon Node v26.4.0, macOS 26.5.2 (25F84)
  • Provider claude via Claude Code 2.1.263, model claude-fable-5-1, mode bypassPermissions (no permission prompt can exist), Inject Paseo tools enabled
  • Parent = long-running orchestrator agent; peers = Codex (gpt-6-astra) agents that report to it with send_agent_prompt; children created with the default notifyOnFinish: true
  • Operator confirmed no interaction at any of the timestamps below.

Timeline (parent's Claude session JSONL, 2026-09-07, UTC; ids shortened, message bodies redacted)

20:29:31.040  assistant tool_use  mcp__paseo__archive_agent     {"agentId":"5d3eb86f-…"}
20:29:31.049  assistant tool_use  mcp__paseo__archive_workspace {"workspaceId":"wks_ec7571d5a51c74d4"}   (same assistant message, parallel calls)
20:29:31.148  user tool_result    archive_agent      {"success":true}
20:29:33.398  user tool_result    archive_workspace  is_error=true
              "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a
               file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the
               user to tell you how to proceed."
20:29:33.399  user text           [Request interrupted by user]
20:29:33.413  user text           [FE→ORQ] …   ← send_agent_prompt from a Codex peer agent, delivered 14 ms later

Then, a few minutes later, when the operator asked to retry:

mcp__paseo__archive_workspace {"workspaceId":"wks_ec7571d5a51c74d4"}
→ "Workspace not found: wks_ec7571d5a51c74d4"

ls of the worktree path, git worktree list and paseo workspace ls all confirmed the workspace was already gone. So the archive did run; only its tool result was replaced by the synthetic denial. The parent then told the operator "you refused the archive, I stopped" — the same false attribution as the Codex turn_aborted case, but here it also misreports the effect of an action that actually happened.

Two milder occurrences in the same session (no tool call in flight)

19:03:17.460  user tool_result  (Bash, complete)
19:03:42.578  user text         [Request interrupted by user]
19:03:42.595  user text         [FE→ORQ] …            ← send_agent_prompt from peer

20:00:09.576  user tool_result  (Bash, complete)
20:00:12.848  user text         [Request interrupted by user]
20:00:12.857  user text         [FE→ORQ] …            ← send_agent_prompt from peer

Here the active turn was replaced (the [Request interrupted by user] marker is recorded) but no tool result was corrupted because none was pending. Correlation in this session: 3/3 interruption markers arrived in the same delivery as an inbound prompt; none happened otherwise.

Observations

  • The replacement policy fires for any inbound prompt to a busy agent (peer send_agent_prompt, child finish, presumably schedules), not only notifyOnFinish.
  • On the Claude harness the interruption of an in-flight tool call is surfaced as the SDK's canned permission denial. Because that text is an imperative ("STOP … wait for the user"), an orchestrator obeying it can freeze a whole fleet, and because the underlying MCP call may have completed, it can also report a wrong world state.
  • Expected: inbound prompts to a busy agent should be queued until the active turn (at minimum, the pending tool call) completes, or delivered as an out-of-band event; a synthetic permission denial should never be written as a tool result.

Happy to share the full redacted JSONL excerpt if useful.

pmilanez avatar Sep 07 '26 20:09 pmilanez

Codex child-finish notifications now use active-turn steering on main (change). If that original Codex notification still interrupts a turn, please reopen with current app/daemon and Codex versions and the matching rollout excerpt.

boudra avatar Sep 08 '26 00:09 boudra