@@ -225,6 +225,72 @@ async def fake_run_single_turn(**_kwargs):
225225 assert "function_call" in saved_types
226226
227227
228+ @pytest .mark .parametrize (
229+ ("conversation_id" , "previous_response_id" , "auto_previous_response_id" ),
230+ [
231+ ("conv_1" , None , False ),
232+ (None , "resp_prev" , False ),
233+ (None , None , True ),
234+ ],
235+ )
236+ @pytest .mark .asyncio
237+ async def test_resumed_interruption_passes_server_managed_conversation_flag (
238+ monkeypatch : pytest .MonkeyPatch ,
239+ conversation_id : str | None ,
240+ previous_response_id : str | None ,
241+ auto_previous_response_id : bool ,
242+ ) -> None :
243+ agent = Agent (name = "resume-agent" )
244+ context_wrapper : RunContextWrapper [dict [str , str ]] = RunContextWrapper (context = {})
245+ state = RunState (
246+ context = context_wrapper ,
247+ original_input = "input" ,
248+ starting_agent = agent ,
249+ max_turns = 1 ,
250+ conversation_id = conversation_id ,
251+ previous_response_id = previous_response_id ,
252+ auto_previous_response_id = auto_previous_response_id ,
253+ )
254+
255+ state ._current_step = NextStepInterruption (interruptions = [])
256+ state ._model_responses = [
257+ ModelResponse (output = [], usage = Usage (), response_id = "resp_1" ),
258+ ]
259+ state ._last_processed_response = ProcessedResponse (
260+ new_items = [],
261+ handoffs = [],
262+ functions = [],
263+ computer_actions = [],
264+ local_shell_calls = [],
265+ shell_calls = [],
266+ apply_patch_calls = [],
267+ tools_used = [],
268+ mcp_approval_requests = [],
269+ interruptions = [],
270+ )
271+ server_managed_values : list [bool ] = []
272+
273+ async def fake_resolve_interrupted_turn (** kwargs : object ) -> SingleStepResult :
274+ server_managed_values .append (cast (bool , kwargs ["server_manages_conversation" ]))
275+ return SingleStepResult (
276+ original_input = "input" ,
277+ model_response = ModelResponse (output = [], usage = Usage (), response_id = "resp_resume" ),
278+ pre_step_items = [],
279+ new_step_items = [],
280+ next_step = NextStepFinalOutput ("done" ),
281+ tool_input_guardrail_results = [],
282+ tool_output_guardrail_results = [],
283+ )
284+
285+ monkeypatch .setattr (run_module , "resolve_interrupted_turn" , fake_resolve_interrupted_turn )
286+
287+ runner = run_module .AgentRunner ()
288+ result = await runner .run (agent , state , run_config = RunConfig ())
289+
290+ assert result .final_output == "done"
291+ assert server_managed_values == [True ]
292+
293+
228294@pytest .mark .asyncio
229295async def test_resumed_approval_does_not_duplicate_session_items () -> None :
230296 async def test_tool () -> str :
0 commit comments