solo icon indicating copy to clipboard operation
solo copied to clipboard

[Proposal] Separate queued task, provider turn, and persistent process lifecycles

Open CovD831 opened this issue 4 months ago • 0 comments

Problem

Solo currently lets one prompt-driven execution path stand in for three different runtime lifecycles:

  1. a daemon task may be waiting in a per-Agent queue;
  2. a provider turn may be actively executing;
  3. a persistent provider process may remain alive across turns.

In batch runs this makes accepted work look active before the provider starts, charges queue time against execution time, and lets task cancellation either leave the turn slot occupied or kill the reusable process. The daemon also emits backend_started before the server subscribes in some runs, but that control event is not replayed.

Evidence from ordinary local tasks

A three-task batch against one Agent showed all three runs entering active-looking state even though only one provider turn could execute. After separating the initial states, the first run became running while the other two stayed queued; each queued run received backend_started_at only when it acquired the provider turn.

A natural execution timeout then exposed a second issue: cancelling the task context did not reliably release the provider turn. A direct cancellation run also showed no active turn to interrupt, meaning the provider had already ended while Solo had not converged its local turn state.

Proposed contract

  • queued: daemon accepted the task, but no provider turn has started.
  • backend_started_at: authoritative, idempotent proof that a provider turn was acquired.
  • terminal run state: cannot be revived by late daemon events.
  • task cancellation interrupts only its provider turn.
  • persistent process lifetime is controlled only by the session pool, not by a task context.
  • crash recovery preserves resumable session metadata but never starts an untracked continuation turn.
  • control events required for lifecycle transitions are replayable across the POST-to-SSE subscription gap.
  • orphaned queued runs converge to queue timeout after server restart.

Acceptance criteria

  • a batch against one Agent exposes one running turn and truthful queued followers;
  • cancellation produces a terminal cancelled run, releases the turn, and lets the next task reuse the same process;
  • queue wait and execution timeout use separate clocks;
  • late events cannot revive completed, failed, cancelled, or timed-out runs;
  • tests cover context cancellation before Stop, cancellation during turn/start acknowledgement, missed terminal notification, SSE replay, and crash recovery without an untracked turn.

CovD831 avatar Jul 21 '26 12:07 CovD831