Share via


TerminationStrategy Class

A strategy for determining when an agent should terminate.

Note: This class is marked as 'experimental' and may change in the future.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Constructor

TerminationStrategy(*, maximum_iterations: int = 99, automatic_reset: bool = False, agents: list[Agent] = None)

Keyword-Only Parameters

Name Description
maximum_iterations
Default value: 99
automatic_reset
Required
agents
Required

Methods

should_agent_terminate

Check if the agent should terminate.

should_terminate

Check if the agent should terminate.

should_agent_terminate

Check if the agent should terminate.

async should_agent_terminate(agent: Agent, history: list[ChatMessageContent]) -> bool

Parameters

Name Description
agent
Required

The agent to check.

history
Required

The history of messages in the conversation.

Returns

Type Description

True if the agent should terminate, False otherwise

should_terminate

Check if the agent should terminate.

async should_terminate(agent: Agent, history: list[ChatMessageContent]) -> bool

Parameters

Name Description
agent
Required

The agent to check.

history
Required

The history of messages in the conversation.

Returns

Type Description

True if the agent should terminate, False otherwise

Attributes

agents

agents: list[Agent]

automatic_reset

automatic_reset: bool

is_experimental

is_experimental = True

maximum_iterations

maximum_iterations: int

stage_status

stage_status = 'experimental'