Repository navigation
Replatform Cloudflare submission execution onto Agents SDK Tasks #709
Replies: 1 comment
|
Possibly related contribution from @mattzcarey — opened #700 which appears to be addressing this. Their summary: This PR replaces the hand-rolled supervision machinery in Flue's Cloudflare target (drain scheduling, heartbeats, fiber management, deadline enforcement) with the Agents SDK's Tasks capability. Two task definitions handle reconciliation and per-submission attempt processing, leveraging the SDK's built-in claim backstop, replay, and signal/deadline management. It also changes abort behavior so signal-ignoring attempts now settle at the submission timeout instead of a fixed 60-second grace period. Implementation: withastro/flue@feat/replatform-coordinator-on-agents-tasks (diff) This comment was posted automatically when #700 was redirected. The implementation is preserved on the branch above so it can inform the work here. |
Uh oh!
There was an error while loading. Please reload this page.
What
Flue's Cloudflare target already extends the Agents SDK
Agentclass; this replatforms its execution layer onto the SDK'sTaskscapability and deletes the hand-rolled supervision: the zero-delay drain plus 30s heartbeat onschedule(), the in-isolate supervisor chain, detachedrunFiberattempt fibers withonFiberRecovered, deadline enforcement over live fibers with a 60s force-settle grace, and the__flueWakeAgentSubmissionsschedule target.Two Task definitions are declared on the generated class via
taskDefinitions(resolved by the SDK on every wake, so replay is correct by construction):flue:drive@v1— one bounded reconcile pass: materialize unready rows, finalize pending settlements, recover interrupted running rows, claim runnable heads, start an attempt run per claim, complete. One run id per object; every former "arm the drain" boundary (admission, abort,onStart, attempt settlement, Task failures) ensures it and joins a live one for free.flue:attempt@v1— one submission processed to settlement in the handler body. The flue abort controller is linked tostep.signal; the submission's durability timeout is the run'sdeadline. The SDK owns the claim backstop that survives eviction, replays the run on a fresh isolate after an interruption (the body reconciles from stream evidence first, then processes the replacement attempt), and settles over a signal-deaf attempt at the deadline, fencing its later writes; the next drive settles the submission through the existing timeout classification.Unchanged: the submission ledger (now the inbox), the canonical stream, admission and dispatch paths,
processSubmission,reconcileInterruptedSubmission, the extension mechanism, and thealarm()context wrapper for extension-authored schedule callbacks.Behavior change worth knowing: abort of an attempt that ignores its signal now settles at the submission timeout rather than after a fixed 60s grace. Stale
__flueWakeAgentSubmissionsschedule rows from earlier deploys logcallback not foundonce and complete.@flue/runtimestill never importsagents: the Tasks surface is typed structurally, as before.Verification
pnpm check:typesandbiome lintare green (knip's unused-export findings are pre-existing onmain). Against a local build of the agents PR branch,examples/cloudflareundervite devwith the Workers AI binding:completed;completed;POST /abortmid-response settlesaborted;cf_agents_task_runs.Original implementation from #700 by @mattzcarey
All reactions