Fix: programmatic prompts (agent messages, scheduled follow-ups) starve at idle sessions after an abort (#1000) #1761
kaluli123123
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Programmatic prompts (agent messages from subagents, scheduled follow-ups/heartbeats) queued at an idle session are never delivered until a human types a prompt. In one report, batches of subagent results sat queued for 8+ hours and all flushed in the same second a human message arrived. This is #1000, one of the "related reports" under the still-open tracker #1382 (Complete queued, interrupted, and archived session lifecycle recovery).
Confirmed still present on
main(06860844e) with a new regression test suite that reproduces all three shapes described in the original report.Root cause (
_admitSessionInputinpackages/coding-agent/src/core/agent-session.ts)requestAbort()sets_sessionInputPumpSuspended = true. A typed prompt clears it via_resumeSessionInputAdmission()(theprompt()path), but a programmatic admission does not: the flag is only cleared whenaction.payload.kind === "turn" && action.wake === "immediate", so queued follow-ups/steer actions with the default wake behavior wait forever at idle.queueKey),_admitSessionInputreturns{ accepted: false, disposition: "queued" }before any code that schedules the pump. Every re-fire is swallowed; nothing ever restarts delivery.History
An earlier PR attempt, #895, proposed a fix and was closed in favor of a maintainer-owned stacked PR, #1162 (part of the merged #1158–#1165 stack for tracker #1382):
#1162 merged, but this specific code path was not part of it — the bug is still live.
Notably, #895's proposed patch toggled
_sessionInputPumpSuspendeddirectly without checking_sessionInputSuspendedForUpdateRestart. That flag is a different, deliberate suspension reason (abortForUpdateRestart()) meant to hold queued inputs so they survive into the restart manifest instead of starting a turn during teardown (see the existing guarded call site around line 6197:if (!this._sessionInputSuspendedForUpdateRestart) this._resumeSessionInputAdmission();). Blindly clearing the flag would have silently reintroduced a second bug — a turn starting mid-restart-teardown — while fixing the first one.Fix
Resume a suspended pump on both paths (the coalesced early return, and the general admission path) via the existing
_resumeSessionInputAdmission()helper, gated on: the action is aturn, the session isn't streaming, the pump is actually suspended, and the suspension is not a restart hold.(mirrored in the coalesced-owner early-return branch above it).
Tests
Added
packages/coding-agent/test/suite/regressions/resume-suspended-input-pump.test.tswith 4 cases:_sessionInputSuspendedForUpdateRestartguard is removed, so it actually exercises that hazardAll 4 fail against pre-fix
mainand pass after the fix. Also ran:test/suite/agent-session-queue.test.ts,agent-session-action-contracts.test.ts,agent-session-action-races.test.ts,agent-session-autonomous.test.ts,agent-session-goal.test.ts(195 passed)test/suite/regressions/4257-update-restart-resume.test.ts, the existing large update-restart suite (35 passed)packages/coding-agentsuite surfaced 3 unrelated pre-existing failures (resource-loader.test.ts,package-command-paths.test.ts,4600-supervisor-singleton.test.ts); confirmed by re-running them against unmodifiedmainthat they fail identically there (sandbox-specific: symlink/extension loading and real daemon-socket timing), unrelated to this change.npm run check(biome,tsgo --noEmit, installer render, browser smoke) — all green. Added apackages/coding-agent/.changes/fragment per the changelog-fragment CI check.Patch
Branch: https://github.com/kaluli123123/prime-agent/tree/fix/resume-suspended-input-pump-programmatic
Diff: main...kaluli123123:prime-agent:fix/resume-suspended-input-pump-programmatic
Happy to open a PR from this branch if a maintainer wants to invite implementation, per CONTRIBUTING.md.
All reactions