agents@0.3.9

cloudflare/agentsagents@0.3.9Feb 4, 2026by github-actions[bot]

AI Summary

Addresses a critical bug where the run() method was not being called in production environments due to prototype chain invocation issues.

Key Highlights

  • Fixed AgentWorkflow run() method not being called in production.
  • Corrected prototype chain invocation logic using Object.hasOwn() and WeakSet.

Full Release Notes

### Patch Changes

-   [#837](https://github.com/cloudflare/agents/pull/837) [`b11b9dd`](https://github.com/cloudflare/agents/commit/b11b9dda37d85a474b07e6ca48fb8cee566db9cc) Thanks [@threepointone](https://github.com/threepointone)! - Fix AgentWorkflow run() method not being called in production

    The `run()` method wrapper was being set as an instance property in the constructor, but Cloudflare's RPC system invokes methods from the prototype chain. This caused the initialization wrapper to be bypassed in production, resulting in `_initAgent` never being called.

    Changed to wrap the subclass prototype's `run` method directly with proper safeguards:

    -   Uses `Object.hasOwn()` to only wrap prototypes that define their own `run` method (prevents double-wrapping inherited methods)
    -   Uses a `WeakSet` to track wrapped prototypes (prevents re-wrapping on subsequent instantiations)
    -   Uses an instance-level `__agentInitCalled` flag to prevent double initialization if `super.run()` is called from a subclass