Skip to content

fix(subagent): wake an idle parent when a background lane settles - #230

Merged
Uking-xxx merged 3 commits into
mainfrom
fix/subagent-lane-wake
Oct 10, 2026
Merged

Uking-xxx merged 3 commits into
mainfrom
fix/subagent-lane-wake

Conversation

@Uking-xxx

Copy link
Copy Markdown
Collaborator

Problem

Start a few background subagents (run_in_background: true) and tell the parent to wait and report. The lanes finish, their completion entries show up in the transcript, and then nothing happens: the parent never reports.

The session log shows the parent's last turn ending (stop) right after it started the lanes. Every notification that arrived afterwards was appended to the session without starting a turn, including all four background_done events.

Lane notifications were sent with { deliverAs: "steer" } only. In AgentSession.sendCustomMessage, a steer reaches the model only while the parent is streaming; when the parent is idle and triggerTurn is unset, the message is just appended. Background lanes almost always settle while the parent sits idle waiting on them, so the model never read the result until the user typed again. Cron already sends { deliverAs: "steer", triggerTurn: true } and doesn't have this problem.

Change

notifyLaneEvent now sets triggerTurn per event:

Event Wakes an idle parent
background_done, background_failed, background_interrupted, background_needs_input yes
background_progress, background_restarted no; they ride along with the next turn

Progress stays non-waking on purpose: with subscribe: "progress", waking would restart the parent every 15s per lane. While the parent is mid-turn, both kinds still steer into that turn as before.

Testing

  • The existing lane-completion test now also asserts triggerTurn: true. A new test covers which events wake: progress, restarted, needs-input, and failed. Both fail on main.
  • Subagent tests 51/51; pnpm run check passes.
  • Manual tmux run from source against step-5-preview, with two background lanes (sleep 20 / sleep 30) and the parent told to wait and report. The parent woke after the first lane ("A done, waiting for B") and again after the second, then reported both results.

Related

Independent of #227 and #229. Not addressed here: progress notifications that pile up while the parent is idle all enter its context on the next turn. Dropping stale ones when a lane settles would be a separate change.

xuyunfang added 3 commits October 9, 2026 19:22
Lane notifications were sent with { deliverAs: "steer" } only. A steer
reaches the model only while the parent is mid-turn; when the parent is
idle, which is exactly when it waits on background lanes, the message is
appended and no turn starts. A parent told to "wait for the lanes and
report" therefore never saw the results until the user typed again.

Done, failed, interrupted, and needs-input events now pass
triggerTurn: true. Progress and restart notices still only ride along,
so a progress subscription does not wake the parent every 15s per lane.
Passing triggerTurn: false made AgentSession defer background_progress and
background_restarted to the end of a running turn instead of steering them
in. Leave triggerTurn unset for non-waking events so they steer mid-turn and
only append while the parent is idle.
# Conflicts:
#	packages/coding-agent/src/features/subagent/lane-events.ts
@Uking-xxx
Uking-xxx merged commit b8a26be into main Oct 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant