Patch Changes
-
#837
b11b9ddThanks @threepointone! - Fix AgentWorkflow run() method not being called in productionThe
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_initAgentnever being called.Changed to wrap the subclass prototype's
runmethod directly with proper safeguards:- Uses
Object.hasOwn()to only wrap prototypes that define their ownrunmethod (prevents double-wrapping inherited methods) - Uses a
WeakSetto track wrapped prototypes (prevents re-wrapping on subsequent instantiations) - Uses an instance-level
__agentInitCalledflag to prevent double initialization ifsuper.run()is called from a subclass
- Uses