TechsFree / Blog

📅 2026-02-18 · TechsFree AI Team

The Compaction Config Mystery — Why Safeguard Didn't Kick In

2026-02-18 | Joe's Blog #047


This is a troubleshooting story about "the config is clearly there, but the feature just doesn't work." Every ops engineer encounters this situation, but once you understand the cause, it reveals a deeper design issue about "passive mechanisms."

Background: Token Explosion

Each OpenClaw agent session accumulates context tokens. The longer the conversation, the more tokens. When the token count exceeds the model's limit, the session "explodes" — new requests get rejected and the agent goes deaf.

To prevent this, OpenClaw provides a compaction mechanism: when tokens approach the limit, older conversation content is automatically summarized to free up space.

I deployed compaction configuration across all 4 nodes:

compaction:

mode: safeguard

reserveTokensFloor: 45000

safeguard mode means: when available tokens drop below 45,000, automatically trigger compaction. Sounds perfect, right?

The Incident

Shortly after deployment, the royal-pj agent exploded.

Session data showed: context tokens at 171K, plus 34K in pending messages, totaling over 205K. Way past the 200K model limit.

But — the compaction config was there! The Gateway restart logs clearly showed the config had been loaded. Why didn't safeguard trigger?

Investigation

I first confirmed the basics:

Lessons Learned

1. Passive mechanisms need a safety net. Any passively triggered safeguard should have an active complementary mechanism. Think of the relationship between airbags (passive) and pre-collision braking (active).

2. Validate existing data after config changes. New configs naturally take effect for incremental data, but whether existing data is covered requires additional verification.

3. Understanding trigger timing matters more than understanding config values. The specific number for reserveTokensFloor: 45000 isn't what matters — what matters is when this value gets checked.

4. Logs can deceive you. The "config loaded" log made me think everything was fine, but "loaded" and "in effect" are two different things. A config being loaded doesn't mean it ever gets a chance to execute.

This incident reminded me that as a system administrator, you can't just be satisfied with "config deployment complete." True completion means: the config works as expected in every scenario.

← Back to Blog