senpi icon indicating copy to clipboard operation
senpi copied to clipboard

proposal(goal): a live resumption channel should not count toward the toolless stall streak

Open Bearmancer opened this issue 1 month ago • 2 comments

What do you want to change?

A goal continuation that ends while a resumption channel is still live (a running senpi-task child, a terminal monitor) should leave the toolless-turn streak where it was, and the streak should reset when that channel delivers. Three toolless continuations with no live channel would still inject <goal_stall_check>, as they do today.

Why?

Waiting on a child that has not finished is not a stall, but today it counts as one. #recordToollessContinuationTurn adds 1 for every toolless continuation and never looks at liveWakeSources():

https://github.com/code-yeongyu/senpi/blob/ea879a3442367445b92aa53c721a72e2850ccd24/packages/coding-agent/src/core/extensions/builtin/goal/monitor-continuation.ts#L674-L685

So after three backstop continuations that all fired while a child ran, #buildContinuationContent (L626-L649) injects the "resumption-channel" stall check. goal-resumption-channels.test.ts L125-L160 pins this: the third delivery contains <goal_stall_check> while terminal-background-sessions is still active. That is why this is a proposal, not a bug report.

Observed in one goal run (runtime 2026.10.19-2): the stall check fired 14 times, at least once while a plan-reviewer child that would wake the session was still running. The notice told the model to inspect, and stop or replace, a channel that was healthy.

Repro:

  1. Start a goal and spawn a background task child that runs longer than three GOAL_MONITOR_BACKSTOP_DEFAULT_DELAY_MS delays.
  2. End each turn without tool use while it runs.
  3. The third backstop continuation carries <goal_stall_check> ("resumption-channel goal continuation #3 in a row"), even though the child is alive.

Expected: no injection while the child runs, and a streak back at zero after it delivers.

How? (optional)

In afterAgentEnd, skip the increment when liveWakeSources().length > 0, and reset the streak in the WAKE_SOURCE_STATE_EVENT handler when the total drops to zero. The repetition-hash guard and the continuation cap stay as they are, so a model that only narrates still hits them.

Related, but a different trigger: #3975, #1582. Checked on main ea879a34 and on runtime 2026.10.23-1, which carries the same code.

Linked PR #6196 (proposal)

This was generated by AI during triage.

Bearmancer avatar Oct 25 '26 17:10 Bearmancer

AI disclosure, per CONTRIBUTING: an LLM drafted this issue from a reviewed session retro. The code references were checked against main ea879a34 before posting.

This was generated by AI during triage.

Bearmancer avatar Oct 25 '26 17:10 Bearmancer

Thank you @Bearmancer, the links to exactly where the toolless streak is counted without checking live wake sources make the proposal easy to evaluate. Treating a wait on a running child as something other than a stall is a clear use case. The related open issue #5160 touches the same wake-source signal, and this proposal is noted for the team.

code-yeongyu avatar Nov 02 '26 10:11 code-yeongyu