Repository navigation
Closed
Labels
complexity-mediumComplexity: medium (board points 5-8)enhancementNew feature or requestpriority-p2Important
Description
Summary
Add a configurable retry mechanism for scheduled executions that fail. When a scheduled task fails (timeout, agent error, rate limit), automatically retry it after a configurable delay.
Default: 1 retry, ON by default — most failures are transient (agent not ready, 429 rate limits, brief network issues). Users who set up schedules expect resilience without needing to discover a retry toggle.
Schema Changes
agent_schedules — 2 new columns
max_retries INTEGER DEFAULT 1, -- 0 = no retry, 1-5 range
retry_delay_seconds INTEGER DEFAULT 60 -- seconds between retries (30-600)schedule_executions — 2 new columns
attempt_number INTEGER DEFAULT 1, -- which attempt this is (1 = first try)
retry_of_execution_id TEXT, -- links retry to original executionExecution Flow
Cron fires → Execute → Failed?
├─ No → Done (status=success)
└─ Yes → attempt_number < max_retries + 1?
├─ No → Done (status=failed, final)
└─ Yes → Schedule delayed retry (retry_delay_seconds)
→ New execution record with:
attempt_number = previous + 1
retry_of_execution_id = original execution id
triggered_by = "retry"
Design Decisions
| Decision | Choice | Rationale |
|---|---|---|
| Default retries | 1 (ON) | Most failures are transient; autonomous agents should be resilient by default |
| Retry = new execution record | Yes | Full observability — each attempt has own logs, cost, duration |
| Link retries | retry_of_execution_id → first attempt |
UI can group attempts together |
| Delay mechanism | APScheduler date trigger |
Survives scheduler restart (vs asyncio.sleep) |
| Which failures retry | All except skipped and cancelled |
Skipped = capacity issue. Cancelled = intentional. |
| Rate limit (429) | Retry with 2x delay | Already detected in task_execution_service |
| Max retries cap | Hard cap at 5 | Prevents misconfiguration |
| Delay range | 30–600 seconds | Too short = same issue. Too long = defeats purpose. |
Implementation Scope
Backend
- Migration: 4 new columns across 2 tables
-
db/schedules.py: new fields in create/update/query operations -
models.py: new fields in schedule and execution request/response models - Scheduler service: retry scheduling logic after execution failure (~50 lines)
- New
triggered_byvalue:"retry"
MCP Server
-
schedules.ts:max_retriesandretry_delay_secondsparams on create/update tools
Frontend
- Schedule form: "Retries" section — max_retries (0-5 dropdown), delay (seconds input)
- Execution history: attempt number badge (e.g., "Attempt 2/2"), link to related attempts
- Execution detail: "Retry of: [link to original]" when applicable
Acceptance Criteria
- Failed scheduled executions auto-retry up to
max_retriestimes withretry_delay_secondsdelay - Each retry is a separate execution record linked to the original via
retry_of_execution_id - Default for new schedules: 1 retry, 60s delay
- Existing schedules get default values via migration (1 retry, 60s delay)
-
skippedandcancelledexecutions are NOT retried - Rate-limited (429) retries use 2x the configured delay
- UI shows attempt number and links between retry attempts
- MCP tools support retry configuration
- Retry survives scheduler restart (uses APScheduler date trigger, not asyncio.sleep)
Metadata
Metadata
Assignees
Labels
complexity-mediumComplexity: medium (board points 5-8)enhancementNew feature or requestpriority-p2Important
Activity
feat(scheduler): retry mechanism for failed scheduled executions (#271)
feat(scheduler): retry mechanism for failed scheduled executions (#271)…
docs: update orchestration plan progress + add retry tests (#271 foll…
docs(announcements): weekly update 2026-04-21
fix(tests): green dev-merge residuals (refs Abilityai#660)