mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
refactor(agents): trim native compaction ownership follow-up
This commit is contained in:
@@ -376,20 +376,16 @@ For CLIs that emit Claude Code stream-json compatible JSONL, set
|
||||
|
||||
Some CLI backends run an agent that compacts its **own** transcript, so OpenClaw must
|
||||
not run its safeguard summarizer against them - doing so fights the backend's own
|
||||
compaction and can hard-fail the turn. **Codex** (its app-server owns automatic
|
||||
compaction) and **Claude Code** (`claude-cli`) both work this way, and both **opt out
|
||||
of OpenClaw compaction**:
|
||||
compaction and can hard-fail the turn.
|
||||
|
||||
- **Codex** routes to its native-harness compaction endpoint (matched by the session's
|
||||
`agentHarnessId`).
|
||||
- **`claude-cli`** has no harness endpoint - Claude Code compacts internally - so it
|
||||
declares `ownsNativeCompaction: true`, and OpenClaw returns a no-op from the
|
||||
compaction path.
|
||||
`claude-cli` has no harness endpoint - Claude Code compacts internally - so it declares
|
||||
`ownsNativeCompaction: true`, and OpenClaw returns a no-op from the compaction path.
|
||||
Native-harness sessions such as Codex keep routing to their harness compaction endpoint
|
||||
instead.
|
||||
|
||||
Either way OpenClaw **defers and never compacts these sessions.** Because the backend
|
||||
owns compaction, the old stopgap of setting `contextTokens: 1_000_000` purely to keep
|
||||
OpenClaw's safeguard from firing on a claude-cli session is **no longer needed** - the
|
||||
opt-out replaces it.
|
||||
Because the backend owns compaction, the old stopgap of setting
|
||||
`contextTokens: 1_000_000` purely to keep OpenClaw's safeguard from firing on a
|
||||
claude-cli session is **no longer needed** - the opt-out replaces it.
|
||||
|
||||
```typescript
|
||||
api.registerCliBackend({ id: "my-cli", ownsNativeCompaction: true /* ... */ });
|
||||
@@ -398,8 +394,7 @@ api.registerCliBackend({ id: "my-cli", ownsNativeCompaction: true /* ... */ });
|
||||
Only declare `ownsNativeCompaction` for a backend that genuinely owns its compaction: it
|
||||
must reliably bound its own transcript as it nears its context window and persist a
|
||||
resumable session (e.g. `--resume` / `--session-id`); otherwise a deferred session can
|
||||
stay over budget. (A session whose `agentHarnessId` matches the provider still routes to
|
||||
the harness endpoint - the no-op applies only when there is no harness endpoint.)
|
||||
stay over budget. Matching `agentHarnessId` sessions still route to the harness endpoint.
|
||||
|
||||
## Bundle MCP overlays
|
||||
|
||||
|
||||
@@ -217,10 +217,9 @@ backend hook can express the behavior.
|
||||
|
||||
If your backend runs an agent that compacts its **own** transcript, set
|
||||
`ownsNativeCompaction: true` so OpenClaw's safeguard summarizer never runs against its
|
||||
sessions - the CLI compaction lifecycle returns a no-op and the turn proceeds. This is
|
||||
the **same opt-out Codex uses** (its app-server owns automatic compaction); `claude-cli`
|
||||
declares it because Claude Code compacts internally with no harness endpoint. It also
|
||||
removes any need to inflate `contextTokens` just to keep the safeguard from firing.
|
||||
sessions - the CLI compaction lifecycle returns a no-op and the turn proceeds. `claude-cli`
|
||||
declares it because Claude Code compacts internally with no harness endpoint. Native-harness
|
||||
sessions such as Codex keep routing to their harness compaction endpoint instead.
|
||||
|
||||
**Only declare it when all of the following hold**, or a deferred over-budget session can
|
||||
stay over budget / go stale (OpenClaw no longer rescues it):
|
||||
@@ -228,9 +227,8 @@ stay over budget / go stale (OpenClaw no longer rescues it):
|
||||
- the backend reliably compacts or bounds its own transcript as it nears its window;
|
||||
- it persists a resumable session so the compacted state survives turns
|
||||
(e.g. `--resume` / `--session-id`);
|
||||
- it is **not** a native-harness compaction session - a session whose `agentHarnessId`
|
||||
matches the provider routes to the harness endpoint instead; this no-op applies only
|
||||
when there is no harness endpoint.
|
||||
- it is not a native-harness compaction session - matching `agentHarnessId` sessions
|
||||
route to the harness endpoint instead.
|
||||
|
||||
## MCP tool bridge
|
||||
|
||||
|
||||
Reference in New Issue
Block a user