Skip to main content

GroupToolExecutor

Tool executor for the group chat initiated with initiate_group_chat

Instance Attributes

chat_messages


A dictionary of conversations from agent to list of messages.

code_executor


The code executor used by this agent. Returns None if code execution is disabled.

description


Get the description of the agent.

function_map


Return the function map.

name


Get the name of the agent.

system_message


Return the system message.

tools


Get the agent’s tools (registered for LLM) Note this is a copy of the tools list, use add_tool and remove_tool to modify the tools list.

use_docker


Bool value of whether to use docker to execute the code, or str value of the docker image name to use, or None when code execution is disabled.

Instance Methods

a_check_termination_and_human_reply

(async) Check if the conversation should be terminated, and if human reply is provided.
This method checks for conditions that require the conversation to be terminated, such as reaching a maximum number of consecutive auto-replies or encountering a termination message. Additionally, it prompts for and processes human input based on the configured human input mode, which can be ‘ALWAYS’, ‘NEVER’, or ‘TERMINATE’. The method also manages the consecutive auto-reply counter for the conversation and prints relevant messages based on the human input received.
Parameters: Returns:

a_execute_function

Execute an async function call and return the result.
Override this function to modify the way async functions and tools are executed.
Parameters: Returns:

a_generate_function_call_reply

Generate a reply using async function call.
”function_call” replaced by “tool_calls” as of OpenAI API v1.1.0 See https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions
Parameters:

a_generate_init_message

Generate the initial message for the agent.
If message is None, input() will be called to get the initial message.
Parameters: Returns:

a_generate_oai_reply

Generate a reply using autogen.oai asynchronously. Parameters:

a_generate_reply

(async) Reply based on the conversation history and the sender.
Either messages or sender must be provided.
Register a reply_func with None as one trigger for it to be activated when messages is non-empty and sender is None.
Use registered auto reply functions to generate replies.
By default, the following functions are checked in order:
1. check_termination_and_human_reply 2. generate_function_call_reply 3. generate_tool_calls_reply 4. generate_code_execution_reply 5. generate_oai_reply Every function returns a tuple (final, reply).
When a function returns final=False, the next function will be checked.
So by default, termination and human reply will be checked first.
If not terminating and human reply is skipped, execute function or code and return the result.
AI replies are generated only when no code execution is performed.
Parameters: Returns:

a_generate_tool_calls_reply

Generate a reply using async function call. Parameters:

a_get_human_input

(Async) Get human input.
Override this method to customize the way to get human input.
Parameters: Returns:

a_initiate_chat

(async) Initiate a chat with the recipient agent.
Reset the consecutive auto reply counter.
If clear_history is True, the chat history with the recipient agent will be cleared.
a_generate_init_message is called to generate the initial message for the agent.
Parameters: Returns:

a_receive

(async) Receive a message from another agent.
Once a message is received, this function sends a reply to the sender or stop.
The reply can be generated automatically or entered manually by a human.
Parameters:

a_send

(async) Send a message to another agent.
Parameters:

a_sequential_run

(Experimental) Initiate chats with multiple agents sequentially.
Parameters: Returns:

can_execute_function

Whether the agent can execute the function. Parameters:

chat_messages_for_summary

A list of messages as a conversation to summarize. Parameters:

check_termination_and_human_reply

Check if the conversation should be terminated, and if human reply is provided.
This method checks for conditions that require the conversation to be terminated, such as reaching a maximum number of consecutive auto-replies or encountering a termination message. Additionally, it prompts for and processes human input based on the configured human input mode, which can be ‘ALWAYS’, ‘NEVER’, or ‘TERMINATE’. The method also manages the consecutive auto-reply counter for the conversation and prints relevant messages based on the human input received.
Parameters: Returns:

clear_history

Clear the chat history of the agent.
Parameters:

clear_next_target

Clears the next target to transition to.

execute_code_blocks

Execute the code blocks and return the result. Parameters:

execute_function

Execute a function call and return the result.
Override this function to modify the way to execute function and tool calls.
Parameters: Returns:

generate_code_execution_reply

Generate a reply using code execution. Parameters:

generate_function_call_reply

Generate a reply using function call.
”function_call” replaced by “tool_calls” as of OpenAI API v1.1.0 See https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions
Parameters:

generate_init_message

Generate the initial message for the agent.
If message is None, input() will be called to get the initial message.
Parameters: Returns:

generate_oai_reply

Generate a reply using autogen.oai. Parameters:

generate_reply

Reply based on the conversation history and the sender.
Either messages or sender must be provided.
Register a reply_func with None as one trigger for it to be activated when messages is non-empty and sender is None.
Use registered auto reply functions to generate replies.
By default, the following functions are checked in order:
1. check_termination_and_human_reply 2. generate_function_call_reply (deprecated in favor of tool_calls) 3. generate_tool_calls_reply 4. generate_code_execution_reply 5. generate_oai_reply Every function returns a tuple (final, reply).
When a function returns final=False, the next function will be checked.
So by default, termination and human reply will be checked first.
If not terminating and human reply is skipped, execute function or code and return the result.
AI replies are generated only when no code execution is performed.
Parameters: Returns:

generate_tool_calls_reply

Generate a reply using tool call. Parameters:

get_actual_usage

Get the actual usage summary.

get_chat_results

A summary from the finished chats of particular agents. Parameters:

get_human_input

Get human input.
Override this method to customize the way to get human input.
Parameters: Returns:

get_next_target

Gets the next target to transition to.

get_total_usage

Get the total usage summary.

has_next_target

Checks if there is a next target to transition to.

initiate_chat

Initiate a chat with the recipient agent.
Reset the consecutive auto reply counter.
If clear_history is True, the chat history with the recipient agent will be cleared.
Parameters: Returns:

initiate_chats

(Experimental) Initiate chats with multiple agents.
Parameters: Returns:

last_message

The last message exchanged with the agent.
Parameters: Returns:

max_consecutive_auto_reply

The maximum number of consecutive auto replies. Parameters:
Print the usage summary. Parameters:

process_all_messages_before_reply

Calls any registered capability hooks to process all messages, potentially modifying the messages. Parameters:

process_last_received_message

Calls any registered capability hooks to use and potentially modify the text of the last message, as long as the last message is not a function call or exit command. Parameters:

receive

Receive a message from another agent.
Once a message is received, this function sends a reply to the sender or stop.
The reply can be generated automatically or entered manually by a human.
Parameters:

register_agents_functions

Adds the functions of the agents to the group tool executor. Parameters:

register_for_execution

Decorator factory for registering a function to be executed by an agent.
It’s return value is used to decorate a function to be registered to the agent.
Parameters: Returns:

register_for_llm

Decorator factory for registering a function to be used by an agent.
It’s return value is used to decorate a function to be registered to the agent. The function uses type hints to specify the arguments and return type. The function name is used as the default name for the function, but a custom name can be provided. The function description is used to describe the function in the agent’s configuration.
Parameters: Returns:

register_function

Register functions to the agent.
Parameters:

register_handoff

Register a single handoff condition (OnContextCondition or OnCondition).
Parameters:

register_handoffs

Register multiple handoff conditions (OnContextCondition or OnCondition).
Parameters:

register_hook

Registers a hook to be called by a hookable method, in order to add a capability to the agent.
Registered hooks are kept in lists (one per hookable method), and are called in their order of registration.
Parameters:

register_model_client

Register a model client.
Parameters:

register_nested_chats

Register a nested chat reply function.
Parameters:

register_reply

Register a reply function.
The reply function will be called when the trigger matches the sender.
The function registered later will be checked earlier by default.
To change the order, set the position to a positive integer.
Both sync and async reply functions can be registered. The sync reply function will be triggered from both sync and async chats. However, an async reply function will only be triggered from async chats (initiated with ConversableAgent.a_initiate_chat). If an async reply function is registered and a chat is initialized with a sync function, ignore_async_in_sync_chat determines the behaviour as follows:
if ignore_async_in_sync_chat is set to False (default value), an exception will be raised, and if ignore_async_in_sync_chat is set to True, the reply function will be ignored.
Parameters:

remove_tool_for_llm

Remove a tool (register for LLM tool) Parameters:

replace_reply_func

Replace a registered reply function with a new one.
Parameters:

reset

Reset the agent.

reset_consecutive_auto_reply_counter

Reset the consecutive_auto_reply_counter of the sender. Parameters:

run_code

Run the code and return the result.
Override this function to modify the way to run the code.
Parameters: Returns:

send

Send a message to another agent.
Parameters:

sequential_run

(Experimental) Initiate chats with multiple agents sequentially.
Parameters: Returns:

set_next_target

Sets the next target to transition to, used in the determine_next_agent function. Parameters:

set_ui_tools

Set the UI tools for the agent.
Parameters:

stop_reply_at_receive

Reset the reply_at_receive of the sender. Parameters:

unset_ui_tools

Unset the UI tools for the agent.
Parameters:

update_agent_state_before_reply

Calls any registered capability hooks to update the agent’s state.
Primarily used to update context variables.
Will, potentially, modify the messages.
Parameters:

update_function_signature

Update a function_signature in the LLM configuration for function_call.
Parameters:

update_max_consecutive_auto_reply

Update the maximum number of consecutive auto replies.
Parameters:

update_system_message

Update the system message.
Parameters:

update_tool_signature

Update a tool_signature in the LLM configuration for tool_call.
Parameters: