Automatic conversation summarization and history management for Pydantic AI. Provides history processors and Pydantic AI capabilities (0.1.x) to compress, trim, and warn about conversation context windows. Current version 0.1.4, requires Python >=3.10. This library replaces the older pydantic-ai-middleware pattern with native capabilities. Active development.
pip install summarization-pydantic-aiVerified import paths — ran on the pinned version, not inferred.
Basic usage with SummarizationProcessor as a history processor.
Replace `ContextManagerMiddleware` with the appropriate capability. For example, if you used `history_processor`, switch to `SummarizationProcessor` or `SlidingWindowProcessor`. If you used the middleware's agent integration, use the new capabilities via `Agent.set_capabilities()`.
If unintended, set `include_compact_tool=False` (default) or control tool availability via system prompt.
Check your logic: `keep_head` should be a small number (e.g., 2-5) to preserve system prompts and initial instructions, not exceed retention.
Explicitly set a capable model (e.g., `'openai:gpt-4o-mini'`) for summarization to ensure quality.