Repository navigation
Description
Summary
When the circuit breaker fires probes against an agent, each probe creates a schedule_executions record. If the probe is rejected (CB open), the record is never closed — it stays in a non-terminal state until the next backend restart, which runs startup cleanup and marks it failed. The result is a large red block on the execution timeline spanning the entire window from probe creation to backend restart, giving a misleading picture of agent activity.
Component
Backend / Circuit Breaker / Execution Timeline (Frontend)
Priority
P3
Observed Behavior
- Circuit breaker opens for an agent
- CB fires probe executions — each creates a
schedule_executionsrow - Probes are rejected (CB open), but their DB records are never closed
- Records sit in non-terminal state (
running,pending_retry, etc.) - On next backend restart, startup cleanup closes them with
error = "Execution orphaned — recovered on backend restart" completed_atis set to the restart time, not the actual probe end time- Timeline displays a large red failure block spanning the full gap (e.g. 40 minutes) instead of a brief probe event
Root Cause
CB probe executions are not closed at the point of rejection. The backend creates the execution record before dispatching to the agent, but when the CB rejects the call, no corresponding completed_at / failed update is written back to schedule_executions. The record is only resolved as a side-effect of backend restart orphan cleanup, which stamps the current wall-clock time as completed_at — not the actual failure time.
Reproduction Steps
- Trigger enough consecutive agent failures to open the circuit breaker
- Observe CB firing probe executions in scheduler logs
- Let the CB remain open for several minutes without a backend restart
- Check
schedule_executions— probe records will be in non-terminal state - Restart the backend
- View the agent's execution timeline — probe records now show as long-duration failures
Suggested Fix
When the circuit breaker rejects a call, immediately close the associated execution record with status = 'failed', completed_at = now(), and a descriptive error such as "Rejected by circuit breaker (open state)". This ensures the timeline accurately reflects a brief probe attempt rather than a multi-minute failure span.
Alternatively, CB probe executions could be marked with a distinct status (e.g. cb_rejected) so the frontend can render them differently (e.g. as a small marker rather than a full red block).
Related
- Circuit breaker implementation:
src/backend/services/agent_client.py - Execution cleanup on restart:
src/backend/services/cleanup_service.py(or similar) - Related: bug(session-tab): shows 'failed to send' on return navigation while execution is still running #759 (session tab false failure state on navigation)
Activity
vybe commentedon May 10, 2026
/claim
github-actions commentedon May 10, 2026
Claimed by @vybe. Label
status-in-progressadded.Next steps:
feature/767-<short-slug>Fixes #767vybe commentedon May 11, 2026
/claim
github-actions commentedon May 11, 2026
@vybe This issue is already assigned to vybe. Use
/unclaimfirst if you want to take over.fix(executions): close CB probe executions on fast-fail and backend s…
fix(execution): the CAS-won terminal owns the paired activity close (#…
fix(activities): close cancelled-event and claimed-turn companion act…