Skip to content

Commit f8d6c8f

Browse files
committed
Add WorkflowIDConflictPolicy.USE_EXISTING to approval start_workflow
Followup to a898cf4. The approval handler relies on a deterministic workflow ID so that activity retries re-attach to the existing approval workflow rather than spamming the operator. Without an explicit conflict policy, the default ALLOW_DUPLICATE silently allows a new approval workflow to start once the previous one closes. USE_EXISTING enforces the contract: if a workflow with this ID is running, attach to it; otherwise allow a fresh one.
1 parent d417831 commit f8d6c8f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tool_registry_incident_triage/triage_activity.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import httpx
2727
from temporalio import activity
2828
from temporalio.client import Client
29+
from temporalio.common import WorkflowIDConflictPolicy
2930
from temporalio.contrib.tool_registry import (
3031
ToolRegistry,
3132
agentic_session,
@@ -361,5 +362,9 @@ async def _real_request_human_approval(
361362
task_queue=task_queue,
362363
start_signal="approval-request",
363364
start_signal_args=[request],
365+
# If the activity retries while the approval workflow is still running,
366+
# attach to the existing one rather than starting a new approval. The
367+
# operator should not get a second prompt for the same incident.
368+
id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,
364369
)
365370
return await handle.result()

0 commit comments

Comments
 (0)