Skip to content

Add workflow idempotency keys so active runs deduplicate - #1998

Draft
ericclemmons wants to merge 1 commit into
mainfrom
codex/workflow-idempotency-key
Draft

Add workflow idempotency keys so active runs deduplicate#1998
ericclemmons wants to merge 1 commit into
mainfrom
codex/workflow-idempotency-key

Conversation

@ericclemmons

Copy link
Copy Markdown
Member

tl;dr – Add active-lifetime idempotencyKey support to runWorkflow() so concurrent callers reuse one Workflow instance.

Agents currently persist Workflow tracking only after workflow.create() returns. Concurrent callers can therefore both create instances before either tracking row exists, and callers that compensate with blockConcurrencyWhile() hold a Durable Object lock across external I/O.

This change atomically claims (workflow_name, idempotency_key) in Agent SQLite before the Workflow RPC. Calls with an occupied key return the active Workflow ID. Terminal tracking rows remain retained, while their key becomes available for a new Workflow instance.

The proposed RFC keeps queue, cancel, and replace concurrency policies out of this initial primitive because they require durable payload storage and lifecycle orchestration.


References: Durable Objects concurrency guidance

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 28c4354

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Minor
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant