Summary
The cli-backend (provider=claude-cli) never triggers any form of context compaction — neither native (agents.defaults.compaction.reserveTokens) nor plugin-based (lossless-claw). Context grows unbounded past the model window with zero compactions.
Environment
- OpenClaw 2026.4.15
- Provider:
claude-cli (model: opus)
- Session:
agent:main:main
- Native compaction:
reserveTokens: 30000 (should trigger ~85% / 170k)
- lossless-claw: tested both enabled and disabled
What happens
- Messages arrive via
chat.send, cli-backend bootstraps workspace files, runs cli exec
- No compaction activity occurs between turns — no threshold evaluation, no compaction attempt, no skip/defer decisions logged
- Context reaches 200%+ of the model window with zero compactions
- This happens regardless of whether lossless-claw is enabled or disabled
Test results
Test 1: lossless-claw enabled
- LCM loads and announces config correctly
- No LCM activity between turns — plugin is completely silent after init
- Context reached 161% with 0 compactions
- Native compaction also did not fire (gateway defers to LCM as active context engine)
Test 2: lossless-claw disabled
- LCM disabled to rule out it blocking native compaction
- Deliberately loaded ~20 large files to push context to 201%
- Native compaction still did not fire — 0 compactions at 201%
- Confirms the issue is in the cli-backend, not LCM
Root cause
The cli-backend execution path does not emit the per-turn lifecycle events (token-usage telemetry, turn-complete signals) that the compaction pipeline hooks into. The backend shells out to the Claude Code CLI, which manages its own context internally and doesn't feed telemetry back through the gateway's plugin/compaction event system.
Evidence: gateway logs show only cli exec: provider=claude-cli model=opus promptChars=N with no subsequent compaction activity. Both native and plugin compaction systems are never evaluated — not "evaluated and deferred" but "never called."
Expected behavior
After each turn completes, the cli-backend should report token usage back to the gateway so the compaction pipeline can evaluate context utilization and trigger compaction when thresholds are exceeded.
Notes
proactiveThresholdCompactionMode tested in both inline and deferred modes — neither triggers
- Cache hit rate is 89%, but at 200%+ utilization headroom checks should fail
- The cli-backend likely needs to emit a turn-complete event with token counts after
cli exec returns, similar to what the native provider backends do
Summary
The
cli-backend(provider=claude-cli) never triggers any form of context compaction — neither native (agents.defaults.compaction.reserveTokens) nor plugin-based (lossless-claw). Context grows unbounded past the model window with zero compactions.Environment
claude-cli(model: opus)agent:main:mainreserveTokens: 30000(should trigger ~85% / 170k)What happens
chat.send, cli-backend bootstraps workspace files, runscli execTest results
Test 1: lossless-claw enabled
Test 2: lossless-claw disabled
Root cause
The
cli-backendexecution path does not emit the per-turn lifecycle events (token-usage telemetry, turn-complete signals) that the compaction pipeline hooks into. The backend shells out to the Claude Code CLI, which manages its own context internally and doesn't feed telemetry back through the gateway's plugin/compaction event system.Evidence: gateway logs show only
cli exec: provider=claude-cli model=opus promptChars=Nwith no subsequent compaction activity. Both native and plugin compaction systems are never evaluated — not "evaluated and deferred" but "never called."Expected behavior
After each turn completes, the cli-backend should report token usage back to the gateway so the compaction pipeline can evaluate context utilization and trigger compaction when thresholds are exceeded.
Notes
proactiveThresholdCompactionModetested in bothinlineanddeferredmodes — neither triggerscli execreturns, similar to what the native provider backends do