Skip to content

Commit d4ef8bf

Browse files
authored
interrupt - docstring - fix formatting (#1074)
1 parent de802fb commit d4ef8bf

File tree

1 file changed

+14
-53
lines changed

1 file changed

+14
-53
lines changed

src/strands/types/interrupt.py

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,22 @@
11
"""Interrupt related type definitions for human-in-the-loop workflows.
22
33
Interrupt Flow:
4-
┌─────────────────┐
5-
│ Agent Invoke │
6-
└────────┬────────┘
7-
8-
9-
┌─────────────────┐
10-
│ Hook Calls │
11-
| on Event |
12-
└────────┬────────┘
13-
14-
15-
┌─────────────────┐ No ┌─────────────────┐
16-
│ Interrupts │ ────────► │ Continue │
17-
│ Raised? │ │ Execution │
18-
└────────┬────────┘ └─────────────────┘
19-
│ Yes
20-
21-
┌─────────────────┐
22-
│ Stop Event Loop │◄───────────────────┐
23-
└────────┬────────┘ |
24-
│ |
25-
▼ |
26-
┌─────────────────┐ |
27-
│ Return | |
28-
| Interrupts │ |
29-
└────────┬────────┘ |
30-
│ |
31-
▼ |
32-
┌─────────────────┐ |
33-
│ Agent Invoke │ |
34-
│ with Responses │ |
35-
└────────┬────────┘ |
36-
│ |
37-
▼ |
38-
┌─────────────────┐ |
39-
│ Hook Calls │ |
40-
| on Event | |
41-
| with Responses | |
42-
└────────┬────────┘ |
43-
│ |
44-
▼ |
45-
┌─────────────────┐ Yes ┌────────┴────────┐
46-
│ New Interrupts │ ────────► │ Store State │
47-
│ Raised? │ │ │
48-
└────────┬────────┘ └─────────────────┘
49-
│ No
50-
51-
┌─────────────────┐
52-
│ Continue │
53-
│ Execution │
54-
└─────────────────┘
4+
```mermaid
5+
flowchart TD
6+
A[Invoke Agent] --> B[Execute Hook/Tool]
7+
B --> C{Interrupts Raised?}
8+
C -->|No| D[Continue Agent Loop]
9+
C -->|Yes| E[Stop Agent Loop]
10+
E --> F[Return Interrupts]
11+
F --> G[Respond to Interrupts]
12+
G --> H[Execute Hook/Tool with Responses]
13+
H --> I{New Interrupts?}
14+
I -->|Yes| E
15+
I -->|No| D
16+
```
5517
5618
Example:
57-
```
19+
```Python
5820
from typing import Any
5921
6022
from strands import Agent, tool
@@ -99,7 +61,6 @@ def approve(self, event: BeforeToolCallEvent) -> None:
9961
```
10062
10163
Details:
102-
10364
- User raises interrupt on their hook event by calling `event.interrupt()`.
10465
- User can raise one interrupt per hook callback.
10566
- Interrupts stop the agent event loop.

0 commit comments

Comments
 (0)