@@ -714,13 +714,10 @@ async def _aformat_response_if_needed(
714714 message .content = response .output_messages [0 ].content
715715 self ._try_format_message (message , response_format )
716716
717- import threading
718-
719717 def step (
720718 self ,
721719 input_message : Union [BaseMessage , str ],
722720 response_format : Optional [Type [BaseModel ]] = None ,
723- stop_event : Optional [threading .Event ] = None ,
724721 ) -> ChatAgentResponse :
725722 r"""Executes a single step in the chat session, generating a response
726723 to the input message.
@@ -733,9 +730,6 @@ def step(
733730 model defining the expected structure of the response. Used to
734731 generate a structured response if provided. (default:
735732 :obj:`None`)
736- stop_event (Optional[threading.Event], optional): Event to signal
737- termination of the agent's operation. When set, the agent will
738- terminate its execution. (default: :obj:`None`)
739733
740734 Returns:
741735 ChatAgentResponse: Contains output messages, a termination status
@@ -770,7 +764,7 @@ def step(
770764 )
771765
772766 # Terminate Agent if stop_event is set
773- if stop_event and stop_event .is_set ():
767+ if self . stop_event and self . stop_event .is_set ():
774768 # Use the _step_token_exceed to terminate the agent with reason
775769 return self ._step_token_exceed (
776770 num_tokens , tool_call_records , "termination_triggered"
@@ -822,7 +816,6 @@ async def astep(
822816 self ,
823817 input_message : Union [BaseMessage , str ],
824818 response_format : Optional [Type [BaseModel ]] = None ,
825- stop_event : Optional [threading .Event ] = None ,
826819 ) -> ChatAgentResponse :
827820 r"""Performs a single step in the chat session by generating a response
828821 to the input message. This agent step can call async function calls.
@@ -839,9 +832,6 @@ async def astep(
839832 used to generate a structured response by LLM. This schema
840833 helps in defining the expected output format. (default:
841834 :obj:`None`)
842- stop_event (Optional[threading.Event], optional): Event to signal
843- termination of the agent's operation. When set, the agent will
844- terminate its execution. (default: :obj:`None`)
845835
846836 Returns:
847837 ChatAgentResponse: A struct containing the output messages,
@@ -873,7 +863,7 @@ async def astep(
873863 )
874864
875865 # Terminate Agent if stop_event is set
876- if stop_event and stop_event .is_set ():
866+ if self . stop_event and self . stop_event .is_set ():
877867 # Use the _step_token_exceed to terminate the agent with reason
878868 return self ._step_token_exceed (
879869 num_tokens , tool_call_records , "termination_triggered"
0 commit comments