Skip to content

Conversation

@threepointone
Copy link
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 <[email protected]>
@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 <[email protected]>
@github-actions
Copy link
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 <[email protected]>
@threepointone
Copy link
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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants