Skip to content

Configurable retry mechanism for task and schedule execution failures #89

Closed as not planned

Description

@vybe

Problem

When a task or scheduled execution fails (Claude Code error, timeout, transient network issue, agent temporarily unhealthy), the execution is simply marked as failed with no automatic recovery. Operators must manually re-trigger failed tasks, which defeats the purpose of autonomous operation.

Currently:

  • TaskExecutionService marks failures in schedule_executions and moves on
  • Scheduled jobs fire once per cron tick — if that run fails, the next attempt is the next cron interval (could be hours/days)
  • No distinction between transient failures (network blip, rate limit) and permanent failures (bad prompt, missing credentials)

Proposed Solution

1. Retry Configuration (per-schedule and per-task)

Add retry settings to schedules and ad-hoc task triggers:

# Schedule-level config
retry:
  max_retries: 3          # 0 = no retries (current behavior)
  backoff: exponential    # fixed | linear | exponential
  initial_delay_seconds: 30
  max_delay_seconds: 600  # cap for exponential backoff
  retry_on:               # optional filter (default: all failures)
    - timeout
    - transient_error

2. Database Changes

Extend schedule_executions:

  • retry_attempt (INTEGER DEFAULT 0) — which attempt this is (0 = first run)
  • retry_of (TEXT, FK) — links to the original execution that failed
  • next_retry_at (TEXT) — when the next retry is scheduled (NULL if no more retries)

Extend agent_schedules:

  • retry_max (INTEGER DEFAULT 0)
  • retry_backoff (TEXT DEFAULT 'exponential')
  • retry_initial_delay (INTEGER DEFAULT 30)
  • retry_max_delay (INTEGER DEFAULT 600)

3. Retry Engine

In TaskExecutionService, after a failure:

  1. Check if retries are configured and retry_attempt < retry_max
  2. Calculate next delay using backoff strategy
  3. Schedule a one-shot retry job via APScheduler add_job(trigger='date', run_date=...)
  4. Update execution record with next_retry_at
  5. Emit WebSocket event execution_retry_scheduled

4. UI Changes

  • Schedule form: Add retry configuration section (collapsible, advanced)
  • Task trigger modal: Optional retry count field
  • Execution Detail page: Show retry chain (attempt 1 → 2 → 3) with links
  • Tasks tab: Badge showing "Retry 2/3" on retrying executions

5. MCP Tools

  • Extend create_agent_schedule / update_agent_schedule with retry params
  • Extend chat_with_agent (async mode) with retry options

6. Observability

  • Dashboard timeline should show retry attempts as linked execution boxes
  • Notifications for final failure after all retries exhausted
  • Retry statistics in agent dashboard (retry rate, success-after-retry rate)

Scope

Component Changes
Database Migration for new columns on schedule_executions and agent_schedules
Backend TaskExecutionService retry logic, scheduler one-shot jobs
Frontend Schedule form, execution detail, tasks tab badges
MCP Extended schedule and chat tool parameters

Out of Scope

  • Circuit breaker pattern (could be a follow-up)
  • Per-step retries in Process Engine (already has its own retry logic)
  • Dead letter queue (log + notification is sufficient for now)

Acceptance Criteria

  • Schedules can be configured with retry count and backoff strategy
  • Failed executions automatically retry up to the configured limit
  • Retry chain is visible in Execution Detail page
  • Final failure (retries exhausted) sends a notification
  • MCP tools support retry configuration
  • Manual task triggers support optional retry count
  • Existing schedules with no retry config continue to work (backward compatible)

Activity

  1. added
    priority-p1
    type-feature
    on Mar 10, 2026
  2. vybe commented on Apr 10, 2026

    @vybe
    ContributorAuthor

    Closing as superseded by #271, which has a tighter, more focused spec for scheduler retry mechanism.

  3. added
    complexity-medium
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p1type-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions