@@ -1945,7 +1945,7 @@ def run_streamed(
19451945 else :
19461946 # input is already str | list[TResponseInputItem] when not RunState
19471947 # Reuse input_for_result variable from outer scope
1948- input_for_result = cast (str | list [TResponseInputItem ], input )
1948+ input_for_result = cast (Union [ str , list [TResponseInputItem ] ], input )
19491949 context_wrapper = RunContextWrapper (context = context ) # type: ignore
19501950 # input_for_state is the same as input_for_result here
19511951 input_for_state = input_for_result
@@ -3600,59 +3600,6 @@ async def _get_single_step_result_from_response(
36003600 run_config = run_config ,
36013601 )
36023602
3603- @classmethod
3604- async def _get_single_step_result_from_streamed_response (
3605- cls ,
3606- * ,
3607- agent : Agent [TContext ],
3608- all_tools : list [Tool ],
3609- streamed_result : RunResultStreaming ,
3610- new_response : ModelResponse ,
3611- output_schema : AgentOutputSchemaBase | None ,
3612- handoffs : list [Handoff ],
3613- hooks : RunHooks [TContext ],
3614- context_wrapper : RunContextWrapper [TContext ],
3615- run_config : RunConfig ,
3616- tool_use_tracker : AgentToolUseTracker ,
3617- ) -> SingleStepResult :
3618- original_input = streamed_result .input
3619- # When resuming from a RunState, items from streamed_result.new_items were already saved
3620- # to the session, so we should start with empty pre_step_items to avoid duplicates.
3621- # pre_step_items should only include items from the current run.
3622- pre_step_items : list [RunItem ] = []
3623- event_queue = streamed_result ._event_queue
3624-
3625- processed_response = RunImpl .process_model_response (
3626- agent = agent ,
3627- all_tools = all_tools ,
3628- response = new_response ,
3629- output_schema = output_schema ,
3630- handoffs = handoffs ,
3631- )
3632- new_items_processed_response = processed_response .new_items
3633- tool_use_tracker .add_tool_use (agent , processed_response .tools_used )
3634- RunImpl .stream_step_items_to_queue (new_items_processed_response , event_queue )
3635-
3636- single_step_result = await RunImpl .execute_tools_and_side_effects (
3637- agent = agent ,
3638- original_input = original_input ,
3639- pre_step_items = pre_step_items ,
3640- new_response = new_response ,
3641- processed_response = processed_response ,
3642- output_schema = output_schema ,
3643- hooks = hooks ,
3644- context_wrapper = context_wrapper ,
3645- run_config = run_config ,
3646- )
3647- new_step_items = [
3648- item
3649- for item in single_step_result .new_step_items
3650- if item not in new_items_processed_response
3651- ]
3652- RunImpl .stream_step_items_to_queue (new_step_items , event_queue )
3653-
3654- return single_step_result
3655-
36563603 @classmethod
36573604 async def _run_input_guardrails (
36583605 cls ,
0 commit comments