Rahulrajaram compaction fixes#3503
Open
rahulrajaram wants to merge 6 commits intoaws:mainfrom
Open
Conversation
- Track cumulative token usage (input + output) in ConversationState - Capture token usage from MetadataEvent in response stream - Add MetadataEvent support to ChatResponseStream enum - Trigger proactive compaction at 98% of context window - Add tests for threshold calculation and overflow prevention This fixes the bug where message count was used instead of token count, causing overflow errors when conversations had many messages with large tool outputs. Now compaction triggers before overflow based on actual token usage from the backend.
- Replace StyledText helper methods with direct crossterm color commands - Ensures consistent ANSI escape sequence generation across terminals - Add unit test to verify proper rendering of prompt with colors - Remove unused StyledText import The fix replaces StyledText::secondary_fg() and StyledText::success_fg() with style::SetForegroundColor() calls using Color::DarkGrey and Color::Green, and StyledText::reset() with style::ResetColor for proper ANSI code output.
Test verifies that user input is sanitized before being appended to the transcript. Currently fails, demonstrating that hidden unicode characters are preserved in the transcript when they should be removed.
Move append_user_transcript() call to after sanitize_unicode_tags() in handle_input(). This ensures the transcript contains the sanitized version of user input, matching what is actually sent to the LLM. Previously, the transcript was appended in prompt_user() before sanitization, causing hidden unicode characters and control characters to be preserved in the transcript while being removed from the actual message sent to the model.
Test shows that run_hooks() executes for full duration without responding to Ctrl+C signals, causing terminal to appear frozen. This validates the reported issue where CLI becomes unresponsive during 'Thinking...' state when hooks are executing.
Hooks now respond to Ctrl+C signals during execution instead of running for the full 30-second timeout. Uses tokio::select! to monitor both hook completion and Ctrl+C signals. Fixes terminal freeze issue where CLI becomes unresponsive during hook execution in 'Thinking...' state.
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.
Fix: Conversation overflow, terminal responsiveness, and transcript accuracy
Changes