Running and results¶
What a run returns, the events it streams, and how it pauses and resumes. See Running, Streaming and Interrupts.
| Name | What it is |
|---|---|
| Results | |
GraphResult | Outcome of Graph.ainvoke. |
| Stream events | |
StreamEvent | One event produced while a graph runs. |
FinalEventData | Data of the final event: final state and thread. |
InterruptEventData | Data of an interrupt event: state, thread and pending interrupts. |
| Interrupts | |
interrupt | Pause the current node until the interrupt is answered. |
Interrupt | A pending interrupt of a paused run. |
Resume | Answers for every pending interrupt of a paused thread. |
Results¶
GraphResult¶
GraphResult(state, step, data=dict(), thread_id=None, checkpoint_id=None, status='completed', interrupts=dict())
Outcome of Graph.ainvoke.
state | StateT |
Final state as the declared schema type. |
step | int |
Superstep in which the run finished or paused, counted from 0. |
data | dict[str, Any] |
Final state as a plain dict. |
thread_id | str | None |
Thread the run used. |
checkpoint_id | str | None |
Id of the run's last history event. |
status | str |
|
interrupts | dict[str, Interrupt] |
Pending interrupts by |
Stream events¶
StreamEvent¶
StreamEvent(mode, data=None, node=None, run_id=None, checkpoint_id=None, step=None, task_id=None)
One event produced while a graph runs.
mode | str |
|
data | InterruptEventData | FinalEventData | Any |
A task's update dict or |
node | str | None |
Node of the event; |
run_id | str | None |
Run that produced the event. |
checkpoint_id | str | None |
History event to load the event's state at: |
step | int | None |
Superstep of the run, counted from 0. |
task_id | str | None |
Task the event belongs to; |
FinalEventData¶
FinalEventData(state, thread_id)
Data of the final event: final state and thread.
state | dict[str, Any] | |
thread_id | str | |
InterruptEventData¶
InterruptEventData(state, thread_id, interrupts)
Data of an interrupt event: state, thread and pending interrupts.
state | dict[str, Any] |
State of the paused run. |
thread_id | str |
Thread of the run. |
interrupts | dict[str, Interrupt] |
Pending interrupts keyed by |
Interrupts¶
interrupt¶
interrupt(payload, *, id) -> Any
Pause the current node until the interrupt is answered.
An on_interrupt hook may answer at once; otherwise the run pauses. On
resume the node runs again from the top, and this call returns the
answer. See Interrupts.
payload | Any |
Question or data for whoever answers. |
id | str |
Unique within one run of the node; letters, digits, |
Any |
The answer, normalized to JSON values. |
ValueError |
If |
GraphExecutionError |
If the node already used |
RuntimeError |
If called outside a running node. |
TypeError |
If an |
Interrupt¶
Interrupt(key, id, node, task_id, payload)
A pending interrupt of a paused run.
key | str |
Key for |
id | str |
The |
node | str |
Node that paused; the subgraph node for a child graph's interrupt. |
task_id | str |
Task of that node. |
payload | Any |
Payload passed to |
Resume¶
Resume(value=_NO_VALUE, *, answers=None)
Answers for every pending interrupt of a paused thread.
value | Any |
Answer for the only pending interrupt. |
answers | Mapping[str, Any] | None |
Answers by |
TypeError |
If |
ResumeError |
If both or neither of |
value | Any |
The single answer; |
answers | dict[str, Any] | None |
The answers by key; |