Registry / llm-agents / summarization-pydantic-ai

summarization-pydantic-ai

JSON →
library0.1.8pypypi✓ verified 80d ago

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-ai
INSTALL
IMPORT
SIG · SUMMARIZATION-PYDA
S
summarization-pydantic-ai
llm-agentspythonv0.1.8
Install
4.9s avg
Import
Disk
44MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 5.8s
py 3.11
✓ —
✓ 5.1s
py 3.12
✓ —
✓ 4.4s
py 3.13
✓ —
✓ 4.5s
py 3.9
✕ build_error
✕ build_error
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SummarizationProcessor
from pydantic_ai_summarization import SummarizationProcessor
from summarization_pydantic_ai import SummarizationProcessor

Basic usage with SummarizationProcessor as a history processor.

from pydantic_ai import Agent from summarization_pydantic_ai import SummarizationProcessor # Create a summarization processor that triggers at 10 messages processor = SummarizationProcessor( trigger=("messages", 10), retention=("messages", 5), summary_model="openai:gpt-4o-mini", ) agent = Agent( model="openai:gpt-4o-mini", system_prompt="You are a helpful assistant.", history_processor=processor, ) # Start a conversation; messages will be summarized when limit reached result = agent.run_sync("Hello!") print(result.data)
Debug
Known issues
breakingVersion 0.1.0 replaced the middleware-based API (ContextManagerMiddleware) with capabilities (SummarizationCapability, SlidingWindowCapability, LimitWarnerCapability, ContextManagerCapability). Old code using `create_context_manager_middleware()` or `ContextManagerMiddleware` must be migrated to the new capability system.
fix
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()`.
affects: < 0.1.0
breakingThe `ContextManagerCapability` now includes a `compact_conversation` tool when `include_compact_tool=True`. This tool is available to the model and may be called unexpectedly, leading to conversation compression the agent did not explicitly request.
fix
If unintended, set `include_compact_tool=False` (default) or control tool availability via system prompt.
affects: >= 0.1.3
gotchaWhen using `keep_head` on `SlidingWindowProcessor`, specifying a high number may cause the head to be larger than the retention, resulting in undefined behavior or errors. Always ensure `keep_head < retention` (or at least less than the total window size).
fix
Check your logic: `keep_head` should be a small number (e.g., 2-5) to preserve system prompts and initial instructions, not exceed retention.
affects: >= 0.1.4
gotchaThe `summary_model` parameter in `SummarizationProcessor` defaults to the agent's model if not set. If the agent's model is not capable of summarization (e.g., a very small local model), compression may fail silently or produce poor summaries.
fix
Explicitly set a capable model (e.g., `'openai:gpt-4o-mini'`) for summarization to ensure quality.
affects: all
Upgrade
Version history
0.1.8latest on PyPI · released Jun 17, 2026
Audit
Dependencies
pydantic-ai-slimrequiredCore dependency; version >=1.74.0 required for async get_instructions support in toolsets
openaioptionalDefault token counter uses tiktoken; optional if custom counter provided
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
2
Resources
summarization-pydantic-ai — pip install summarization-pydantic-ai · libregistry