AI SYSTEMS / ENGINEERING

中文

Agent runtime / 2026

Scheduling and Recovering Long-Running Tasks

Gives local AI coding tasks scheduled runs, execution history, and continuation in the original session after interruption.

Task lifecycleSQLiteSession recovery
A task lifecycle showing schedules, run states, failure recovery, and archived results

The problem

Long-running coding tasks can be interrupted by a restart, model error, or failed external call. If only the final status is stored, the system cannot distinguish active work from stale state or determine what should continue.

System design

Local task configuration and schedule triggers manage runs. SQLite records run state, duration, errors, logs, and session relationships. On startup, the service reconciles leftover run records before deciding whether to resume, wait, or mark a task interrupted.

Scheduled tasks can recover the same session after a delay, with the parent and follow-up runs linked. Manual and UI-launched runs retain separate semantics so they do not enter automatic retry by accident.

Engineering boundaries

The local scheduler interface showing task configuration, run history, and continuation controls
Task configuration and run history. Task instructions are redacted. Open for a larger view.

Task configuration, run records, and logs remain traceable. Recovery actions have an explicit trigger source and claim state, so retry, alerting, and continuation can be verified independently.

My contribution

I implemented the local task interface, run history, state reconciliation, and recovery logic, then added checks for retry boundaries, concurrent claims, and shutdown.