Skip to content

IDLE-DEFER should re-arm IsProcessing when background tasks are active #403

@PureWeen

Description

@PureWeen

Problem

When SessionIdleEvent arrives with active background tasks but IsProcessing is already false (cleared by a prior watchdog timeout, EVT-REARM cycle, or permission recovery), the IDLE-DEFER path is a no-op — it flushes text but doesn't re-arm processing. The background tasks (sub-agents, shells) continue running but PolyPilot thinks the turn is done.

Observed

19:32:19 [IDLE-DEFER] 'PP- IC Things-worker-1' session.idle received with active background tasks 
  — deferring completion (IsProcessing=False, response=0+0 chars)

IsProcessing=False means the response was already finalized (truncated). The orchestrator collects a short/empty response and reports the worker as failed.

Expected

When IDLE-DEFER detects IsProcessing=false AND background tasks are active, it should re-arm IsProcessing=true (similar to EVT-REARM) so the session stays alive until the background tasks complete and a final idle (without background tasks) arrives.

Considerations

  • Must follow INV-2 (UI thread for mutations)
  • Must restart the watchdog (INV-9)
  • Should log [IDLE-DEFER-REARM] for diagnostics
  • The existing EVT-REARM path handles a similar case (TurnStart with IsProcessing=false) — the IDLE-DEFER re-arm would be analogous

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions