Skip to content

pydantic_ai.dependencies

AgentDeps module-attribute

AgentDeps = TypeVar('AgentDeps')

Type variable for agent dependencies.

RunContext dataclass

Bases: Generic[AgentDeps]

Information about the current call.

Source code in pydantic_ai_slim/pydantic_ai/dependencies.py
30
31
32
33
34
35
36
37
38
39
@dataclass
class RunContext(Generic[AgentDeps]):
    """Information about the current call."""

    deps: AgentDeps
    """Dependencies for the agent."""
    retry: int
    """Number of retries so far."""
    tool_name: str | None
    """Name of the tool being called."""

deps instance-attribute

deps: AgentDeps

Dependencies for the agent.

retry instance-attribute

retry: int

Number of retries so far.

tool_name instance-attribute

tool_name: str | None

Name of the tool being called.

ToolParams module-attribute

ToolParams = ParamSpec('ToolParams')

Retrieval function param spec.

SystemPromptFunc module-attribute

A function that may or maybe not take RunContext as an argument, and may or may not be async.

Usage SystemPromptFunc[AgentDeps].

ResultValidatorFunc module-attribute

A function that always takes ResultData and returns ResultData, but may or maybe not take CallInfo as a first argument, and may or may not be async.

Usage ResultValidator[AgentDeps, ResultData].

JsonData module-attribute

JsonData: TypeAlias = (
    "None | str | int | float | Sequence[JsonData] | Mapping[str, JsonData]"
)

Type representing any JSON data.

ToolReturnValue module-attribute

ToolReturnValue = Union[JsonData, Awaitable[JsonData]]

Return value of a tool function.

ToolContextFunc module-attribute

A tool function that takes RunContext as the first argument.

Usage ToolContextFunc[AgentDeps, ToolParams].

ToolPlainFunc module-attribute

A tool function that does not take RunContext as the first argument.

Usage ToolPlainFunc[ToolParams].