Skip to content

Hard pause and two-tier automatic resume (reset-known sleep + backoff probe) #34

Description

@Ryan-Atkinson87

Implement the hard pause and automatic resume: the floor of the usage-control model.

Spec: §6.3 (hard pause — finish atomic step, commit, stop), §6.4 (Pause and resume —
two-tier reset detection, resume point).

Acceptance criteria

  • On reaching threshold (Threshold evaluation and date-sensitive Agent SDK credit meter handling #33): set a waiting-for-usage state in the state store and signal a graceful stop — the current atomic step finishes cleanly and progress is committed before stopping (a known marker, unlike a crash; resume needs no discard — contrast §18.4).
  • Reset time known: if the last successful read gave a resets_at for the governing meter, sleep until that time plus a small buffer, then resume — no probing.
  • Reset time unknown: probe with the cheapest possible call (tiny max_tokens, trivial prompt) on the specific exhausted model tier (a Sonnet probe does not prove the Opus weekly reset). 200 → resume; 429 → keep waiting.
  • Probe interval is exponential backoff: start 5 min, double on each failed probe (5 → 10 → 20 → 40), cap 30 min, reset to 5 min on success.
  • On resume, the engine continues from the per-issue state marker (Per-issue state markers and resume-or-reset crash recovery #24) at the next step — no work lost because the pause stopped at a committed step.
  • The probe goes through the Claude adapter (Spec §3.3), not a direct API call.
  • Unit tests cover: pause sets state + commits, reset-known sleep path, backoff sequence with reset-on-success, and per-tier probe targeting.

Depends on: #30
Depends on: #3
Depends on: #24
Depends on: #17

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions