Repository navigation
Run each Cloudflare conversation as a single Agents SDK state machine #737
astrobot-houston
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Continues discussion #709 and supersedes #700: the Cloudflare coordinator now runs each conversation as one durable state machine on the Agents SDK engine, instead of a drive run plus one attempt run per submission.
Depends on the unreleased Agents SDK engine in cloudflare/agents#2301 (which is stacked on #2274). Draft until an
agentsrelease carries it; locally it was built against that branch through a workspacelink:override that is not committed.What changes
flue:conversation@v1, at a fixed address. Itsidlephase parks on the run's mailbox — holding no alarm — until admission or an abort sends it a wake, then claims the next runnable head from the submission ledger. Itsturnphase processes that submission to settlement and returns toidle, where the next queued head is claimed in the same invocation. The submission ledger stays the record of what was accepted and how it settled (it is shared with the Node target); the machine is its executor.reconcileInterruptedSubmission, same classification.onCancel, which aborts and orphans the attempt's controller (so a zombie's appends are refused) and returns the machine toidle, where the ledger settles the submission through the timeout classification. Live turns heartbeat the watchdog until the submission's own timeout, which aborts their work from inside.taskDefinitions; the coordinator losesensureDrive,ensureAttemptRun,hasLiveAttemptRunand the per-attempt run ids (~600 lines net).Verified
pnpm check:types(109 tasks), the runtime and vite builds, and the runtime unit tests pass. Live onexamples/cloudflareagainst the engine build: a prompt settlescompleted; two prompts queued back-to-back settle with the second joined at the turn boundary; an abort mid-response settlesabortedand a follow-up prompt completes; killing the dev server mid-response and restarting it replays the turn, which continues from the durable partial stream and settlescompleted. The machine's row parkswaitingon its mailbox with no wake job while the conversation is quiet.Docs: the "Durable agent execution" section of the Cloudflare target guide and "Cloudflare recovery" in the durability guide describe the new model.
Original implementation from #736 by @mattzcarey
All reactions