-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathrun_workflow.py
More file actions
35 lines (24 loc) · 990 Bytes
/
Copy pathrun_workflow.py
File metadata and controls
35 lines (24 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Start the hook-based HITL workflow and send an approval signal."""
import asyncio
import os
from temporalio.client import Client
from strands_plugin.human_in_the_loop.workflow import HumanInTheLoopWorkflow
async def main() -> None:
client = await Client.connect(os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"))
handle = await client.start_workflow(
HumanInTheLoopWorkflow.run,
"Please delete /tmp/sensitive.txt",
id="strands-human-in-the-loop",
task_queue="strands-human-in-the-loop",
)
# Poll until the agent reaches the approval interrupt.
reason = None
while reason is None:
await asyncio.sleep(0.5)
reason = await handle.query(HumanInTheLoopWorkflow.pending_approval)
print(f"Approval requested: {reason}")
await handle.signal(HumanInTheLoopWorkflow.approve, "approve")
result = await handle.result()
print(f"Result: {result}")
if __name__ == "__main__":
asyncio.run(main())