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.
str
required
Unique name for the agent
ChatCompletionClient
required
LLM client for generating responses
List[Tool] | None
Tools the agent can use
List[Handoff | str] | None
Other agents this agent can transfer control to
str | None
System prompt for the agent
str
required
Description of the agent’s capabilities
ChatCompletionContext | None
Context manager for conversation history
List[Memory] | None
Memory modules for the agent
bool
Whether to reflect on tool execution results (default: False)
int
Maximum tool call iterations per turn (default: 1)

Methods

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

Team Classes

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

Message Types

Plain text message.
str
required
Message text content
str
required
Name of the agent that created the message
Message indicating agent handoff.
str
required
Name of the agent to transfer to
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.
ChatMessage
The final response message
List[BaseAgentEvent]
Intermediate events and messages
Result of running an agent or team.
List[ChatMessage]
Complete conversation history
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

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

See Also