Last updated: November 29, 2026
Pydantic AI 2.77, released November 27, 2026, makes long-running agents easier to keep and resume. It adds SQLite, PostgreSQL and MongoDB conversation stores, a compaction hook with on-demand compact_history(), and one portable setting for readable thinking. Version 2.76 added Google Interactions support and Pax desktop sandboxes.
Contents
- What’s new in Pydantic AI 2.76 and 2.77
- Pydantic AI 2.75 vs 2.77
- How to upgrade and use the new features
- Compaction: hooks, events and compact_history()
- Power-user tips and limitations
- Frequently asked questions
What’s new in Pydantic AI 2.76 and 2.77
Pydantic AI is the open-source Python agent framework from the team behind Pydantic. It ships minor releases almost daily, so this guide groups the two releases since our Pydantic AI 2.75 guide: v2.76.0 on November 26 and v2.77.0 on November 27 (v2.77.0 release notes). The headline features in 2.77 are:
- Conversation stores for SQLite, PostgreSQL and MongoDB. Save a whole
Conversationbetween runs and load it again by ID. - A compaction foundation. A
compact_history()capability hook,RunContext.request_compaction(),Agent.compact_history(), and newCompactionStartEventandCompactionEndEventstream events. - Readable thinking across providers. A unified
thinking_summarysetting, plusanthropic_thinking_displayandbedrock_thinking_display. - Validated JSON schema output.
StructuredDict(validate=True)checks output against its JSON schema. - CodeMode and fallback updates. CodeMode sandboxes can import host modules with
external_modules, andfallback_oncan takeUnsupportedSettingWarningto skip a model that would ignore a setting. - Safer sub-agents. Sub-agent definition files below
operatorauthority are skipped with a warning.
Version 2.76 added stateless Google Interactions support through GoogleInteractionsModel, CodeMode(allow_final_output=True), per-tool ui_visibility for UI adapters, mid-session tool updates in realtime sessions, and a /computer-use desktop sandbox command in Pax, the project’s coding agent (v2.76.0 release notes).
Pydantic AI 2.75 vs 2.77
The table compares the release we covered last with the current one, based on the official notes for 2.76 and 2.77.
| Area | Pydantic AI 2.75 (Nov 25) | Pydantic AI 2.76 and 2.77 (Nov 26-27) |
|---|---|---|
| Headline | Computer use tool contract, fallback on empty or invalid responses | Conversation stores, compaction hook, readable thinking |
| Persistence | Step persistence for recovering runs | SQLite, PostgreSQL and MongoDB ConversationStore backends |
| Long contexts | Harness compaction strategies | compact_history() hook, request_compaction(), Agent.compact_history(), compaction events |
| Thinking | Unified thinking setting | thinking_summary, anthropic_thinking_display, bedrock_thinking_display |
| Models | Claude, GPT-5.4+ and Gemini computer use | GoogleInteractionsModel; deprecation warning for gemini-2.5-pro and gemini-2.5-flash |
| Output | RunContext.submit_output() | StructuredDict(validate=True); CodeMode allow_final_output |
| Pax | /trust and –version | /computer-use sandboxes, -x plugin flag, permissions mode in footer |
If you route models through a proxy, our LiteLLM 1.111 guide covers the gateway side.
How to upgrade and use the new features
Pydantic AI 2.77.0 requires Python 3.11 or newer, according to its PyPI listing. Follow these steps to move an existing project forward (release notes):
- Upgrade. Run
pip install -U pydantic-ai(orpydantic-ai-slimwith your extras). Thegoogleextras now requiregoogle-genai>=2.34.0. - Read the Compatibility Notes. Both releases list them first. Search your code for exhaustive
matchstatements over stream events, sinceCompactionStartEventandCompactionEndEventjoin the union. - Fix read_file offsets. In 2.76,
FileSystemread_fileoffsets became 1-indexed. Where you passoffset=N, passN + 1. - Add a conversation store. Import a store from
pydantic_ai_harness.conversation_store, load the conversation by ID, run the agent withconversation=, and saveresult.conversation. - Turn on readable thinking. Use
Thinking(effort="high", summary=True)or setthinking_summary=Truein model settings. - Validate schema output. Wrap an external JSON schema in
StructuredDict(..., validate=True)so mismatches go back to the model to fix.
How the stores work. Each store keeps a conversation as a log and stores every message once, keyed by its SHA-256, so continuing a conversation appends only new messages and a fork shares history instead of copying it. Saves are checked against the conversation’s revision: if someone else saved in between, save raises ConversationConflict instead of overwriting. Parts of 64 KiB or more are externalized by default (Conversation Stores docs).
The backends differ. SQLite and PostgreSQL write each save in one transaction and clean up unused entries on delete. MongoDB uses no transactions, so deleting a conversation removes only its record. The stores are part of Pydantic AI Harness, which is still on 0.x releases, so its API may change between minor versions (docs).
Compaction: hooks, events and compact_history()
Version 2.77 adds the plumbing that Pydantic AI’s built-in compaction is being built on. The docs say NativeCompaction already compacts with the serving model’s own API, while a size threshold and a portable summarizer will follow in later releases (Compaction docs).
- Request compaction. Any tool or capability hook can call
ctx.request_compaction(reason=..., focus=...). The history is compacted before the next model request, and a pending request merges with a new one so a user’s focus is not lost. - Compact between turns.
agent.compact_history(messages, focus=..., reason=...)compacts a saved history without sending a prompt, for example while the user is idle and the prompt cache is still warm. It returns aCompactionRunResultwith the compactedall_messages(). - Recover from overflow. If a model rejects a request with
ModelContextWindowExceededErrorand a capability has acompact_historyhook, Pydantic AI compacts with reasoncontext_overflowand retries the same model once. - Watch or cancel. Listeners can
cancel()aCompactionStartEvent;CompactionEndEventcarries the compaction record.
Compaction usage counts toward the run’s usage limits but not as a request. In 2.77, default FallbackCompaction chains also recover when SummarizingCompaction fails, instead of ending the parent run (release notes). For a framework comparison, see our Mastra 1.86 guide on durable agents.
Power-user tips and limitations
- Expect a little more latency on Claude. With the unified
thinkingsetting on Anthropic or Claude on Bedrock, Pydantic AI now sendsdisplay: summarized. Newer Claude models then return summarized thinking instead of empty blocks, which can add a little latency before the first text token. Setanthropic_thinking_display="omitted"to opt out. - Know where thinking_summary is ignored. The docs list providers without a switch, including OpenAI Chat Completions, xAI, Mistral, Ollama and DeepSeek. On OpenAI’s Responses API, summaries are not requested by default because they may require organization verification.
- Watch usage limits. Fallback subagent requests from
XSearchandImageGenerationnow count towardUsageLimits, including the defaultrequest_limit=50. - Check sub-agent folders. A delegate working outside the parent’s directory runs at
noneauthority unless apath_authorityentry covers it. Let in-flight durable runs finish before upgrading. - Plan Gemini migrations. Requests to
gemini-2.5-proandgemini-2.5-flashnow emitDeprecatedModelWarning, which fails tests that treat warnings as errors.
Limitations. Pydantic AI is free and open source, and the release notes list no pricing; you pay your model provider directly. The thinking details above come from the (Thinking docs). Compaction beyond NativeCompaction still needs a capability you write or a Harness strategy. For other agent frameworks, see our LlamaIndex 0.14.26 guide and OpenAI Agents SDK Codex guide.
Frequently asked questions
What is new in Pydantic AI 2.77?
Version 2.77.0, released November 27, 2026, adds SQLite, PostgreSQL and MongoDB conversation stores, a compaction hook with Agent.compact_history(), portable readable thinking through thinking_summary, StructuredDict(validate=True), and CodeMode access to host modules.
How do I save Pydantic AI conversations to a database?
Import SqliteConversationStore, PostgresConversationStore or MongoConversationStore from pydantic_ai_harness.conversation_store. Load a Conversation by ID, pass it to agent.run(conversation=…), then save result.conversation. Conflicting saves raise ConversationConflict.
How do I compact a long conversation in Pydantic AI?
Add a capability with a compact_history hook, such as NativeCompaction, then call ctx.request_compaction() from a tool or hook, or call agent.compact_history() on a saved history to compact it without sending a new prompt.
How do I see Claude’s thinking in Pydantic AI?
Set thinking_summary=True, or use Thinking(summary=True). On Anthropic and Claude on Bedrock, Pydantic AI now sends display: summarized when thinking is enabled, so newer Claude models return summarized thinking instead of empty blocks.
Does upgrading to Pydantic AI 2.77 break existing code?
It can. The release notes list compatibility changes, including renamed Pax session-store classes, new stream event types, a 1-indexed read_file offset from 2.76, and usage-limit counting for fallback subagents.
Sources
- Pydantic AI v2.77.0 release notes (GitHub, November 27, 2026)
- Pydantic AI v2.76.0 release notes (GitHub, November 26, 2026)
- Pydantic AI docs: Provider-Native Compaction
- Pydantic AI docs: Conversation Stores
- Pydantic AI docs: Thinking
1 thought on “Pydantic AI 2.77: Power-User Guide to Conversation Stores, Compaction and Thinking”