KernelFunctionSelectionStrategy Class
Determines agent selection based on the evaluation of a Kernel Function.
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
KernelFunctionSelectionStrategy(*, has_selected: bool = False, initial_agent: Agent | None = None, agent_variable_name: str | None = '_agent_', history_variable_name: str | None = '_history_', arguments: KernelArguments | None = None, function: KernelFunction, kernel: Kernel, result_parser: Callable[[...], str] = None, history_reducer: ChatHistoryReducer | None = None)
Keyword-Only Parameters
Name | Description |
---|---|
has_selected
Required
|
|
initial_agent
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
select_agent |
Select the next agent to interact with. |
select_agent
Select the next agent to interact with.
async select_agent(agents: list[Agent], history: list[ChatMessageContent]) -> Agent
Parameters
Name | Description |
---|---|
agents
Required
|
The list of agents to select from. |
history
Required
|
The history of messages in the conversation. |
Returns
Type | Description |
---|---|
The next agent to interact with. |
Exceptions
Type | Description |
---|---|
If the strategy fails to execute the function or select the next agent |
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
arguments
arguments: KernelArguments | None
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
result_parser
result_parser: Callable[[...], str]
stage_status
stage_status = 'experimental'