The agent development library pydantic-ai has released a version with more conversation history storage options and expanded support for compacting long conversations. Developers can tailor history storage and compaction timing to their applications. Changes to interrupted-response detection and usage accounting also affect existing production code.

1. More storage choices and compaction controls

Released on November 27, v2.77.0 adds SQLite, Postgres, and MongoDB backends, software components that handle conversation storage. This gives applications that retain conversation history more storage choices.

Pax's session store class and conflict exception have been renamed SqliteSessionStore and SessionConflict, respectively. The old names can still be imported, with a deprecation warning. Alongside the new storage options, names used in code that references session stores are being standardized.

History compaction reduces long conversation histories to a more manageable size. This release adds compact_history(), a hook that plugs compaction into execution, and RunContext.request_compaction() to request it during a run. Developers can request compaction within the execution flow and receive start and end events to track the process.

These events occur when compaction is requested or a compaction hook is registered. Separately, Agent.compact_history() can compact message history without continuing the conversation. This supports both control during execution and history cleanup outside a run.

2. Changes to information placement and completion detection

In new runs, Memory's startup snapshot, a copy of its state at a specific time, and information from Planning precede the user prompt, the input sent to the model. Previously appended through a separate model request, they now appear at the front of the same request as the prompt. This changes where code should look for this information in conversation history.

Messages carrying compaction results are now application-side messages rather than user input. Previously stored compaction result messages remain recognized and are converted to the new format during the next compaction. Code reading these messages from history can switch to locating them through CompactionReceiptPart.

If an Anthropic, Google, or OpenAI Responses stream ends before the provider's completion event, the final stream_response() value has a status of 'incomplete'. Streams deliver responses in chunks, and this change distinguishes arrival of the final value from successful completion. Code displaying responses or starting follow-up work can use this status to handle incomplete termination.

3. Fallback model work counts toward run limits

Requests and tokens used by fallback subagents for XSearch and ImageGeneration now count toward the overall run's usage limits. The default request limit is 50. Even for the same task, extra requests from switching to a fallback model can reach the limit sooner, and runs already near it may end with UsageLimitExceeded.

By default, conversation search covers the most recent 2000 messages within the search scope. Results indicate when the cap leaves some history unexamined, and raising the setting allows older records to be searched. This change prevents search from holding up run processing for too long.

ModelRetry occurs if a query exceeds 1,000 characters or contains more than 32 unique terms. Search depth and query size are limited separately, so the scope for finding older conversations and the query structure are distinct settings to adjust.

Permission enforcement is now organized around the parent run. If permissions are below 'operator', subagent definition files on disk are not read, and a warning is logged. Delegated working directories receive the lowest permission the parent assigned to that path. Outside the parent's working directory, permission is 'none' unless a separate path permission exists.

4. Weigh expanded capabilities against operational costs

These changes offer more flexibility in configuring storage and compaction, but require code adjustments for event handling, message history reading, and usage accounting. The key question is not just how to enable new features, but how existing code interprets information placement and completion status in conversations.

Model responses also bring both benefits and costs. With unified thinking settings for Claude on Anthropic and Bedrock, newer Claude models return summarized thinking instead of empty thinking content. According to the release notes, returning summaries may slightly increase time to the first text token. Changes to compaction message formats or request construction for some models may also cause a one-time miss in existing conversations' prompt caches, which reuse repeated input.

For durable runs using subagent definition folders, the release notes advise upgrading after ongoing work finishes or applying a versioning process for workers or applications. Workers are processes that execute assigned tasks. In this case, deployment planning includes not only feature testing but also deciding which version will finish each run.

The value of v2.77.0 lies in expanding conversation storage and compaction options while aligning completion detection, usage accounting, and permission handling more closely with actual execution.