Skip to content

Collapse websockets binary frame hex dumps to byte counts#127

Merged
alexkroman merged 1 commit into
mainfrom
claude/hopeful-maxwell-dxrz5q
Jun 12, 2026
Merged

Collapse websockets binary frame hex dumps to byte counts#127
alexkroman merged 1 commit into
mainfrom
claude/hopeful-maxwell-dxrz5q

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

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:

    • Added regex pattern _BINARY_FRAME_HEX to match websockets frame log format (BINARY/CONT opcodes followed by hex bytes and metadata)
    • Extended _RedactingFormatter.format() to collapse binary frame hex payloads to byte counts for websockets logger records only
    • Updated module docstring to explain the binary frame collapsing behavior
  • tests/test_debuglog.py:

    • Added test_binary_frame_hex_is_collapsed_to_byte_count() to verify hex payload collapsing with synthetic log messages
    • Added test_real_websockets_binary_frame_rendering_is_collapsed() to test against actual websockets Frame objects and their string representation
    • Added test_text_frames_and_other_loggers_keep_their_payload() to ensure text frames and non-websockets loggers are unaffected

Implementation 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 -vv debugging utility (direction and size information) while eliminating the meaningless hex dumps from high-frequency binary frames.

https://claude.ai/code/session_01TBiiKi2mruovPieXh2ezHi

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
@alexkroman alexkroman enabled auto-merge June 12, 2026 20:45
@alexkroman alexkroman added this pull request to the merge queue Jun 12, 2026
Merged via the queue into main with commit b3e0e59 Jun 12, 2026
16 checks passed
@alexkroman alexkroman deleted the claude/hopeful-maxwell-dxrz5q branch June 12, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants