Skip to content

[BUG] Agent stuck status=running after run completes — zombie run not auto-cleared, blocking all subsequent heartbeats #97

Description

@aduduman031084

Summary

Paperclip agents intermittently get stuck in status=running after their heartbeat run has already completed successfully. Because maxConcurrentRuns=1, no new heartbeat can start — the agent is silently dead to the platform while looking alive. This is a recurring, high-impact production bug that has now manifested at least 5 times on our instance since June 2026.

Recurrence History (our instance)

Date Issue Agent Impact
2026-06-23 [FAI-5776] Founding Engineer + DevOps ~90 min zombie, 3 issues 409/403-locked, pricing build blocked
2026-06-23 [FAI-5776] DevOps Engineer Same incident, concurrent zombie
2026-06-26 FAI-6087 (this) Founding Engineer 7h+ zombie, Phase 2 work (FAI-6090) stranded overnight
Earlier FAI-5355, FAI-5428, FAI-5462, FAI-5686 DevOps Engineer Multiple silent-run reviews raised
Earlier FAI-2588 Founding Engineer "Standing in stale sessions multiple times in one day"

Every one of these was a productivity kill. An agent that should be building or reviewing sits frozen while the board sees a green "running" status and assumes work is progressing.

What Happens

  1. Agent runs a heartbeat. Run completes with status=succeeded.
  2. Paperclip does not flip agent.status from runningidle.
  3. lastHeartbeatAt goes stale while agent.status stays running.
  4. All new wake attempts are rejected (maxConcurrentRuns=1 concurrency guard).
  5. Assigned issues collect 409/403 checkout conflicts as if the agent is busy.
  6. Human or CEO agent must manually intervene: pause → resume (or board-level runtime-state/reset-session).

Root Cause (as far as we can tell)

The run completion callback / state-machine transition from run.status=succeededagent.status=idle is not firing reliably. This appears to be a race or a missed event in the agent lifecycle handler, not reproducible on demand but recurring under normal agentic load.

Why This Keeps Hurting Us

  • Our zombie-run watchdog (a 15-min cron we built ourselves as a workaround, [FAI-5939]) was paused by the board on 2026-06-24 — meaning the platform's own lifecycle should handle this, not a user-space workaround.
  • The runtime-state/reset-session recovery endpoint returns 403 Board access required when called from an agent JWT, so agent self-recovery is impossible. Board manual intervention is the only path.
  • There is no platform-native alerting beyond "suspicious after 1h / critical after 4h" stale-run checks — by the time an alert fires, hours of work are lost.

Reproduction Steps

We cannot reproduce this on demand, but the conditions are:

  • codex_local adapter
  • wakeOnDemand: true, maxConcurrentRuns: 1
  • Normal heartbeat run that completes (last observed: run completed ~19:16Z, zombie persisted until ~07:55Z next day — ~12 hours)

Expected Behavior

When a heartbeat run reaches a terminal state (succeeded, failed, cancelled), agent.status must atomically transition to idle (or paused if paused). No manual recovery should be needed.

Requested Fixes / Mitigations

  1. Fix the state transition so run.completedagent.status=idle is atomic and reliable.
  2. Expose a self-service recovery endpoint (e.g. POST /api/agents/:id/recover-zombie) callable by agents with their own JWT, not just board-level tokens.
  3. Platform-native watchdog built into the scheduler — not a user-space cron we have to maintain and remember to keep unpaused.
  4. Alert loudness — a zombie older than 30 min should be auto-reaped or at minimum surfaced as a board-level notification, not just a stale-run evaluation issue.

Business Impact

Each zombie incident costs 2–12 hours of autonomous agent capacity and requires board-level manual intervention. On a team running autonomous agentic workflows 24/7, this is the single biggest reliability drag we have. We have built two generations of internal workarounds ([FAI-1166], [FAI-5778], [FAI-5939]) and the bug still reappears.

Please treat this as a high-priority platform reliability issue. It is seriously impacting our work and overall productivity

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamBelongs to the Paperclip application/control-plane, not the operator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions