-
Notifications
You must be signed in to change notification settings - Fork 44
Add automatic compaction of historical messages for agents #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Implementation Plan for Message CompactionAfter analyzing the codebase, here's a detailed plan for implementing automatic compaction of historical messages for agents: 1. Enhance LLM Abstraction to Track Token LimitsA. Modify
|
Revised Implementation Plan: Agent Self-Managed Message CompactionBased on feedback, we're revising the approach to give the agent more self-awareness and control over its context window usage. Instead of automatic compaction, we'll:
1. Enhance LLM Abstraction to Track Token LimitsSame as previous plan, we need to enhance the LLM abstraction to track and return:
2. Create a Status Update MechanismA. Create a new file
|
Example Status UpdateHere's an example of what the status update would look like for the agent:
This status update provides:
The status update will be sent periodically (e.g., every 5 agent interactions) to keep the agent informed about its resource usage and background tasks. |
Implements #338 - Agent self-managed message compaction: 1. Enhanced LLM abstraction to track token limits for all providers 2. Added status update mechanism to inform agents about resource usage 3. Created compactHistory tool for summarizing older messages 4. Updated agent documentation and system prompt 5. Added tests for the new functionality 6. Created documentation for the message compaction feature This feature helps prevent context window overflow errors by giving agents awareness of their token usage and tools to manage their context window.
would you consider sliding window or some kind of Dynamic Context Trimming? or maybe an approach from recent cursor update - making regular checkpoints, being able to return to them, and they can also contain smaller summaries of previous steps. or some kind of memory. so you can recover from crashes easily. https://cline.bot/blog/understanding-the-new-context-window-progress-bar-in-cline |
# [mycoder-agent-v1.7.0](mycoder-agent-v1.6.0...mycoder-agent-v1.7.0) (2025-03-21) ### Bug Fixes * Fix TypeScript errors and tests for message compaction feature ([d4f1fb5](d4f1fb5)) ### Features * Add automatic compaction of historical messages for agents ([a5caf46](a5caf46)), closes [#338](#338) * Improve message compaction with proactive suggestions ([6276bc0](6276bc0))
🎉 This issue has been resolved in version mycoder-agent-v1.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Problem
When agents run for extended periods, they accumulate a large history of messages that eventually fills up the LLM's context window, causing errors when the token limit is exceeded.
Proposed Solution
Implement automatic compaction of historical messages to prevent context window overflow:
Enhance the LLM abstraction to track and return:
Monitor token usage and trigger compaction when it approaches a configurable threshold (e.g., 50% of maximum)
When triggered, compact older messages (excluding recent ones, perhaps 10 messages back) into a single summarized message
Use a prompt like: "Provide a detailed but concise summary of our conversation above. Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next."
Benefits
Questions
The text was updated successfully, but these errors were encountered: