﻿# Pydantic AI client history is not an authorization record

Pydantic AI reconstructs runs from accepted history, so client tool calls and approvals are not server-side authorization evidence; sanitization alone does not establish trust.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-pydantic-ai-client-history-trust/
Language: en

## Identify who controls the submitted conversation

A web client sends prior messages and approval decisions when continuing an agent run. Pydantic AI's [history guide](https://pydantic.dev/docs/ai/core-concepts/message-history/) describes its server-side surfaces as stateless: they reconstruct a run from submitted history and deferred results. A client that can supply those objects can fabricate tool calls or approval entries. Their presence in the accepted history is therefore not independent evidence that a model originally proposed them or a person reviewed them.

## Use sanitization for its actual scope

The guide provides `sanitize_messages` to constrain untrusted history. It strips or resets fields such as client-supplied system instructions, workspace references and reserved framework metadata under the documented defaults. These measures narrow what submitted messages can influence. They do not cryptographically establish the origin of every call, result or approval. Keep that distinction visible when deciding whether client-held conversation state can authorize an external write.

## Authenticate the route and constrain its tools

The [deferred-tool guide](https://pydantic.dev/docs/ai/tools-toolsets/deferred-tools/) explicitly distinguishes human sign-off from application authorization. Authenticate the endpoint and expose tools appropriate to the caller. A user allowed to continue a conversation is not automatically entitled to every target accepted by a broadly configured file-update tool. Validate the resource relationship inside the operation that will create the effect, using state the application actually controls.

## Carry caller context through dependencies

The [dependencies guide](https://pydantic.dev/docs/ai/core-concepts/dependencies/) passes application objects into each run and exposes them through `RunContext.deps`. Use trusted caller identity and authorization services from the route's own context, rather than deriving them from a sentence or metadata object inside client history. The dependency type supports application structure; it does not make untrusted values safe merely because they fit that type. Establish their provenance before constructing the run.

## Keep the review record where its authority lives

For sensitive paused work, the history guide recommends checking against server-side state or persisting the paused run and supplying the application's own deferred results. [Task contracts](/journal/learn-codex-task-contract/) define the allowed target and outcome; [tool observations](/journal/learn-codex-tool-observation/) record the actual operation. Conversation content can still support useful continuation. Its role is context, while the permission to change an external resource comes from the application's authenticated authority and retained review state.
