Collapse websockets binary frame hex dumps to byte counts#127
Merged
Conversation
A realtime session logs dozens of '> BINARY fb ff ...' lines per second whose payload is PCM audio — meaningless as hex even after websockets' own 75-char cap. The -vv formatter now rewrites websockets binary/CONT frame records to keep just the direction and metadata, e.g. '> BINARY [9600 bytes]'. Other loggers and TEXT frames are untouched. https://claude.ai/code/session_01TBiiKi2mruovPieXh2ezHi
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
Adds filtering to the debug log formatter to collapse websockets binary frame hex dumps to their byte counts, reducing log noise from high-frequency binary frames (e.g., PCM audio streams) while preserving debugging utility.
Changes
aai_cli/debuglog.py:_BINARY_FRAME_HEXto match websockets frame log format (BINARY/CONT opcodes followed by hex bytes and metadata)_RedactingFormatter.format()to collapse binary frame hex payloads to byte counts for websockets logger records onlytests/test_debuglog.py:test_binary_frame_hex_is_collapsed_to_byte_count()to verify hex payload collapsing with synthetic log messagestest_real_websockets_binary_frame_rendering_is_collapsed()to test against actual websockets Frame objects and their string representationtest_text_frames_and_other_loggers_keep_their_payload()to ensure text frames and non-websockets loggers are unaffectedImplementation Details
The regex targets the specific format produced by websockets' Frame
__str__method: opcode name (BINARY or CONT), hex byte pairs (possibly with "..." elision), and the "[N bytes]" metadata. The formatter only applies this transformation to records from the "websockets" logger namespace, leaving other loggers and text frames untouched. This preserves-vvdebugging utility (direction and size information) while eliminating the meaningless hex dumps from high-frequency binary frames.https://claude.ai/code/session_01TBiiKi2mruovPieXh2ezHi