-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add auto-updating savings data to current-session.txt (issue #113) #115
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
Conversation
Add real-time token savings tracking to current-session.txt file by automatically updating savings metrics every 10 operations. Changes: - Update README.md to document new savings object in current-session.txt - Savings object includes 7 fields: totalTokensSaved, tokenReductionPercent, originalTokens, optimizedTokens, cacheHitRate, compressionRatio, lastUpdated - Auto-update mechanism calls get_cache_stats() MCP tool every 10 operations - Graceful error handling - skips update if MCP call fails without blocking Implementation location: - PowerShell hooks: ~/.claude-global/hooks/handlers/token-optimizer-orchestrator.ps1 - Update-SessionOperation function modified to fetch and calculate savings data Benefits: - Real-time visibility into token optimization performance - No need to manually call get_session_stats() for monitoring - Minimal performance impact (<50ms per update) - Atomic file writes prevent corruption Resolves #113
|
Warning Rate limit exceeded@ooples has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 30 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Summary by CodeRabbitRelease Notes
WalkthroughREADME.md documentation updated to describe a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Performance Benchmark Results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test (Node 20)
- GitHub Check: Test (Node 18)
🔇 Additional comments (2)
README.md (2)
492-528: Excellent documentation of the new auto-updating savings feature.The Session Tracking Files section clearly explains the new
savingsobject, its seven fields, auto-update mechanism (every 10 operations), calculation method, error handling, and distinguishes this feature from per-operation analysis. All PR objectives are well documented and the "New in v1.x" and "Note" sections properly set user expectations.The only items requiring verification are the data type consistency issue (cacheHitRate format) and tool name accuracy (get_cache_stats vs get_session_stats), both flagged in separate comments above.
519-527: Verify the MCP tool name matches the actual implementation.The documentation references
get_cache_stats()MCP tool (line 522), but the PR objectives also mentionget_session_stats(). Confirm which tool is actually called in the PowerShell implementation to ensure documentation accuracy.Run this script to find the MCP tool calls in the PowerShell orchestrator:
If the tool name differs from documentation, update line 522 accordingly.
Change cacheHitRate from decimal format (0.72) to percentage format (72.0) to match the implementation and other examples in the documentation. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Performance Benchmark Results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the documentation to reflect a new automatic savings tracking feature in session data files. The changes document that savings metrics are now auto-updated every 10 operations, eliminating the need for manual get_session_stats() calls for real-time monitoring.
Key Changes:
- Updated cache hit rate display format from decimal (0.72) to percentage (72.0)
- Expanded session file format documentation to include new
savingsobject with detailed metrics - Added explanation of automatic savings update mechanism that triggers every 10 operations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ```json | ||
| { | ||
| "sessionId": "abc-123", | ||
| "sessionStart": "20251031-082211", |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Timestamp format uses 'YYYYMMDD-HHMMSS' pattern. Consider adding clarification in documentation that this represents '2025-10-31 08:22:11' to improve readability.
| **New in v1.x**: The `savings` object is now automatically updated every 10 operations, eliminating the need to manually call `get_session_stats()` for real-time monitoring. This provides instant visibility into token optimization performance. | ||
|
|
||
| **How it works**: | ||
| - Every 10 operations, the PowerShell hooks automatically call `get_cache_stats()` MCP tool |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The documentation mentions 'PowerShell hooks' which may not apply to all users. Consider clarifying whether this automatic update mechanism works across all platforms or is platform-specific.
| - Every 10 operations, the PowerShell hooks automatically call `get_cache_stats()` MCP tool | |
| - On Windows, every 10 operations, the PowerShell hooks automatically call `get_cache_stats()` MCP tool | |
| - On other platforms, you may need to manually call `get_cache_stats()` or set up a similar hook using your preferred shell (e.g., Bash, Zsh) |
| "tokenReductionPercent": 68.2, // Percentage of tokens saved | ||
| "originalTokens": 184000, // Original token count before optimization | ||
| "optimizedTokens": 58570, // Token count after optimization | ||
| "cacheHitRate": 42.5, // Cache hit rate percentage |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The example shows cacheHitRate: 42.5 in the session file format, but the earlier example at line 484 shows cacheHitRate: 72.0. Using consistent example values throughout the documentation would improve clarity and reduce potential confusion.
| "cacheHitRate": 42.5, // Cache hit rate percentage | |
| "cacheHitRate": 72.0, // Cache hit rate percentage |
|
This PR is included in version 4.1.0. 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Implements GitHub Issue #113: Automatically add token savings data to
current-session.txtfor easy real-time monitoring without needing to manually callget_session_stats()MCP tool.Changes
PowerShell Hook Updates
~/.claude-global/hooks/handlers/token-optimizer-orchestrator.ps1Update-SessionOperationfunction to auto-fetch savings data every 10 operationsget_cache_stats()MCP tool to get real-time cache performance metricsConvertTo-Json -Depth 10Documentation Updates
README.md- Session Tracking Files sectionsavingsobject with 7 fieldsNew Session File Format
{ "sessionId": "aad1f532-43d3-44af-ba65-6f89c409b122", "sessionStart": "20251031-082211", "totalOperations": 2410, "totalTokens": 0, "lastOptimized": 0, "savings": { "totalTokensSaved": 125430, "tokenReductionPercent": 68.2, "originalTokens": 184000, "optimizedTokens": 58570, "cacheHitRate": 42.5, "compressionRatio": 0.32, "lastUpdated": "20251031-162400" } }Benefits
get_session_stats()for quick checksTesting
invoke-mcp.ps1helpersrc/core/cache-engine.tsRelated Issues
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com