Skip to content

Don't fail agent-owned scans on controller restart - #30

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-8898
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-8898

Conversation

@cursor

@cursor cursor Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

A controller restart (crash, deploy, reboot) reloaded every running job as failed — including scans a remote agent was still executing. try_set_terminal then refused POST /complete, so the agent's results were discarded and the UI showed "Scan interrupted by server restart."

Trigger: Postgres/SaaS (or any remote agent) → job is running on an agent → API process restarts → agent POSTs complete → 200 with status: failed and no terminal done event.

Fix: ScanJob.from_dict only fails running jobs that have no assigned_agent_id (true in-process zombies). Assigned jobs stay running so the agent can complete. Graceful shutdown uses the same rule. Dead agents are still handled by reclaim_stale_jobs.

Tests: reload keeps assigned running jobs; unassigned running jobs still fail; full agent lifecycle survives a simulated restart and retains pre-restart events.

Open in Web View Automation 

ScanJob.from_dict treated every running job as an in-process zombie and
marked it failed. Remote agents keep executing across a controller
restart; try_set_terminal then refused POST /complete and the results
were discarded. Leave assigned running jobs running so the agent can
finish; only unassigned running jobs (no agent will complete them) are
failed on reload. Same rule on graceful shutdown.

Co-authored-by: dmitryflynn <dmitryflynn@users.noreply.github.com>
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