[P1] Implement Conversation History Trimming #10
Labels
No labels
audit-2025-12-03
component/api
component/commands
component/llm
component/memory
component/tick-loop
component/tools
priority
high
priority
low
status
in-progress
status
needs-info
status
needs-triage
status
on-hold
type
bug
type
documentation
type
enhancement
type
feature
type
refactor
type
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
blightbow/evennia_ai#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
conversation_historyhas no token-based trimming despitemax_historyattribute existing. This leads to unbounded growth and potential context overflow.Suggested Fix
max_context_tokensPriority
P1 — High Priority
Source
Architecture Audit 2025-12-03, Section 2: Memory Leak Potential
Resolution Summary
Implemented a two-phase context compaction system based on research from Claude Code, MemGPT, and JetBrains NeurIPS 2025 findings.
Implementation Details
Configuration Attributes (
assistant_script.py:161-169):compact_enabled- Toggle compaction on/off (default: True)compact_sleep_threshold- Trigger at 70% context usage during sleepcompact_emergency_threshold- Emergency trigger at 80% usagecompact_preserve_window- Keep last 20 messages intactcompact_model- Optional override model for summarizationcompact_prompt- Optional custom summarization promptlast_compaction- Timestamp trackingCore Functions:
count_conversation_tokens()inhelpers.py:452-473- Token counting helpergenerate_context_summary()inllm_interaction.py:317-380- LLM-based summarizationcompact_conversation_history()inrag_memory.py:825-956- Main compaction logicIntegration Points:
rag_memory.py:1111-1120- Runs after memory consolidationassistant_script.py:646-667- Triggers during awake mode when approaching limitsKey Features:
Testing
test_context_compaction.pyDocumentation