File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,8 @@ class RunResult(RunResultBase):
159159 _current_turn_persisted_item_count : int = 0
160160 """Number of items from new_items already persisted to session for the
161161 current turn."""
162+ _current_turn : int = 0
163+ """The current turn number. This is preserved when converting to RunState."""
162164 _original_input : str | list [TResponseInputItem ] | None = field (default = None , repr = False )
163165 """The original input from the first turn. Unlike `input`, this is never updated during the run.
164166 Used by to_state() to preserve the correct originalInput when serializing state."""
@@ -229,6 +231,7 @@ def to_state(self) -> Any:
229231 state ._input_guardrail_results = self .input_guardrail_results
230232 state ._output_guardrail_results = self .output_guardrail_results
231233 state ._last_processed_response = self ._last_processed_response
234+ state ._current_turn = self ._current_turn
232235 state ._current_turn_persisted_item_count = self ._current_turn_persisted_item_count
233236 state .set_tool_use_tracker_snapshot (self ._tool_use_tracker_snapshot )
234237
Original file line number Diff line number Diff line change @@ -1241,6 +1241,7 @@ def _get_approval_identity(
12411241 ),
12421242 max_turns = max_turns ,
12431243 )
1244+ result ._current_turn = current_turn
12441245 result ._original_input = _copy_str_or_list (original_input )
12451246 return result
12461247
@@ -1286,6 +1287,7 @@ def _get_approval_identity(
12861287 ),
12871288 max_turns = max_turns ,
12881289 )
1290+ result ._current_turn = current_turn
12891291 if server_conversation_tracker is None :
12901292 # Save both input and output items together at the end.
12911293 # When resuming from state, session_input_items_for_save
@@ -1651,6 +1653,7 @@ def _get_approval_identity(
16511653 ),
16521654 max_turns = max_turns ,
16531655 )
1656+ result ._current_turn = current_turn
16541657 if run_state is not None :
16551658 result ._current_turn_persisted_item_count = (
16561659 run_state ._current_turn_persisted_item_count
@@ -1706,6 +1709,7 @@ def _get_approval_identity(
17061709 ),
17071710 max_turns = max_turns ,
17081711 )
1712+ result ._current_turn = current_turn
17091713 if run_state is not None :
17101714 result ._current_turn_persisted_item_count = (
17111715 run_state ._current_turn_persisted_item_count
You can’t perform that action at this time.
0 commit comments