fix(task-create): handle WorkflowAlreadyStartedError gracefully - #489
Merged
Conversation
alvinkam2001
force-pushed
the
akam/task-create-idempotency
branch
from
August 7, 2026 00:33
dbfcca6 to
58c27ea
Compare
jromualdez-scale
left a comment
Contributor
There was a problem hiding this comment.
Took a look — the change itself makes sense to me. The reuse vs conflict policy distinction is the right diagnosis and USE_EXISTING is literally what temporalio documents for this ("Set to USE_EXISTING for idempotent deduplication on workflow ID"), so no concerns there.
Couple of non-blocking comments on the wrapper API below.
jromualdez-scale
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
task/createidempotent in the Temporal ACP path. Duplicate submits for the same task ID (e.g. load-balanced agentex-agent replicas racing on the same notification) no longer surfaceWorkflowAlreadyStartedError, Temporal returns the existing workflow handle instead.Change
TemporalTaskService.submit_tasknow passesid_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING.TemporalClient.start_workflowaccepts anid_conflict_policyparam (defaults toUNSPECIFIED, preserving current behavior for any other caller).Why
WorkflowIDReusePolicy.ALLOW_DUPLICATE(already set) only governs reuse after a run closes — it doesn't help when a run is currently open. Workflows are mainly just noise as the workflow still runsTest plan
tests/lib/core/services/test_temporal_task_service.py:submit_taskpassesUSE_EXISTINGto the clientTemporalClient.start_workflowforwardsid_conflict_policywhen setTemporalClient.start_workflowdefaults toUNSPECIFIED(backwards-compat)TemporalTaskServicetests still passtask/createcalls with the same task ID, confirm both return 200 with the same workflow ID and no error logGreptile Summary
The PR makes Temporal-backed
task/createsubmissions idempotent while preserving the existing default behavior for other workflow starts.USE_EXISTINGwhen submitting task workflows.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Caller participant TaskService as TemporalTaskService participant Wrapper as TemporalClient participant Temporal Caller->>TaskService: submit_task(task ID) TaskService->>Wrapper: start_workflow(USE_EXISTING) Wrapper->>Temporal: "start_workflow(id_conflict_policy=USE_EXISTING)" alt Workflow ID is already running Temporal-->>Wrapper: Existing workflow handle else Workflow ID is available Temporal-->>Wrapper: New workflow handle end Wrapper-->>TaskService: Workflow ID TaskService-->>Caller: Workflow IDReviews (3): Last reviewed commit: "address comments" | Re-trigger Greptile