langgraph_agent_toolkit.core.tool_selection_config module

Validate tool selection settings without agent runtime dependencies.

class langgraph_agent_toolkit.core.tool_selection_config.ToolSelectionConfig(*, mode='off', max_tools=8, always_include=<factory>, model_config_key=None, max_retries=1, on_parsing_failure='error')[source][source]

Bases: BaseModel

Select the middleware and keep tool selection disabled by default.

max_tools limits selected tools. Required tools do not use this limit. Parsing fallback does not retry tool execution.

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.

Parameters:
  • mode (Literal['off', 'llm', 'provider'])

  • max_tools (Annotated[int, Ge(ge=1)])

  • always_include (list[str])

  • model_config_key (str | None)

  • max_retries (Annotated[int, Ge(ge=0), Le(le=3)])

  • on_parsing_failure (Literal['error', 'none', 'all'])

model_config = {'extra': 'forbid', 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

mode: Literal['off', 'llm', 'provider']
max_tools: int
always_include: list[str]
model_config_key: str | None
max_retries: int
on_parsing_failure: Literal['error', 'none', 'all']
classmethod validate_tool_names(value)[source][source]

Reject empty, repeated, or padded tool names.

Parameters:

value (list[str])

Return type:

list[str]

classmethod validate_model_key(value)[source][source]

Reject an empty model configuration key.

Parameters:

value (str | None)

Return type:

str | None