← Back to PRs

#13574: fix(heartbeat): skip when session has active run

by 1kuna open 2026-02-10 18:28 View on GitHub →
stale
Defer heartbeat polling when the session already has an active embedded Pi run to avoid lock contention that can surface as Agent failed during compaction or long runs. The heartbeat checks for active runs before polling and defers up to 5 times (2 minutes each). If the session is still busy after 10 minutes, the cycle is skipped. Testing: - npm run build - npx vitest run src/infra/heartbeat-runner*.test.ts References #13573 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change adds a guard in `runHeartbeatOnce` to skip running the heartbeat poll when the resolved session has an active embedded Pi run, intended to reduce lock contention during compaction/long runs. The logic is inserted immediately after resolving the heartbeat session entry and before heartbeat delivery/prompt resolution. <h3>Confidence Score: 4/5</h3> - Mostly safe to merge, but skip logic likely breaks exec/cron event delivery and reduces heartbeat telemetry visibility. - Change is small and localized, but the new early return occurs before exec/cron pending-event handling and doesn’t emit a heartbeat event for the new skip reason, which can alter externally-visible behavior and observability. - src/infra/heartbeat-runner.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs