Skip to content

Stale shell background tasks cause repeated IDLE-DEFER delays #573

@PureWeen

Description

@PureWeen

Problem

The CLI reports stale shell background tasks in session.idle across turns, causing IDLE-DEFER to repeatedly delay completion for sessions that are actually done.

Observed behavior

The PROMPT session consistently receives session.idle with shells=2 even on brand-new turns sent hours after the shells last ran. These same 2 shells have been reported since April 6 and are clearly finished processes.

2026-04-08 20:39:26 backgroundTasks={agents=1, shells=2}  → IDLE-DEFER
2026-04-08 20:42:23 backgroundTasks={agents=0, shells=2}  → IDLE-DEFER
2026-04-09 00:37:21 backgroundTasks={agents=0, shells=2}  → IDLE-DEFER (4 hours later, new turn)

Each turn then waits ~10 minutes for the watchdog to detect file-growth stall before force-completing.

Impact

  • Simple turns that should complete in seconds take ~10 minutes
  • The zombie detection threshold (20 min) is too long for shell-only carryover
  • Every new message to the affected session repeats the cycle

Possible PolyPilot-side fix

If the background task fingerprint at the start of a new turn matches the fingerprint from the end of the previous turn, skip IDLE-DEFER immediately — those tasks are clearly carried over, not from this turn.

Possible upstream CLI fix

The CLI should remove finished shell entries from its backgroundTasks tracking so they don't leak across turns indefinitely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalUpstream bug or dependency issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions