-
Notifications
You must be signed in to change notification settings - Fork 469
Description
After adding the Cloudflare Agent AIChatAgent class and exporting it in my main file, running wrangler deploy often results in:
[ERROR] Your Worker failed validation because it exceeded startup limits
I have used the Cloudflare tool npx wrangler check startup to generate a worker-startup.cpuprofile and I use this bash script to output the duration
jq -r '(.endTime - .startTime) / 1000' worker-startup.cpuprofileMy current worker has a startup time of 31ms without the agent, and over 200ms with the agent. I tried to use dynamic imports to defer the imports to runtime, and it improved the situration a bit, but it was still very high. Unfortunately, I can't defer the AIChatAgent class that my class extends.
I then created this very very minimal test repo: https://github.com/dnyg/cf-agent-test
Here I have an example of a worker with only "agents" as a dependency and a hardcoded fetch response along with an implementation of AIChatAgent where everything is default.
Without the agent this worker has a startup time of 13-14ms. With the worker it is 34ms (a big increase - 250% - but not as breaking as what I'm experiencing on my actual worker).
As I understand, it is not possible to point to the location of your Durable Object within your wrangler.jsonc file - it has to be exported in the main file.
I am not sure what exactly is causing my cpu startup time to skyrocket, but I assume it might be differences in versions of the ai and zod packages within my project, and agents.
Any ideas to what I can do to again be able to deploy? For now I will probably just move it to a seperate worker, and suffer the cpu startup time there.