Skip to content

[Feat] Let tasks sleep and resume after a requested wait - #1301

Open
roomote-community[bot] wants to merge 12 commits into
developfrom
feature/task-wait-0tawul3eoispl
Open

[Feat] Let tasks sleep and resume after a requested wait#1301
roomote-community[bot] wants to merge 12 commits into
developfrom
feature/task-wait-0tawul3eoispl

Conversation

@roomote-community

@roomote-community roomote-community Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

What changed

  • Added an explicit wait_task action for agent-requested pauses from 10 minutes through six days.
  • Persists the wake deadline and reason, schedules wake before sleep, releases compute through snapshot or standby, and resumes the same task with a hidden continuation.
  • Uses one transactional claim for timed and manual resumes, reopens failed claims only after the child is canceled, and runs a database-backed recovery sweep for missed wake delivery.
  • Recovers cancellations that happen before or after the scheduled wake checks the manual-resume child, replacing completed wake jobs when needed.
  • Protects wait snapshots while claims are active, canceled, or temporarily unclaimed so standby retention cannot interrupt recovery.
  • Preserves active goals without consuming continuation budget, supplies the authoritative generation on wake, restores the prior generation if scheduling fails, and blocks automatic continuation while a durable wait is pending.
  • Treats duplicate pending wait requests idempotently by repairing queue side effects, while rejecting waits that were already consumed.

Why this change was made

Tasks previously had no durable way to honor requests such as "check again in 30 minutes." Blocking sleeps retained compute, while ordinary idle sleep had no timed wake-up. The lifecycle also needs to remain correct under Redis failures, retries, manual messages, canceled resume attempts, retention sweeps, prolonged worker outages, and Goal Mode continuation.

Impact

Roomote agents can intentionally sleep without holding an active sandbox and automatically continue at the requested time. A wait cannot create competing manual and timed resumptions, and canceling a manual resume no longer prevents the scheduled wake from creating its timed continuation or allows retention to delete the required snapshot. Transient queue failures remain recoverable, pending waits keep their resume handle through outages, and preserved goals remain actionable after waking. Short waits that would be dominated by sleep and resume overhead are rejected, and unsupported runtimes fail before claiming that the task is paused.

@roomote-community

roomote-community Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

No code issues found. See task

  • Active goals retain their assigned generation after a timed wake, so the resumed turn can complete or block the preserved goal.
  • Unclaimed pending waits keep their snapshots until resumed or explicitly cleared, preserving recovery through prolonged outages.
  • A canceled manual-resume child before the scheduled wake releases the wait claim so the timed continuation can be created.
  • Cancellation after the timed wake observes a pending child is recovered by the database-backed wake sweep.
  • Canceled resume claims and active claimed resume children remain protected until the wake can finish, preventing standby retention from deleting their snapshot (packages/db/src/lib/task-waits.ts:73).

Reviewed 0383961

Comment thread apps/bullmq/src/task-wake-queue.ts
Comment thread apps/bullmq/src/scheduled-jobs/standby-retention.ts Outdated
@roomote-community

roomote-community Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the lifecycle risks identified in the follow-up review in cddcdf33, merged current develop in 7724da43, and removed the final lossy retention cutoff in c50ae695.

Timed and manual resumes share one recoverable claim; failed children cannot consume a wait; unclaimed pending snapshots remain protected until resumed or cleared; failed setup restores Goal Mode generation state; durable waits suppress automatic goal continuation; and duplicate requests repair pending waits without treating consumed waits as success. Focused DB, API, BullMQ, and worker tests plus repository lint, type checks, and pre-push checks pass.

Comment thread apps/bullmq/src/task-wake-queue.ts Outdated
@daniel-lxs
daniel-lxs marked this pull request as ready for review August 14, 2026 23:37
Comment thread packages/db/src/lib/task-waits.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant