Skip to content

add destroyed flag and yield ctx.abort#26558

Merged
mattzcarey merged 3 commits into
productionfrom
sync-docs-pr-653
Jan 16, 2026
Merged

add destroyed flag and yield ctx.abort#26558
mattzcarey merged 3 commits into
productionfrom
sync-docs-pr-653

Conversation

@threepointone

Copy link
Copy Markdown
Contributor

$PR_BODY_TEXT

Updates documentation to reflect that destroy() can now be safely called
within scheduled task callbacks. The Agent properly handles cleanup by:
- Setting an internal flag to skip remaining database updates
- Yielding ctx.abort() to the event loop for clean alarm handler completion

This addresses the fix in cloudflare/agents#653 where calling destroy()
inside a schedule previously caused errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@threepointone
threepointone requested a review from a team November 17, 2025 10:54
@github-actions github-actions Bot added product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/s labels Nov 17, 2025
Updates documentation to reflect that destroy() can now be safely called
from within scheduled task callbacks. The Agent SDK now:
- Sets an internal flag to prevent database updates after destruction
- Defers ctx.abort() to the event loop to allow handlers to complete

Related to cloudflare/agents#653

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/agents/ @irvinebroque, @rita3ko, @elithrar, @thomasgauvin, @threepointone, @cloudflare/pcx-technical-writing

Updates schedule-tasks.mdx to reflect changes from cloudflare/agents#653:

- Add example showing immediate task scheduling (delay = 0)
- Document safe usage of destroy() within scheduled callbacks
- Explain that Agent SDK defers destruction to ensure scheduled tasks complete

Addresses the fix for issue #616 where calling destroy() inside a schedule
would cause errors and retry loops.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@threepointone

Copy link
Copy Markdown
Contributor Author

Updated documentation to include:

  • Example of immediate task scheduling (delay = 0)
  • New section on lifecycle management with scheduled tasks
  • Documentation of safe destroy() usage within scheduled callbacks

These changes reflect the fixes from cloudflare/agents#653 for issue #616.

@github-actions

Copy link
Copy Markdown
Contributor

Hey there, we've marked this pull request as stale because there's no recent activity on it. This label is helps us identify PRs that might need updates (or to be closed out by our team if no longer relevant).

@github-actions github-actions Bot added the stale label Dec 29, 2025
@mattzcarey
mattzcarey merged commit 140b600 into production Jan 16, 2026
8 checks passed
@mattzcarey
mattzcarey deleted the sync-docs-pr-653 branch January 16, 2026 14:17
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. size/s stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants