Share via


KernelFunctionTerminationStrategy Class

A termination strategy that uses a kernel function to determine termination.

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

KernelFunctionTerminationStrategy(*, maximum_iterations: int = 99, automatic_reset: bool = False, agents: list[Agent] = None, agent_variable_name: str | None = '_agent_', history_variable_name: str | None = '_history_', arguments: KernelArguments | None = None, function: KernelFunction, kernel: Kernel, result_parser: Callable[[...], bool] = None, history_reducer: ChatHistoryReducer | None = None)

Keyword-Only Parameters

Name Description
maximum_iterations
Default value: 99
automatic_reset
Required
agents
Required
agent_variable_name
Default value: _agent_
history_variable_name
Default value: _history_
arguments
Required
function
Required
kernel
Required
result_parser
Required
history_reducer
Required

Methods

should_agent_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

Attributes

DEFAULT_AGENT_VARIABLE_NAME

DEFAULT_AGENT_VARIABLE_NAME: ClassVar[str] = '_agent_'

DEFAULT_HISTORY_VARIABLE_NAME

DEFAULT_HISTORY_VARIABLE_NAME: ClassVar[str] = '_history_'

agent_variable_name

agent_variable_name: str | None

agents

agents: list[Agent]

arguments

arguments: KernelArguments | None

automatic_reset

automatic_reset: bool

function

function: KernelFunction

history_reducer

history_reducer: ChatHistoryReducer | None

history_variable_name

history_variable_name: str | None

is_experimental

is_experimental = True

kernel

kernel: Kernel

maximum_iterations

maximum_iterations: int

result_parser

result_parser: Callable[[...], bool]

stage_status

stage_status = 'experimental'