Execution state
Execution state management for graph execution in PyAgenity.
This module provides the ExecutionState class and related enums to track progress, interruptions, and pause/resume functionality for agent graph execution.
Classes:
Name | Description |
---|---|
ExecutionState |
Tracks the internal execution state of a graph. |
ExecutionStatus |
Status of graph execution. |
StopRequestStatus |
Status of graph execution. |
Attributes:
Name | Type | Description |
---|---|---|
logger |
|
Attributes¶
Classes¶
ExecutionState
¶
Bases: BaseModel
Tracks the internal execution state of a graph.
This class manages the execution progress, interrupt status, and internal data that should not be exposed to users.
Methods:
Name | Description |
---|---|
advance_step |
Advance to the next execution step. |
clear_interrupt |
Clear the interrupt state and resume execution. |
complete |
Mark execution as completed. |
error |
Mark execution as errored. |
from_dict |
Create an ExecutionState instance from a dictionary. |
is_interrupted |
Check if execution is currently interrupted. |
is_running |
Check if execution is currently running. |
is_stopped_requested |
Check if a stop has been requested for execution. |
set_current_node |
Update the current node in execution state. |
set_interrupt |
Set the interrupt state for execution. |
Attributes:
Name | Type | Description |
---|---|---|
current_node |
str
|
|
internal_data |
dict[str, Any]
|
|
interrupt_data |
dict[str, Any] | None
|
|
interrupt_reason |
str | None
|
|
interrupted_node |
str | None
|
|
status |
ExecutionStatus
|
|
step |
int
|
|
stop_current_execution |
StopRequestStatus
|
|
thread_id |
str | None
|
|
Source code in pyagenity/state/execution_state.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
Attributes¶
Functions¶
advance_step
¶
advance_step()
Advance to the next execution step.
Source code in pyagenity/state/execution_state.py
134 135 136 137 138 139 140 |
|
clear_interrupt
¶
clear_interrupt()
Clear the interrupt state and resume execution.
Source code in pyagenity/state/execution_state.py
110 111 112 113 114 115 116 117 118 |
|
complete
¶
complete()
Mark execution as completed.
Source code in pyagenity/state/execution_state.py
153 154 155 156 157 158 |
|
error
¶
error(error_msg)
Mark execution as errored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
Error message to record. |
required |
Source code in pyagenity/state/execution_state.py
160 161 162 163 164 165 166 167 168 169 |
|
from_dict
classmethod
¶
from_dict(data)
Create an ExecutionState instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
dict[str, Any]
|
Dictionary containing execution state fields. |
required |
Returns:
Name | Type | Description |
---|---|---|
ExecutionState |
ExecutionState
|
The deserialized execution state object. |
Source code in pyagenity/state/execution_state.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
is_interrupted
¶
is_interrupted()
Check if execution is currently interrupted.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if interrupted, False otherwise. |
Source code in pyagenity/state/execution_state.py
120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
is_running
¶
is_running()
Check if execution is currently running.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if running, False otherwise. |
Source code in pyagenity/state/execution_state.py
171 172 173 174 175 176 177 178 179 180 |
|
is_stopped_requested
¶
is_stopped_requested()
Check if a stop has been requested for execution.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if stop requested, False otherwise. |
Source code in pyagenity/state/execution_state.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
set_current_node
¶
set_current_node(node)
Update the current node in execution state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
Node to set as current. |
required |
Source code in pyagenity/state/execution_state.py
142 143 144 145 146 147 148 149 150 151 |
|
set_interrupt
¶
set_interrupt(node, reason, status, data=None)
Set the interrupt state for execution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
Node where the interrupt occurred. |
required |
|
str
|
Reason for the interrupt. |
required |
|
ExecutionStatus
|
Status to set for the interrupt. |
required |
|
dict[str, Any] | None
|
Optional additional interrupt data. |
None
|
Source code in pyagenity/state/execution_state.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
ExecutionStatus
¶
Bases: Enum
Status of graph execution.
Attributes:
Name | Type | Description |
---|---|---|
COMPLETED |
|
|
ERROR |
|
|
INTERRUPTED_AFTER |
|
|
INTERRUPTED_BEFORE |
|
|
RUNNING |
|
Source code in pyagenity/state/execution_state.py
18 19 20 21 22 23 24 25 |
|
Attributes¶
StopRequestStatus
¶
Bases: Enum
Status of graph execution.
Attributes:
Name | Type | Description |
---|---|---|
NONE |
|
|
STOPPED |
|
|
STOP_REQUESTED |
|
Source code in pyagenity/state/execution_state.py
28 29 30 31 32 33 |
|