Skip to content

API Reference parrot.tools.optimizations.base

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.optimizations.base

View source

Shared toolkit base for the tool-optimizations toolkits (FEAT-543).

:class:OptimizationToolkitBase is the single validation seam for all three toolkits. It exists because MCP input does not pass through AbstractTool.execute(): MCPToolAdapter.execute() calls tool._execute(**arguments) directly, so schema validation never runs. ToolkitTool._execute() does still invoke toolkit._pre_execute() with the raw kwargs, before unknown keys are stripped — which makes :meth:OptimizationToolkitBase._pre_execute the enforcement point for untrusted tools/call arguments.

Direct Python calls must be safe too, so the public toolkit methods validate their own arguments as well; this seam is defence in depth, not a substitute.

Class OptimizationToolkitBase

Common policy, validation and result-shaping for optimization toolkits.

Subclasses declare :attr:arg_models, mapping each public method name to its Pydantic argument model, and implement public async methods that return Pydantic models.

Parameter Type Default Description
repo_root str | Path The repository checkout this toolkit is confined to.
policy Optional[OptimizationPolicy] None A fully built policy, overriding per-field keyword arguments when supplied.
**kwargs Any {} Policy overrides plus normal toolkit keyword arguments.

Attributes:

Attribute Type Description
arg_models dict[str, type[BaseModel]] Method name -> argument model. Every exposed tool must have an entry; an unmapped tool name is rejected outright.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally