Skip to content

Commit e4b4c0c

Browse files
brianstrauchclaude
andcommitted
Fix interrupt sample: make delete_thing idempotent
The activity was toggling its `_APPROVED` state (add on raise, discard on success), so after the human approved once, a follow-up tool call from the model would interrupt again with no further approval coming — hanging the test. Drop the discard so once approved, the name stays approved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b376e8e commit e4b4c0c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

strands_plugin/interrupt/workflow.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727
@activity.defn
2828
async def delete_thing(name: str) -> str:
2929
if name not in _APPROVED:
30-
# First attempt: register that approval is needed and stop the agent.
31-
# In production, this branch would check a real authorization service
32-
# and only raise when the resource is protected; here, marking the
33-
# name as approved on the way out simulates the human flipping the
34-
# flag during the interrupt pause.
30+
# First attempt: mark the name as approved on the way out (simulating
31+
# the human flipping a flag during the interrupt pause) and stop the
32+
# agent. In production this branch would check a real authorization
33+
# service and only raise when the resource is protected.
3534
_APPROVED.add(name)
3635
raise InterruptException(
3736
Interrupt(
@@ -40,7 +39,6 @@ async def delete_thing(name: str) -> str:
4039
reason=f"approve delete of protected resource '{name}'?",
4140
)
4241
)
43-
_APPROVED.discard(name)
4442
return f"deleted {name}"
4543

4644

0 commit comments

Comments
 (0)