DedrooM: loop detection + context compression for Claude Code (open source)
I kept running into the same two problems with Claude Code on longer sessions: it'd get stuck retrying a failing command in a near-identical loop, and tool output (file listings, logs, diffs) would pile up in context even after it stopped being useful. Both quietly ran up the token bill.
So I built DedrooM - a small proxy that sits in front of Claude Code (and a few other agents: Codex, Aider, Cursor, Cline, OpenCode) and does two things:
Loop Detection
Stops loops before they compound. Tracks repeated tool calls with an adaptive window, tightens up automatically once error rate climbs, and blocks a call outright if it's clearly stuck.
Context Compression
Compresses redundant tool output before it hits the model - truncates repetitive stuff like long file listings, dedupes logs, keeps the parts that actually matter.
Getting Started
It's one command to try:
pip install dedroom
dedroom wrap claude
dedroom unwrap claude puts things back to normal.
It's Apache 2.0, source is here: https://github.com/Devaretanmay/dedroom
Caveats
Being upfront about the numbers: the compression/savings figures in the README are from a handful of internal test scenarios, not a big benchmark suite - real savings depend a lot on your workload (loop-prone sessions and repetitive tool output benefit a lot more than a clean session does). I'd rather you try it and tell me it doesn't do much for your setup than oversell it here.
Feedback
Would genuinely like feedback from people running long Claude Code sessions - especially if it either catches something useful or gets in your way. Happy to answer questions about how the loop detection or compression actually works under the hood.
Comments
No comments yet. Start the discussion.