mirror of
https://github.com/pydantic/pydantic-ai-harness.git
synced 2026-07-21 02:45:34 +00:00
* refactor: graduate capabilities out of `experimental` (ACP excepted) The `experimental` label suppressed the try->fail->report->improve loop we want from real usage, so drop it from the harness. Ten capabilities move to top-level submodules; ACP stays experimental (it may still be reshaped or moved to core, and can't be generic across agents). - Old `pydantic_ai_harness.experimental.<name>` paths keep working as DeprecationWarning shims (via `warn_moved`), so existing imports don't break. - Renames to match capability names: authoring -> runtime_authoring, overflow -> overflowing_tool_output. - Capabilities stay in individual submodules with no top-level re-export, so importing the root package never pulls in a capability's optional deps. - Docs drop the experimental framing and the "may be removed in any release" language in favor of "API subject to change". * docs: tell capability authors to ask the user when unsure about a name Per PR review: a name is a public commitment once shipped, so ask rather than guess.
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
"""Minimum thinking-effort floor shared by the sub-agent capability and its orchestrator."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic_ai.settings import ThinkingEffort, ThinkingLevel
|
|
|
|
MINIMUM_EFFORT_FLOOR: ThinkingEffort = 'low'
|
|
"""Lowest thinking effort any agent this capability builds is allowed to run at.
|
|
|
|
`clamp_effort` raises anything below this to the floor. The constant is exported
|
|
so an orchestrator that builds its own agents can apply the same floor to them
|
|
(the orchestrator-side application is the caller's responsibility)."""
|
|
|
|
_EFFORT_RANK: dict[ThinkingEffort, int] = {'minimal': 0, 'low': 1, 'medium': 2, 'high': 3, 'xhigh': 4}
|
|
"""Ordering of the concrete effort levels, low to high."""
|
|
|
|
|
|
def clamp_effort(level: ThinkingLevel | None, floor: ThinkingEffort = MINIMUM_EFFORT_FLOOR) -> ThinkingLevel:
|
|
"""Raise a thinking level to at least `floor`.
|
|
|
|
- `None` or `False` (thinking unset or disabled, both below any floor) become `floor`.
|
|
- `True` (thinking on at the provider's default effort) is left as `True`: its
|
|
magnitude is provider-defined and not comparable to a named level, so it is
|
|
neither downgraded nor bumped.
|
|
- A concrete effort below `floor` becomes `floor`; one at or above `floor` is unchanged.
|
|
"""
|
|
if level is None or level is False:
|
|
return floor
|
|
if level is True:
|
|
return True
|
|
if _EFFORT_RANK[level] < _EFFORT_RANK[floor]:
|
|
return floor
|
|
return level
|