In short.
This Pydantic AI Harness documentation page shows Python developers building Pydantic AI agents how to let the model search and recover earlier details from saved conversation history, but it cannot recover messages the application never saved or no longer retains. ConversationSearch exposes a search_conversation_history tool over persisted history, using BM25 word ranking and conversation scoping. Important tradeoffs include rebuilding the search corpus on every call, trust in whatever conversation_id the application supplies, which multi-tenant apps should derive on the server from the authenticated user, and changing 0.x APIs. Runtime correctness, retrieval quality and latency are not assessed; operating cost is unknown.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete documentation page at [https://pydantic.dev/docs/ai/harness/conversation-search/index.md], including its examples, API reference, 0.x compatibility notice, scope migration guidance and limitations. Linked pages, repository files, license texts and issue discussions are excluded. No software was executed; operational correctness, retrieval quality, performance, provider compatibility and security isolation remain unverified.
The overview
Identity
The resource is the Conversation Search documentation page for Pydantic AI Harness at [https://pydantic.dev/docs/ai/harness/conversation-search/index.md]. It combines an integration guide, configuration reference and explanation of the ConversationSearch capability.
ConversationSearch gives an agent a search_conversation_history tool. It reads saved history through a HistorySource and writes no history itself.
Assessment
The documented design fits agents that need to recover exact paths, values or decisions after older messages leave the model's live context. It also makes retained earlier runs searchable when they share a conversation identifier.
The guide provides enough detail to plan an integration and understand its main failure modes. It supplies no measured recall, latency, scale limits or tenant-isolation results, so production suitability remains unverified.
Users
The intended readers are Python developers building Pydantic AI agents, especially assistants with long conversations, compaction or follow-up runs. Beginners need familiarity with configuring an Agent and making asynchronous agent.run calls.
Developers responsible for shared storage also need to understand conversation identity and snapshot retention. The examples require application code; the page does not describe a ready-to-use chat application.
Capabilities
The tool searches retained earlier runs and persisted earlier steps of the current run. Results identify their run and conversation, and an optional run_id narrows retrieval to one permitted run. Instruction changes saved in history are searchable, while initial instructions are excluded.
The defaults allow up to 10 matching excerpts with context_lines=5 controlling surrounding messages. Indexed text remains complete, but displayed long messages are clipped to 500 characters, or 200 for system text and tool arguments. Excerpts shift toward a match beyond the usual cutoff.
Using it
Requirements
The documented snapshot-based setup uses pydantic_ai.Agent, pydantic_ai_harness, a model configuration and a store shared by StepPersistence and SnapshotHistorySource. A custom HistorySource can supply another history substrate. Supported Python versions, installation commands and exact package versions are not specified.
Conversation scope trusts the supplied conversation_id. In a multi-tenant application, the guide requires deriving it on the server from authenticated user identity. Custom history sources must populate conversation_id on returned run records. Store-wide scope='all' is intended only for history isolated to one principal.
Mechanism
StepPersistence saves full history at step boundaries before subsequent compaction. SnapshotHistorySource replays complete snapshots, removes summary artifacts and joins newly added messages using content-hash overlap. Interrupted snapshots are excluded, and later copies of overlapping messages are retained.
The resulting corpus is ranked with a pure-Python BM25 implementation requiring no extra ranking dependencies. Query words score independently, with rare terms receiving more weight. Conversation scope filters eligible runs, and a run_id argument cannot reach outside that scope.
Setup
Create one store and share it between persistence and search. The example uses SqliteStepStore(database='sessions.db'), StepPersistence(store=store) and ConversationSearch(SnapshotHistorySource(store), scope='conversation') in the agent's capabilities. SlidingWindowCompaction(max_messages=40) illustrates removing older messages from live context while retaining searchable snapshots.
Pass a stable conversation_id to agent.run for related runs. The persistence and search capabilities can appear in either order because search reads the store when called.
Identical search capabilities sharing the default capability id combine into one; differing configurations sharing that id raise a construction-time UserError. Separate search tools require distinct capability and toolset ids plus PrefixTools to distinguish their registered tool names.
Example
The page's authenticated-chat example defines ask(question, user_id, chat_id), calls agent.run with conversation_id=f'{user_id}:{chat_id}', and returns result.output. The intended effect is to make retained runs from that user's chat eligible for later search.
The user identifier must come from authenticated server context. This configuration example was not executed, and it provides no observed retrieval or isolation result.
Assessment & evidence
Limitations
Recovery requires surviving snapshots containing the original messages. History compacted before its first persistence can be lost, and snapshot retention caps can remove pre-compaction originals. Some inherited requests with later instruction changes can be indexed more than once.
The tokenizer matches word-character sequences. For Chinese, Japanese, Thai and other text without spaces, it matches an entire unbroken sequence rather than words within it.
Every search rebuilds the corpus from in-scope snapshots and lists all stored run records to apply scope. Larger stores and histories therefore increase work; no latency measurements are supplied. Remote media restoration adds fetches.
ConversationSearch emits no dedicated spans, but core tool instrumentation can record the search duration, query and result, with content governed by instrumentation settings.
Reasoning
Separating persistent history from live context lets compaction shorten the model's immediate input while leaving original details available for later retrieval. This benefit depends on persistence occurring before those details disappear.
Exact identifiers are a plausible use case because BM25 scores query words independently and favors rare terms. That suitability is inferred from the documented mechanism; comparative retrieval quality is unknown. Conversation scoping also depends on trustworthy identity assignment and correctly populated source records.
Alternatives
The documented extension point is a custom HistorySource, which can replace SnapshotHistorySource when an existing substrate provides an append-only entry log.
SlidingWindowCompaction and SummarizingCompaction address live-context size and can work alongside retrieval. The page supplies no comparison with competing memory libraries, embedding-based retrieval or managed history services, so their relative quality and cost are not assessed.
Evidence
The evidence is the complete Conversation Search documentation page and its embedded API reference at [https://pydantic.dev/docs/ai/harness/conversation-search/index.md]. It supports the described configuration, defaults, recovery mechanics and stated limitations.
Linked implementation code, threat-model documentation, related guides and issue discussions are outside the supplied evidence. No code was executed. Correctness, retrieval performance, provider compatibility and security isolation remain unverified in operation.
Access & freshness
Costs
Operating cost is unknown. The page supplies no prices, token counts, storage estimates or measured compute consumption.
Potential cost drivers inferred from the design include model usage, retained snapshots and computation to reconstruct history for each search. The page explicitly notes that remote media can be fetched during snapshot reads, even though the index only names the files. No monetary amounts are established.
Rights
The page does not state a license for its documentation, embedded examples or implementation. Redistribution permissions, modification rights, commercial-use conditions and attribution requirements are unknown from this evidence.
The linked implementation directory does not provide license evidence within the supplied page.
Freshness
The page was captured on 15 November 2026. It warns that Pydantic AI Harness 0.x APIs may change between minor releases, with deprecation warnings and migration guidance.
It documents a change from store-wide search to conversation scope as the default. Leaving scope unset resolves to conversation scope and emits one HarnessDeprecationWarning per instance; an explicit scope avoids that warning. The exact package release containing this behavior and subsequent changes are unknown.
Actions
Before integrating, confirm the API against the intended package version. Run StepPersistence from the first run of each conversation so messages are snapshotted before any compaction drops them; history inherited from an unpersisted session can be lost. Share the store with the snapshot history source, choose scope explicitly and retain original snapshots for the period during which recall is needed.
Derive conversation identifiers from authenticated server context. Evaluate retrieval with representative identifiers and languages, measure search latency on realistic history sizes, and verify retention and tenant boundaries. Review instrumentation settings for queries and excerpts containing sensitive conversation text.
