Open
Conversation
added 3 commits
April 17, 2026 15:37
- Fix transitive compaction chain detection: _find_compacted_run_ids() and session get_messages() now expand the full chain of compacted runs, preventing incorrectly loading runs that were indirectly compacted - Add missing ashould_compact() async method to CompactionManager - Fix 4 f-string violations per .cursorrules (no f-string without variables)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add conversation compaction support for both Agent and Team. When conversation history grows large (exceeding a
configurable token threshold), the system automatically compacts older messages into an LLM-generated summary, reducing
context window usage while preserving conversation continuity.
Behavior:
enable_compaction=False(default): No changes to existing Agent/Team logic — fully backward compatibleenable_compaction=True: Compaction logic is activated, history is compacted when exceeding thresholdKey changes:
compactionmodule (libs/agno/agno/compaction/) with aCompactionManagerthat handles threshold detection,summary generation via LLM, and compaction boundaries
compacted_run_idsin the runrecord
are not compacted independently
Resolves #7557
Type of change
Checklist
./scripts/format.shand./scripts/validate.sh)Duplicate and AI-Generated PR Check
issue
Test Results
All 10 integration tests passed:
Files Changed
New files:
libs/agno/agno/compaction/__init__.pylibs/agno/agno/compaction/manager.pycookbook/02_agents/03_context_management/conversation_compaction.pycookbook/03_teams/09_context_management/team_conversation_compaction.pylibs/agno/tests/integration/agent/test_compaction.pylibs/agno/tests/integration/teams/test_compaction.pyModified files:
libs/agno/agno/models/base.py— defaultcontext_window: Optional[int] = 128000libs/agno/agno/agent/agent.py—enable_compaction,compaction_managerparamslibs/agno/agno/agent/_init.py— compaction manager initializationlibs/agno/agno/agent/_messages.py— compaction priority history loadinglibs/agno/agno/agent/_run.py— 4 compaction trigger pointslibs/agno/agno/run/agent.py—compacted_run_idsfieldlibs/agno/agno/session/agent.py— compaction boundary detectionlibs/agno/agno/team/team.py—enable_compaction,compaction_managerparamslibs/agno/agno/team/_init.py—_set_compaction_manager()libs/agno/agno/team/_messages.py— compaction priority history loadinglibs/agno/agno/team/_run.py— 6 compaction trigger pointslibs/agno/agno/run/team.py—compacted_run_idsfieldlibs/agno/agno/session/team.py— compaction boundary detection