Skip to content

Update docs to tighten up alarm loop guardrails - #34151

Open
harshil1712 wants to merge 5 commits into
productionfrom
harshil/do-alarm-loop-guardrails
Open

harshil1712 wants to merge 5 commits into
productionfrom
harshil/do-alarm-loop-guardrails

Conversation

@harshil1712

Copy link
Copy Markdown
Contributor

Summary

Add clear information on DO Alarm running into loops and how to prevent them

Documentation checklist

@github-actions github-actions Bot added product:durable-objects Durable Objects: https://developers.cloudflare.com/workers/learning/using-durable-objects/ product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. product:billing labels Oct 9, 2026
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

AI Review

✅ Reviewed d41cba6 · 0 findings · incremental

Commands
  • /review Run a review now.
  • /full-review Review the entire PR diff.
  • /disable-auto-review Stop automatic reviews.
  • /rebase Rebase against production.

@github-actions github-actions Bot added the size/m label Oct 9, 2026
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review coverage

🟡 4 ownership areas need approval.

Suggested reviewers: @dalexeenko @irvinebroque @joshthoward @vy-ton @southpolesteve

Needs approval Eligible approvers Suggested
billing @dalexeenko, @shanecloudflare, @zqamruddin, @cloudflare/customer-support, @cloudflare/product-owners dalexeenko
durable-objects
/src/content/docs/durable-objects/
@danlapid, @iglesiasbrandon, @irvinebroque, @joshthoward, @lambrospetrou, @mikenomitch, @rita3ko, @vy-ton, @cloudflare/product-owners irvinebroque, joshthoward, vy-ton
durable-objects
/src/content/partials/durable-objects/
@danlapid, @iglesiasbrandon, @irvinebroque, @joshthoward, @lambrospetrou, @mikenomitch, @rita3ko, @vy-ton, @cloudflare/product-owners joshthoward, vy-ton
agents @irvinebroque, @rita3ko, @cloudflare/ai-agents, @cloudflare/dev-plat-leads, @cloudflare/product-owners irvinebroque, southpolesteve
CODEOWNERS mappings for displayed areas (4)
Pattern Owners
/src/content/docs/billing/ @dalexeenko, @shanecloudflare, @zqamruddin, @cloudflare/customer-support, @cloudflare/product-owners
/src/content/docs/durable-objects/ @danlapid, @iglesiasbrandon, @irvinebroque, @joshthoward, @lambrospetrou, @mikenomitch, @rita3ko, @vy-ton, @cloudflare/product-owners
/src/content/partials/durable-objects/ @danlapid, @iglesiasbrandon, @irvinebroque, @joshthoward, @lambrospetrou, @mikenomitch, @rita3ko, @vy-ton, @cloudflare/product-owners
/src/content/docs/agents/ @irvinebroque, @rita3ko, @cloudflare/ai-agents, @cloudflare/dev-plat-leads, @cloudflare/product-owners

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://harshil-do-alarm-loop-guardrails.previews.developers.cloudflare.com (commit d41cba6)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://98684961.previews.developers.cloudflare.com d41cba6 2026-10-19T17:54:04.045Z Visit the dashboard ↗
  • Build: Failed ❌

View logs ↗
bcd0280 2026-10-16T21:14:52.997Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://8b4939a7.previews.developers.cloudflare.com da1ed74 2026-10-14T10:32:38.057Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d1d03c5c.previews.developers.cloudflare.com eb9a113 2026-10-14T10:04:01.833Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ca813e1f.previews.developers.cloudflare.com b3a9ed9 2026-10-12T12:52:46.455Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://bc078fd6.previews.developers.cloudflare.com adf8db2 2026-10-09T14:32:44.650Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://398a751c.previews.developers.cloudflare.com 2a3e096 2026-10-09T12:04:06.477Z Visit the dashboard ↗

Comment thread src/content/docs/agents/runtime/execution/schedule-tasks.mdx Outdated
Comment thread src/content/docs/durable-objects/api/alarms.mdx Outdated
Comment thread src/content/docs/durable-objects/api/alarms.mdx Outdated
Comment thread src/content/docs/durable-objects/api/alarms.mdx Outdated
Comment thread src/content/docs/durable-objects/api/alarms.mdx Outdated
Comment thread src/content/docs/durable-objects/best-practices/rules-of-durable-objects.mdx Outdated
Comment thread src/content/docs/durable-objects/best-practices/rules-of-durable-objects.mdx Outdated
Comment thread src/content/docs/durable-objects/best-practices/rules-of-durable-objects.mdx Outdated
Comment thread src/content/docs/durable-objects/api/alarms.mdx Outdated
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

@cloudflare cloudflare deleted a comment from github-actions Bot Oct 16, 2026
@mvvmm

mvvmm commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

/rebase

harshil1712 and others added 3 commits October 19, 2026 17:46
Co-authored-by: Ashley Peacock <apeacock@cloudflare.com>
Addresses review feedback that storing an attempt counter adds a write per
alarm. An in-memory counter is not a reliable substitute: objects are evicted
after 70-140s idle, so with retries >= 1 minute apart it resets between
attempts and the limit never trips.

- Rules of Durable Objects: the good example derives both backoff and a
  give-up deadline from `refreshAt`, which the object already stores. Retries
  need no extra storage writes, and the stop condition survives eviction. The
  success path now advances `refreshAt` so the deadline stays meaningful.
- Alarms API: update the caution and the "Catching exceptions" note to match.
- Testing: replace the run-until-stop test with two focused tests (minimum
  delay on retry, no reschedule after the deadline).
- Storage API partial: "almost immediately" -> "immediately", consistent with
  earlier review suggestions.
- Optimize costs: "attempt limit" -> "deadline".

Verified: examples and tests type-check (strict, noUnused*); good example
passes; setAlarm(Date.now()) variant fails test 1; no-deadline variant fails
test 2. pnpm run check and pnpm run build pass.
Use the wording suggested by the Agents team in review. The only change from the suggested text is the scheduleEvery() link anchor (#interval).
- Rules of Durable Objects: add jitter to the backoff in the good example,
  as suggested in review, so retries from objects that fail at the same time
  are spread out.
- Reword "back off on failure" to "back off for retried operations" to
  distinguish handler-scheduled retries from exceptions escaping alarm(),
  which have their own built-in backoff. Applied to the Rules bullet, the
  Rules intro, and the Alarms caution.
- Reword "runs (again) immediately" to "is (re)scheduled to run immediately",
  since alarms are not guaranteed to run at an exact time. Applied to the
  Alarms caution, the Rules intro, the setAlarm bullet, and the storage
  partial.

Verified: example and tests type-check; good example passes; the
setAlarm(Date.now()) and no-deadline variants fail the intended tests.
pnpm run check and pnpm run build pass.
@cloudflare-docs-bot
cloudflare-docs-bot Bot force-pushed the harshil/do-alarm-loop-guardrails branch from bcd0280 to d41cba6 Compare October 19, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. product:billing product:durable-objects Durable Objects: https://developers.cloudflare.com/workers/learning/using-durable-objects/ size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants