-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
At present, the definition of AbstractAgent requires the user to implement the abstract overide method, defined as such:
@contextmanager
@abstractmethod
def override(
self,
*,
deps: AgentDepsT | _utils.Unset = _utils.UNSET,
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
) -> Iterator[None]:
"""Context manager to temporarily override agent dependencies, model, toolsets, or tools.
This is particularly useful when testing.
You can find an example of this [here](../testing.md#overriding-model-via-pytest-fixtures).
Args:
deps: The dependencies to use instead of the dependencies passed to the agent run.
model: The model to use instead of the model passed to the agent run.
toolsets: The toolsets to use instead of the toolsets passed to the agent constructor and agent run.
tools: The tools to use instead of the tools registered with the agent.
"""
raise NotImplementedError
yieldThe problem is that _utils is a private module, and thus is improper to reference from outside of PydanticAI itself.
This implicitly makes it impossible to actually implement AbstractAgent from outside of PydanticAI without violating the "rules" of good Python.
Python, Pydantic AI & LLM client version
Python - 3.12
PydanticAI - 0.8.1
LLM Client - All