🤖 Agent 接口¶
evoagentx.agents ¶
Agent ¶
Bases: BaseModule
Base class for all agents.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique identifier for the agent |
description |
str
|
Human-readable description of the agent's purpose |
llm_config |
Optional[LLMConfig]
|
Configuration for the language model. If provided, a new LLM instance will be created.
Otherwise, the existing LLM instance specified in the |
llm |
Optional[BaseLLM]
|
Language model instance. If provided, the existing LLM instance will be used. |
agent_id |
Optional[str]
|
Unique ID for the agent, auto-generated if not provided |
system_prompt |
Optional[str]
|
System prompt for the Agent. |
actions |
List[Action]
|
List of available actions |
n |
Optional[int]
|
Number of latest messages used to provide context for action execution. It uses all the messages in short term memory by default. |
is_human |
bool
|
Whether this agent represents a human user |
version |
int
|
Version number of the agent, default is 0. |
Source code in evoagentx/core/module.py
__call__ ¶
Make the operator callable and automatically choose between sync and async execution.
Source code in evoagentx/agents/agent.py
async_execute
async
¶
async_execute(action_name: str, msgs: Optional[List[Message]] = None, action_input_data: Optional[dict] = None, return_msg_type: Optional[MessageType] = UNKNOWN, return_action_input_data: Optional[bool] = False, **kwargs) -> Union[Message, Tuple[Message, dict]]
Execute an action asynchronously with the given context and return results.
This is the async version of the execute method, allowing it to perform actions based on the current conversation context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_name
|
str
|
The name of the action to execute |
required |
msgs
|
Optional[List[Message]]
|
Optional list of messages providing context for the action |
None
|
action_input_data
|
Optional[dict]
|
Optional pre-extracted input data for the action |
None
|
return_msg_type
|
Optional[MessageType]
|
Message type for the return message |
UNKNOWN
|
**kwargs
|
Any
|
Additional parameters, may include workflow information |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Union[Message, Tuple[Message, dict]]
|
A message containing the execution results |
Source code in evoagentx/agents/agent.py
execute ¶
execute(action_name: str, msgs: Optional[List[Message]] = None, action_input_data: Optional[dict] = None, return_msg_type: Optional[MessageType] = UNKNOWN, return_action_input_data: Optional[bool] = False, **kwargs) -> Union[Message, Tuple[Message, dict]]
Execute an action with the given context and return results.
This is the core method for agent functionality, allowing it to perform actions based on the current conversation context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_name
|
str
|
The name of the action to execute |
required |
msgs
|
Optional[List[Message]]
|
Optional list of messages providing context for the action |
None
|
action_input_data
|
Optional[dict]
|
Optional pre-extracted input data for the action |
None
|
return_msg_type
|
Optional[MessageType]
|
Message type for the return message |
UNKNOWN
|
**kwargs
|
Any
|
Additional parameters, may include workflow information |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Union[Message, Tuple[Message, dict]]
|
A message containing the execution results |
Source code in evoagentx/agents/agent.py
set_llm_config ¶
Set a new LLM config and rebuild the LLM instance from it.
init_llm ¶
Initialize the language model for the agent.
Source code in evoagentx/agents/agent.py
init_long_term_memory ¶
Initialize long-term memory components.
Source code in evoagentx/agents/agent.py
add_action ¶
add_action(action: Type[Action])
Add a new action to the agent's available actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Type[Action]
|
The action instance to add |
required |
Source code in evoagentx/agents/agent.py
check_action_name ¶
Check if an action name is valid for this agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_name
|
str
|
Name of the action to check |
required |
Source code in evoagentx/agents/agent.py
get_action ¶
get_action(action_name: str) -> Action
Retrieves the Action instance associated with the given name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_name
|
str
|
Name of the action to retrieve |
required |
Returns:
| Type | Description |
|---|---|
Action
|
The Action instance with the specified name |
Source code in evoagentx/agents/agent.py
get_action_name ¶
get_action_name(action_cls: Type[Action]) -> str
Searches through the agent's actions to find one matching the specified type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_cls
|
Type[Action]
|
The Action class type to search for |
required |
Returns:
| Type | Description |
|---|---|
str
|
The name of the matching action |
Source code in evoagentx/agents/agent.py
get_action_inputs ¶
get_action_inputs(action: Action) -> Union[dict, None]
Uses the context extraction action to determine appropriate inputs for the specified action based on the conversation history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
Action
|
The action for which to extract inputs |
required |
Returns:
| Type | Description |
|---|---|
Union[dict, None]
|
Dictionary of extracted input data, or None if extraction fails |
Source code in evoagentx/agents/agent.py
get_all_actions ¶
get_all_actions() -> List[Action]
Get all actions except the context extraction action.
Returns:
| Type | Description |
|---|---|
List[Action]
|
List of Action instances available for execution |
Source code in evoagentx/agents/agent.py
get_agent_profile ¶
Generate a human-readable profile of the agent and its capabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_names
|
List[str]
|
Optional list of action names to include in the profile. If None, all actions are included. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A formatted string containing the agent profile |
Source code in evoagentx/agents/agent.py
get_prompts ¶
Get all the prompts of the agent.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary with keys in the format 'agent_name::action_name' and values containing the system_prompt and action prompt. |
Source code in evoagentx/agents/agent.py
set_prompt ¶
Set the prompt for a specific action of this agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_name
|
str
|
Name of the action whose prompt should be updated |
required |
prompt
|
str
|
New prompt text to set for the action |
required |
system_prompt
|
Optional[str]
|
Optional new system prompt to set for the agent |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the prompt was successfully updated, False otherwise |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the action_name does not exist for this agent |
Source code in evoagentx/agents/agent.py
set_prompts ¶
Set the prompts for all actions of this agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts
|
dict
|
A dictionary with keys in the format 'action_name' and values containing the system_prompt and action prompt. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the prompts were successfully updated, False otherwise |
Source code in evoagentx/agents/agent.py
save_module ¶
Save the agent to persistent storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path where the agent should be saved |
required |
ignore
|
List[str]
|
List of field names to exclude from serialization |
[]
|
**kwargs
|
Any
|
Additional parameters for the save operation |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The path where the agent was saved |
Source code in evoagentx/agents/agent.py
from_dict
classmethod
¶
from_dict(data: Dict, llm_config: Optional[LLMConfig] = None, **kwargs) -> Agent
Create an agent instance from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict
|
The dictionary containing all necessary configuration to recreate this agent |
required |
llm_config
|
Optional[LLMConfig]
|
The LLMConfig instance |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Agent |
Agent
|
The agent instance |
Source code in evoagentx/agents/agent.py
get_config ¶
Get a dictionary containing all necessary configuration to recreate this agent.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A configuration dictionary that can be used to initialize a new Agent instance |
dict
|
with the same properties as this one. |
Source code in evoagentx/agents/agent.py
CustomizeAgent ¶
CustomizeAgent(name: str, description: str, prompt: Optional[str] = None, prompt_template: Optional[PromptTemplate] = None, llm_config: Optional[LLMConfig] = None, inputs: Optional[List[Union[dict, Parameter]]] = None, outputs: Optional[List[Union[dict, Parameter]]] = None, system_prompt: Optional[str] = None, output_parser: Optional[Type[ActionOutput]] = None, parse_mode: Optional[str] = 'title', parse_func: Optional[Callable] = None, title_format: Optional[str] = None, tools: Optional[List[Union[Toolkit, Tool]]] = None, custom_output_format: Optional[str] = None, max_steps: int = 20, max_tool_call_concurrency: int = 5, **kwargs)
Bases: Agent
CustomizeAgent provides a flexible framework for creating specialized LLM-powered agents without writing custom code. It enables the creation of agents with well-defined inputs and outputs, custom prompt templates, and configurable parsing strategies.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the agent. |
description |
str
|
A description of the agent's purpose and capabilities. |
prompt_template |
PromptTemplate
|
The prompt template that will be used for the agent's primary action. |
prompt |
str
|
The prompt template that will be used for the agent's primary action.
Should contain placeholders in the format |
llm_config |
LLMConfig
|
Configuration for the language model. |
inputs |
List[Union[dict, Parameter]]
|
List of input specifications as dicts or Parameter objects. Each dict (e.g., |
outputs |
List[Union[dict, Parameter]]
|
List of output specifications as dicts or Parameter objects. Each dict (e.g., |
system_prompt |
str
|
The system prompt for the LLM. Defaults to DEFAULT_SYSTEM_PROMPT. |
output_parser |
Type[ActionOutput]
|
A custom class for parsing the LLM's output. Must be a subclass of ActionOutput. |
parse_mode |
str
|
Mode for parsing LLM output. Options are: - "title": Parse outputs using section titles (default) - "str": Parse as plain text - "json": Parse as JSON - "xml": Parse as XML - "custom": Use a custom parsing function |
parse_func |
Callable
|
Custom function for parsing LLM output when parse_mode is "custom". Must accept a "content" parameter and return a dictionary. |
title_format |
str
|
Format string for title parsing mode with {title} placeholder. Default is "## {title}". |
tools |
list[Toolkit]
|
List of tools to be used by the agent. |
custom_output_format |
str
|
Specify the output format. Only used when |
Source code in evoagentx/agents/customize_agent.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
customize_action_name
property
¶
Get the name of the primary custom action for this agent.
Returns:
| Type | Description |
|---|---|
str
|
The name of the primary custom action |
action
property
¶
action: Action
Get the primary custom action for this agent.
Returns:
| Type | Description |
|---|---|
Action
|
The primary custom action |
prompt
property
¶
Get the prompt for the primary custom action.
Returns:
| Type | Description |
|---|---|
str
|
The prompt for the primary custom action |
prompt_template
property
¶
Get the prompt template for the primary custom action.
Returns:
| Type | Description |
|---|---|
PromptTemplate
|
The prompt template for the primary custom action |
validate_data ¶
validate_data(prompt: str, prompt_template: PromptTemplate, inputs: List[Union[dict, Parameter]], outputs: List[Union[dict, Parameter]], output_parser: Type[ActionOutput], parse_mode: str, parse_func: Callable, title_format: str) -> tuple
Validate and normalize agent configuration, auto-correcting parse_mode where needed.
Converts inputs and outputs to Parameter objects, validates all
parsing-related options, and (for prompt_template-based agents only)
auto-corrects parse_mode to "json" when the output schema contains
object/array types or a json_schema without a custom parse function.
Raw-prompt agents keep their parse_mode, since the prompt is sent verbatim
and dictates its own output format.
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple containing: |
tuple
|
|
tuple
|
|
tuple
|
|
Source code in evoagentx/agents/customize_agent.py
create_customize_action
staticmethod
¶
create_customize_action(name: str, desc: str, prompt: str, prompt_template: PromptTemplate, inputs: List[Union[dict, Parameter]], outputs: List[Union[dict, Parameter]], parse_mode: str, parse_func: Optional[Callable] = None, output_parser: Optional[ActionOutput] = None, title_format: Optional[str] = '## {title}', custom_output_format: Optional[str] = None, tools: Optional[List[Union[Tool, Toolkit]]] = None, max_steps: int = 20, max_tool_call_concurrency: int = 5, **kwargs) -> Action
Create a custom action based on the provided specifications.
This method dynamically generates an Action class and instance with: - Input parameters defined by the inputs specification - Output format defined by the outputs specification - Custom execution logic using the customize_action_execute function - If tools is provided, returns a CustomizeAction action instead
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Base name for the action |
required |
desc
|
str
|
Description of the action |
required |
prompt
|
str
|
Prompt template for the action |
required |
prompt_template
|
PromptTemplate
|
Prompt template for the action |
required |
inputs
|
List[Union[dict, Parameter]]
|
List of input field specifications |
required |
outputs
|
List[Union[dict, Parameter]]
|
List of output field specifications |
required |
parse_mode
|
str
|
Mode to use for parsing LLM output |
required |
parse_func
|
Optional[Callable]
|
Optional custom parsing function |
None
|
output_parser
|
Optional[ActionOutput]
|
Optional custom output parser class |
None
|
tools
|
Optional[List[Union[Tool, Toolkit]]]
|
Optional list of tools |
None
|
max_steps
|
int
|
Maximum number of steps the agent can take |
20
|
max_tool_call_concurrency
|
int
|
Maximum number of concurrent tool calls |
5
|
Returns:
| Type | Description |
|---|---|
Action
|
A newly created Action instance |
Source code in evoagentx/agents/customize_agent.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
__call__ ¶
__call__(inputs: dict = None, return_msg_type: MessageType = UNKNOWN, **kwargs) -> Message
Call the customize action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict
|
The inputs to the customize action. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ActionOutput |
Message
|
The output of the customize action. |
Source code in evoagentx/agents/customize_agent.py
get_customize_agent_info ¶
Get the information of the customize agent.
Source code in evoagentx/agents/customize_agent.py
save_module ¶
Save the customize agent's configuration to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path where the configuration should be saved |
required |
ignore
|
List[str]
|
List of keys to exclude from the saved configuration |
[]
|
**kwargs
|
Any
|
Additional parameters for the save operation |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The path where the configuration was saved |
Source code in evoagentx/agents/customize_agent.py
get_config ¶
Get a dictionary containing all necessary configuration to recreate this agent.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A configuration dictionary that can be used to initialize a new Agent instance |
dict
|
with the same properties as this one. |
Source code in evoagentx/agents/customize_agent.py
ActionAgent ¶
ActionAgent(name: str, description: str, inputs: List[dict], outputs: List[dict], execute_func: Callable, async_execute_func: Optional[Callable] = None, llm_config: Optional[LLMConfig] = None, **kwargs)
Bases: Agent
ActionAgent is a specialized agent that executes a provided function directly without LLM. It creates an action that uses the provided function as the execution backbone.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the agent. |
description |
str
|
A description of the agent's purpose and capabilities. |
inputs |
List[dict]
|
List of input specifications, where each dict contains: - name (str): Name of the input parameter - type (str): Type of the input - description (str): Description of what the input represents - required (bool, optional): Whether this input is required (default: True) |
outputs |
List[dict]
|
List of output specifications, where each dict contains: - name (str): Name of the output field - type (str): Type of the output - description (str): Description of what the output represents - required (bool, optional): Whether this output is required (default: True) |
execute_func |
Callable
|
The function to execute the agent. |
async_execute_func |
(Callable, Optional)
|
Async version of the function. If not provided, an async wrapper will be automatically created around execute_func. |
llm_config |
LLMConfig
|
Configuration for the language model (minimal usage). |
Source code in evoagentx/agents/action_agent.py
main_action_name
property
¶
Get the name of the main function action for this agent.
Returns:
| Type | Description |
|---|---|
str
|
The name of the main function action |
get_config ¶
Get configuration for the ActionAgent.
Source code in evoagentx/agents/action_agent.py
save_module ¶
Save the ActionAgent configuration to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path where the configuration should be saved |
required |
ignore
|
List[str]
|
List of keys to exclude from the saved configuration |
[]
|
**kwargs
|
Any
|
Additional parameters for the save operation |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The path where the configuration was saved |
Source code in evoagentx/agents/action_agent.py
load_module
classmethod
¶
load_module(path: str, llm_config: LLMConfig = None, **kwargs) -> ActionAgent
Load the ActionAgent from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path of the file |
required |
llm_config
|
LLMConfig
|
The LLMConfig instance (optional) |
None
|
**kwargs
|
Additional keyword arguments |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ActionAgent |
ActionAgent
|
The loaded agent instance |
Raises:
| Type | Description |
|---|---|
KeyError
|
If required functions are not found in the registry |
Source code in evoagentx/agents/action_agent.py
__call__ ¶
__call__(inputs: dict = None, return_msg_type: MessageType = UNKNOWN, **kwargs) -> Message
Call the main function action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict
|
The inputs to the function action. |
None
|
return_msg_type
|
MessageType
|
The type of message to return. |
UNKNOWN
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Message |
Message
|
The output of the function action. |
Source code in evoagentx/agents/action_agent.py
AgentManager ¶
Bases: BaseModule
Responsible for creating and managing all Agent objects required for workflow operation.
Attributes:
| Name | Type | Description |
|---|---|---|
storage_handler |
StorageHandler
|
Used to load and save agents from/to storage. |
agents |
List[Agent]
|
A list to keep track of all managed Agent instances. |
agent_states |
Dict[str, AgentState]
|
A dictionary to track the state of each Agent by name. |
Source code in evoagentx/core/module.py
check_agents ¶
Validate agent list integrity and state consistency.
Performs thorough validation of the agent manager's internal state: 1. Checks for duplicate agent names 2. Verifies that agent states exist for all agents 3. Ensures agent list and state dictionary sizes match
Source code in evoagentx/agents/agent_manager.py
has_agent ¶
Check if an agent with the given name exists in the manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if an agent with the given name exists, False otherwise |
Source code in evoagentx/agents/agent_manager.py
load_agent ¶
Load an agent from local storage through storage_handler.
Retrieves agent data from storage and creates an Agent instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent to load |
required |
tools
|
Optional[List[Union[Tool, Toolkit]]]
|
Optional list of tools available for the agent |
None
|
**kwargs
|
Any
|
Additional parameters for agent creation |
{}
|
Returns:
| Type | Description |
|---|---|
Agent
|
Agent instance with data loaded from storage |
Source code in evoagentx/agents/agent_manager.py
load_all_agents ¶
Load all agents from storage and add them to the manager.
Retrieves all available agents from storage and adds them to the managed agents collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional parameters passed to storage handler |
{}
|
Source code in evoagentx/agents/agent_manager.py
get_agent_name ¶
get_agent_name(agent: Union[str, dict, Agent]) -> str
Extract agent name from different agent representations.
Handles different ways to specify an agent (string name, dictionary, or Agent instance) and extracts the agent name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Union[str, dict, Agent]
|
Agent specified as a string name, dictionary with 'name' key, or Agent instance |
required |
Returns:
| Type | Description |
|---|---|
str
|
The extracted agent name as a string |
Source code in evoagentx/agents/agent_manager.py
add_agent ¶
add_agent(agent: Union[str, dict, Agent], llm_config: Optional[LLMConfig] = None, tools: Optional[List[Union[Tool, Toolkit]]] = None, **kwargs)
add a single agent, ignore if the agent already exists (judged by the name of an agent).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Union[str, dict, Agent]
|
The agent to be added, specified as: - String: Agent name to load from storage - Dictionary: Agent specification to create a CustomizeAgent - Agent: Existing Agent instance to add directly |
required |
llm_config
|
Optional[LLMConfig]
|
The LLM configuration to be used for the agent. Only used when the |
None
|
tools
|
Optional[List[Union[Tool, Toolkit]]]
|
Optional list of tools available for the agent, used to resolve tool_names in agent config. |
None
|
**kwargs
|
Any
|
Additional parameters for agent creation |
{}
|
Source code in evoagentx/agents/agent_manager.py
add_agents ¶
add_agents(agents: List[Union[str, dict, Agent]], llm_config: Optional[LLMConfig] = None, tools: Optional[List[Union[Tool, Toolkit]]] = None, **kwargs)
add several agents by using self.add_agent().
Source code in evoagentx/agents/agent_manager.py
add_agents_from_workflow ¶
add_agents_from_workflow(workflow_graph, llm_config: Optional[LLMConfig] = None, tools: Optional[List[Union[Tool, Toolkit]]] = None, **kwargs)
Initialize agents from the nodes of a given WorkFlowGraph and add these agents to self.agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_graph
|
WorkFlowGraph
|
The workflow graph containing nodes with agents information. |
required |
llm_config
|
Optional[LLMConfig]
|
The LLM configuration to be used for the agents. |
None
|
tools
|
Optional[List[Union[Tool, Toolkit]]]
|
Optional list of tools available for the agents, used to resolve tool_names in agent config. |
None
|
**kwargs
|
Any
|
Additional parameters passed to add_agent |
{}
|
Source code in evoagentx/agents/agent_manager.py
update_agents_from_workflow ¶
update_agents_from_workflow(workflow_graph, llm_config: Optional[LLMConfig] = None, tools: Optional[List[Union[Tool, Toolkit]]] = None, **kwargs)
Update agents from a given WorkFlowGraph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_graph
|
WorkFlowGraph
|
The workflow graph containing nodes with agents information. |
required |
llm_config
|
Optional[LLMConfig]
|
The LLM configuration to be used for the agents. |
None
|
tools
|
Optional[List[Union[Tool, Toolkit]]]
|
Optional list of tools available for the agents, used to resolve tool_names in agent config. |
None
|
**kwargs
|
Additional parameters passed to update_agent |
{}
|
Source code in evoagentx/agents/agent_manager.py
get_agent ¶
get_agent(agent_name: str, **kwargs) -> Agent
Retrieve an agent by its name from managed agents.
Searches the list of managed agents for an agent with the specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent to retrieve |
required |
**kwargs
|
Any
|
Additional parameters (unused) |
{}
|
Returns:
| Type | Description |
|---|---|
Agent
|
The Agent instance with the specified name |
Source code in evoagentx/agents/agent_manager.py
update_agent ¶
update_agent(agent: Union[dict, Agent], llm_config: Optional[LLMConfig] = None, tools: Optional[List[Union[Tool, Toolkit]]] = None, **kwargs)
Update an agent in the manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Union[dict, Agent]
|
The agent to be updated, specified as: - Dictionary: Agent specification to update a CustomizeAgent - Agent: Existing Agent instance to update |
required |
llm_config
|
Optional[LLMConfig]
|
The LLM configuration to be used for the agent. |
None
|
tools
|
Optional[List[Union[Tool, Toolkit]]]
|
Optional list of tools available for the agent, used to resolve tool_names in agent config. |
None
|
Source code in evoagentx/agents/agent_manager.py
remove_agent ¶
Remove an agent from the manager and optionally from storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent to remove |
required |
remove_from_storage
|
bool
|
If True, also remove the agent from storage |
False
|
**kwargs
|
Any
|
Additional parameters passed to storage_handler.remove_agent |
{}
|
Source code in evoagentx/agents/agent_manager.py
get_agent_state ¶
Get the state of a specific agent by its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AgentState |
AgentState
|
The current state of the agent. |
Source code in evoagentx/agents/agent_manager.py
set_agent_state ¶
Changes an agent's state and notifies any threads waiting on that agent's state. Thread-safe operation for coordinating multi-threaded agent execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent |
required |
new_state
|
AgentState
|
The new state to set |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the state was updated successfully, False otherwise |
Source code in evoagentx/agents/agent_manager.py
get_all_agent_states ¶
Get the states of all managed agents.
Returns:
| Type | Description |
|---|---|
Dict[str, AgentState]
|
Dict[str, AgentState]: A dictionary mapping agent names to their states. |
save_all_agents ¶
Save all managed agents to persistent storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional parameters passed to the storage handler |
{}
|
wait_for_agent_available ¶
Wait for an agent to be available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent to wait for |
required |
timeout
|
Optional[float]
|
Maximum time to wait in seconds, or None to wait indefinitely |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the agent became available, False if timed out |
Source code in evoagentx/agents/agent_manager.py
copy ¶
copy() -> AgentManager