feat: add memory monitoring and proactive compaction#167
Merged
laynepenney merged 2 commits intomainfrom Jan 26, 2026
Merged
Conversation
Add memory monitoring system to prevent heap out of memory errors: - Real-time heap usage tracking with configurable thresholds - Three alert levels: warning (60%), compact (70%), critical (85%) - 30-second minimum interval between automatic compactions - Proactive compaction triggered when memory usage exceeds 70% - New '/compact memory' command to check heap usage This addresses the V8 heap out of memory crash that occurs during long-running sessions with large conversation histories. Files: - src/memory-monitor.ts: New memory monitoring system - src/agent.ts: Integrate memory monitor and add proactive compaction - src/commands/compact-commands.ts: Add memory subcommand - src/index.ts: Add memory status display handler Wingman: Codi <codi@layne.pro>
Fix E16 error by using correct snake_case property names from Node.js v8 API: - Fix property names: used_heap_size, heap_size_limit, etc. - Use proper ES module import for v8 - Add additional utility methods: isCritical(), getDetailedSnapshot() - Test confirms memory monitor works correctly Build and all 324 tests pass successfully. Wingman: Codi <codi@layne.pro>
Collaborator
Author
|
Final Self-Review: All tests pass, build successful, memory monitor functional. 15/15 edge cases tested. Ready to merge. |
laynepenney
added a commit
that referenced
this pull request
Jan 26, 2026
* feat: add memory monitoring and proactive compaction Add memory monitoring system to prevent heap out of memory errors: - Real-time heap usage tracking with configurable thresholds - Three alert levels: warning (60%), compact (70%), critical (85%) - 30-second minimum interval between automatic compactions - Proactive compaction triggered when memory usage exceeds 70% - New '/compact memory' command to check heap usage This addresses the V8 heap out of memory crash that occurs during long-running sessions with large conversation histories. Files: - src/memory-monitor.ts: New memory monitoring system - src/agent.ts: Integrate memory monitor and add proactive compaction - src/commands/compact-commands.ts: Add memory subcommand - src/index.ts: Add memory status display handler Wingman: Codi <codi@layne.pro> * fix: ensure proper v8.getHeapStatistics() integration Fix E16 error by using correct snake_case property names from Node.js v8 API: - Fix property names: used_heap_size, heap_size_limit, etc. - Use proper ES module import for v8 - Add additional utility methods: isCritical(), getDetailedSnapshot() - Test confirms memory monitor works correctly Build and all 324 tests pass successfully. Wingman: Codi <codi@layne.pro>
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 memory monitoring system to prevent heap out of memory errors during long-running Codi sessions.
Problem
V8 heap OOM crashes occur when long-running sessions accumulate large conversation histories (~4GB heap limit).
Solution
Added memory monitoring with:
Files
Testing
Usage
/compact memory shows heap usage and stats