[BUG] claude reads .o and binary files sometimes after compaction, immediately filling the entire context

Resolved 💬 3 comments Opened Dec 26, 2025 by swiftveteran Closed Feb 14, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

═════════════════════════════════ Conversation compacted · ctrl+o for history ════════════════════════════════
  ⎿  Read ../../../../tmp/test_writing_file.c (16 lines)
  ⎿  Read ../../../../tmp/test_reading_file.c (18 lines)
  ⎿  Read ../../../../tmp/test_reading_file.o (1 lines)
  ⎿  Read ../../../../tmp/test_reading_file (1 lines)

∴ Thinking…

It reads in a one-off binary it made, ../../../../tmp/test_reading_file even though I have a read hook that forbids it from reading binary files. This file immediately fills up the context and causes compaction again in a loop, blowing through the entire 5 hour budget in about 20m of compactions.

Something after compaction is causing this? Anyway, not sure of any workarounds. Thanks!

What Should Happen?

Compaction should honor the read hooks and should be smart enough not to read in binary or .o files to begin with.

Error Messages/Logs

Steps to Reproduce

Whenever it's working on a C program with a bug that it wants to investigate, it has a chance to start looping like this. I have to babysit it and if I look away it

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.76 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗