|
29 | 29 | ) |
30 | 30 |
|
31 | 31 | if TYPE_CHECKING: |
32 | | - from ._run_impl import QueueCompleteSentinel |
| 32 | + from ._run_impl import ProcessedResponse, QueueCompleteSentinel |
33 | 33 | from .agent import Agent |
34 | 34 | from .tool_guardrails import ToolInputGuardrailResult, ToolOutputGuardrailResult |
35 | 35 |
|
@@ -116,6 +116,8 @@ def last_response_id(self) -> str | None: |
116 | 116 | @dataclass |
117 | 117 | class RunResult(RunResultBase): |
118 | 118 | _last_agent: Agent[Any] |
| 119 | + _last_processed_response: ProcessedResponse | None = field(default=None, repr=False) |
| 120 | + """The last processed model response. This is needed for resuming from interruptions.""" |
119 | 121 |
|
120 | 122 | @property |
121 | 123 | def last_agent(self) -> Agent[Any]: |
@@ -162,6 +164,7 @@ def to_state(self) -> Any: |
162 | 164 | state._model_responses = self.raw_responses |
163 | 165 | state._input_guardrail_results = self.input_guardrail_results |
164 | 166 | state._output_guardrail_results = self.output_guardrail_results |
| 167 | + state._last_processed_response = self._last_processed_response |
165 | 168 |
|
166 | 169 | # If there are interruptions, set the current step |
167 | 170 | if self.interruptions: |
@@ -202,6 +205,9 @@ class RunResultStreaming(RunResultBase): |
202 | 205 | is_complete: bool = False |
203 | 206 | """Whether the agent has finished running.""" |
204 | 207 |
|
| 208 | + _last_processed_response: ProcessedResponse | None = field(default=None, repr=False) |
| 209 | + """The last processed model response. This is needed for resuming from interruptions.""" |
| 210 | + |
205 | 211 | # Queues that the background run_loop writes to |
206 | 212 | _event_queue: asyncio.Queue[StreamEvent | QueueCompleteSentinel] = field( |
207 | 213 | default_factory=asyncio.Queue, repr=False |
@@ -443,6 +449,7 @@ def to_state(self) -> Any: |
443 | 449 | state._input_guardrail_results = self.input_guardrail_results |
444 | 450 | state._output_guardrail_results = self.output_guardrail_results |
445 | 451 | state._current_turn = self.current_turn |
| 452 | + state._last_processed_response = self._last_processed_response |
446 | 453 |
|
447 | 454 | # If there are interruptions, set the current step |
448 | 455 | if self.interruptions: |
|
0 commit comments