Uh oh!
There was an error while loading. Please reload this page.
fix(task-create): handle WorkflowAlreadyStartedError gracefully - #489
Open
alvinkam2001 wants to merge 1 commit into
Open
fix(task-create): handle WorkflowAlreadyStartedError gracefully#489alvinkam2001 wants to merge 1 commit into
alvinkam2001 wants to merge 1 commit into
Conversation
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 freeto 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 a workflow with the same task ID remains active.TemporalClient.start_workflow.USE_EXISTINGfor task submission while retainingALLOW_DUPLICATEbehavior for closed executions.Confidence Score: 5/5
The PR appears safe to merge, with no actionable correctness, compatibility, or security issues identified.
The active-workflow conflict behavior is scoped to task submission, the existing closed-run reuse policy remains intact, the Temporal dependency supports the new API, and tests cover policy selection and forwarding.
Important Files Changed
USE_EXISTINGfor duplicate active task workflow IDs without changing closed-run reuse behavior.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[task/create request] --> B[TemporalTaskService.submit_task] B --> C[Start workflow with task ID] C --> D{Execution with ID active?} D -- Yes --> E[USE_EXISTING returns existing handle] D -- No, prior run closed --> F[ALLOW_DUPLICATE starts new run] D -- No prior run --> G[Start first workflow run] E --> H[Return workflow ID] F --> H G --> HReviews (1): Last reviewed commit: "handle same workflow task/create gracefu..." | Re-trigger Greptile