@@ -372,6 +372,35 @@ its own control markers and channel delivery.
372372For CLIs that emit Claude Code stream-json compatible JSONL, set
373373` jsonlDialect: "claude-stream-json" ` on that backend's config.
374374
375+ ## Native compaction ownership
376+
377+ Some CLI backends run an agent that compacts its ** own** transcript, so OpenClaw must
378+ not run its safeguard summarizer against them - doing so fights the backend's own
379+ compaction and can hard-fail the turn. ** Codex** (its app-server owns automatic
380+ compaction) and ** Claude Code** (` claude-cli ` ) both work this way, and both ** opt out
381+ of OpenClaw compaction** :
382+
383+ - ** Codex** routes to its native-harness compaction endpoint (matched by the session's
384+ ` agentHarnessId ` ).
385+ - ** ` claude-cli ` ** has no harness endpoint - Claude Code compacts internally - so it
386+ declares ` ownsNativeCompaction: true ` , and OpenClaw returns a no-op from the
387+ compaction path.
388+
389+ Either way OpenClaw ** defers and never compacts these sessions.** Because the backend
390+ owns compaction, the old stopgap of setting ` contextTokens: 1_000_000 ` purely to keep
391+ OpenClaw's safeguard from firing on a claude-cli session is ** no longer needed** - the
392+ opt-out replaces it.
393+
394+ ``` typescript
395+ api .registerCliBackend ({ id: " my-cli" , ownsNativeCompaction: true /* ... */ });
396+ ```
397+
398+ Only declare ` ownsNativeCompaction ` for a backend that genuinely owns its compaction: it
399+ must reliably bound its own transcript as it nears its context window and persist a
400+ resumable session (e.g. ` --resume ` / ` --session-id ` ); otherwise a deferred session can
401+ stay over budget. (A session whose ` agentHarnessId ` matches the provider still routes to
402+ the harness endpoint - the no-op applies only when there is no harness endpoint.)
403+
375404## Bundle MCP overlays
376405
377406CLI backends do ** not** receive OpenClaw tool calls directly, but a backend can
0 commit comments