Skip to main content
The autogen_agentchat package provides high-level abstractions for building conversational agents and teams.

Agent Classes

AI-powered assistant agent with tool use and handoff capabilities.
name
str
required
Unique name for the agent
model_client
ChatCompletionClient
required
LLM client for generating responses
tools
List[Tool] | None
Tools the agent can use
handoffs
List[Handoff | str] | None
Other agents this agent can transfer control to
system_message
str | None
System prompt for the agent
description
str
required
Description of the agent’s capabilities
model_context
ChatCompletionContext | None
Context manager for conversation history
memory
List[Memory] | None
Memory modules for the agent
reflect_on_tool_use
bool
Whether to reflect on tool execution results (default: False)
max_tool_iterations
int
Maximum tool call iterations per turn (default: 1)

Methods

on_messages
async method
Process messages and return a response
messages
Sequence[ChatMessage]
required
Conversation messages
cancellation_token
CancellationToken | None
Token to cancel the operation
Returns: Response with the agent’s reply
on_messages_stream
async generator
Stream messages and events as they’re generated
run
async method
Run the agent with a task
task
str | ChatMessage
required
Initial task or message
termination_condition
TerminationCondition | None
Condition to stop execution
Returns: TaskResult with conversation history
Agent representing a human user with input capabilities.
name
str
required
Agent name
description
str
required
Agent description
input_func
Callable | None
Custom function for getting user input
Agent that executes code in a sandboxed environment.
name
str
required
Agent name
code_executor
CodeExecutor
required
Code execution backend
approval_func
ApprovalFuncType | None
Function to approve code before execution
description
str
required
Agent description
Meta-agent that manages an internal team of agents.
name
str
required
Agent name
group_chat
BaseGroupChat
required
Internal team configuration
description
str
required
Agent description
Agent that filters messages based on configurable criteria.
name
str
required
Agent name
filter_config
MessageFilterConfig
required
Filter configuration
description
str
required
Agent description
Base class for all chat agents in the framework.
name
str
required
Agent name
description
str
required
Agent description

Team Classes

Team where agents take turns in a fixed order.
participants
List[BaseChatAgent]
required
List of agents in the team
termination_condition
TerminationCondition | None
Condition to stop the conversation
Team with dynamic agent selection using an LLM.
participants
List[BaseChatAgent]
required
Agents available for selection
model_client
ChatCompletionClient
required
LLM for selecting the next speaker
selector_prompt
str | None
Custom prompt for agent selection
allow_repeated_speaker
bool
Whether the same agent can speak twice in a row (default: False)
Dynamic team with agent handoffs and context transfer.
participants
List[BaseChatAgent]
required
Agents in the swarm
termination_condition
TerminationCondition | None
Condition to stop execution
Specialized team for the Magentic-One architecture.
participants
List[BaseChatAgent]
required
Specialized agents for the Magentic-One pattern
max_turns
int
Maximum conversation turns
Graph-based team with custom agent flow.
graph
DiGraph
required
Directed graph of agents
entry_point
str
required
Starting node identifier
Base class for all team implementations.

Message Types

Plain text message.
content
str
required
Message text content
source
str
required
Name of the agent that created the message
Message indicating agent handoff.
target
str
required
Name of the agent to transfer to
content
str
required
Context for the handoff
Summary of tool execution results.
Message with structured data.

Events

Event emitted when a tool is called.
Event emitted after tool execution.
Streaming chunk from the model.
Agent’s internal reasoning.

Response Types

Agent response to messages.
chat_message
ChatMessage
The final response message
inner_messages
List[BaseAgentEvent]
Intermediate events and messages
Result of running an agent or team.
messages
List[ChatMessage]
Complete conversation history
stop_reason
str | None
Reason for termination

Termination Conditions

Stop after a maximum number of messages.
Stop when specific text is mentioned.
Stop on a specific message type.
Stop after a time limit.
Stop after token budget is exhausted.

State Management

Serializable state for assistant agents.

Logging

TRACE_LOGGER_NAME
str
Logger name: "autogen_agentchat"
EVENT_LOGGER_NAME
str
Logger name: "autogen_agentchat.events"

See Also