agent

Functions

create_default_planner(tool_manager[, ...])

Create a default planner with the given model client, model kwargs, template, task desc, cache path, use cache, max steps.

create_default_tool_manager([tools, ...])

Create a default tool manager with the given tools, context variables, and add_llm_as_fallback.

Classes

Agent(name, tools, context_variables, ...)

An agent is a high-level component that holds (1) a generator as task plannaer (calling tools) and (2) a tool manager to manage tools.

class Agent(name: str, tools: ~typing.List[~typing.Any] | None = None, context_variables: ~typing.Dict | None = None, add_llm_as_fallback: bool | None = True, model_client: ~adalflow.core.model_client.ModelClient | None = None, model_kwargs: ~typing.Dict[str, ~typing.Any] | None = {}, model_type: ~adalflow.core.types.ModelType | None = ModelType.LLM, template: str | None = None, role_desc: str | None = None, cache_path: str | None = None, use_cache: bool | None = False, answer_data_type: ~typing.Type[~core.agent.T] | None = <class 'str'>, max_steps: int | None = 10, is_thinking_model: bool | None = False, tool_manager: ~adalflow.core.tool_manager.ToolManager | None = None, planner: ~adalflow.core.generator.Generator | None = None, **kwargs)[source]

Bases: Component

An agent is a high-level component that holds (1) a generator as task plannaer (calling tools) and (2) a tool manager to manage tools.

It comes with default prompt template that instructs LLM (1) agentic task description (2) template on adding definitions of tools (3) arguments to fill in history.

Additionally, it comes with two helper tools: 1. finish: to finish the task 2. additional_llm_tool: to answer any input query with llm’s world knowledge. Use me as a fallback tool or when the query is simple.

name

Name of the agent

Type:

str

tool_manager

Stores and manages tools

Type:

ToolManager

generator

Handles text generation with a language model

Type:

Generator

the output_processors must return the type StepOutput
is_training() bool[source]
get_prompt(**kwargs) str[source]

Get formatted prompt using generator’s prompt template.

Parameters:

**kwargs – Additional arguments to pass to the generator’s get_prompt

Returns:

Formatted prompt string