[v7 follow-up] CFW Workflows multi-turn execute() continuation (write-once instance id + stream reactivation)
Spun out of #74 (cross-runtime multi-turn continuation). #74 made executor.execute(agent, msg, { sessionId }) continue a completed session into a new turn on runtime-js, runtime-dbos, runtime-temporal, and CF-DO. Cloudflare Workflows (CFW) is the one remaining runtime where multi-turn continuation does not work.
Why CFW is blocked (two gaps)
- Write-once instance id.
CloudflareAgentExecutor.execute()creates the workflow instance with idagent__<name>__<sessionId>(packages/runtime-cloudflare/src/executor.ts:~534). Cloudflare Workflows rejects creating an instance whose id already exists, so a 2ndexecute()on the same sessionId collides after turn 1. Fix: mint a per-turn id (mirror the__resume__<N>/__retry__<N>convention already used by resume/retry, e.g.__turn__<N>fromincrementResumeCount) and routegetHandle/status/interrupt throughgetCurrentRun(sessionId)to resolve the latest turn's instance id (the id is no longer derivable from sessionId alone). Guard concurrency with the existingcompareAndSetStatusCAS. - Stream reactivation. Like the other durable runtimes, turn 1's completion leaves the sessionId-keyed stream
'ended'; the CFW execute() path must callreactivateStream(streamId)on continuation (it already does this inretry(), ~lines 986-993).reactivateStream/getStreamInfoexist on both the DO and binding-side stream managers.
Why it wasn't done in #74
CFW Workflows multi-turn is not validatable in this repo: vitest-pool-workers cannot create real Workflow instances (the existing *.workflow.test.ts skip workflow-creation cases for exactly this reason — they note full workflow tests need wrangler dev or a real Miniflare setup). Shipping the per-turn-id + reconstruction machinery without an executable test would violate the project's no-unvalidated-work discipline. The cross-runtime matrix also does not cover CFW multi-turn.
Scope to do here
- Per-turn instance id on continuation +
getCurrentRun-based handle reconstruction. reactivateStream-on-continuation in CFWexecute().- A validation path: either a
wrangler dev-based integration test or a documented manual-validation procedure. - Mind idempotent-retry double-spawn: increment the per-turn counter exactly once per turn transition.
Priority: medium. Most production multi-turn flows on Cloudflare use the DO runtime (which already works as of #74); CFW Workflows multi-turn is the gap.
Design reference: docs/superpowers/specs/2026-05-23-cross-runtime-multiturn-continuation-design.md (CFW section).