Skip to content

Commit b67dc65

Browse files
committed
docs(codex): document native compaction hooks
1 parent dbdf286 commit b67dc65

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

‎docs/concepts/compaction.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ the summary:
113113
/compact Focus on the API design decisions
114114
```
115115

116+
## Codex harness compaction
117+
118+
When an embedded agent session uses the Codex app-server harness, Codex owns the
119+
native thread and native compaction operation. OpenClaw keeps a transcript mirror
120+
for channel history and future harness switching, but the canonical compacted
121+
thread stays in Codex.
122+
123+
OpenClaw plugin hooks still expose `before_compaction` and `after_compaction`
124+
for the Codex harness from the app-server compaction item stream. Codex native
125+
`PreCompact` and `PostCompact` hooks, when supported by the installed Codex
126+
app-server, are separate Codex command hooks configured through Codex. They are
127+
useful for low-level Codex audit or policy, but they do not replace the
128+
OpenClaw plugin hook contract.
129+
116130
## Using a different model
117131

118132
By default, compaction uses your agent's primary model. You can use a more

‎docs/plugins/codex-harness.md‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,17 @@ thread unless Codex exposes that operation through app-server or native hook
530530
callbacks.
531531

532532
When newer Codex app-server builds expose native compaction and model lifecycle
533-
hook events, OpenClaw should version-gate that protocol support and map the
534-
events into the existing OpenClaw hook contract where the semantics are honest.
535-
Until then, OpenClaw's `before_compaction`, `after_compaction`, `llm_input`, and
536-
`llm_output` events are adapter-level observations, not byte-for-byte captures
537-
of Codex's internal request or compaction payloads.
533+
hook events, OpenClaw version-gates that protocol support and maps events into
534+
the existing OpenClaw hook contract where the semantics are honest. The
535+
OpenClaw `before_compaction`, `after_compaction`, `llm_input`, and `llm_output`
536+
events remain adapter-level observations, not byte-for-byte captures of Codex's
537+
internal request or compaction payloads.
538+
539+
Codex native `PreCompact` and `PostCompact` hooks are lower-level Codex command
540+
hooks. They run inside Codex around native thread compaction, using Codex hook
541+
configuration. OpenClaw's plugin hooks do not require a user or project
542+
`hooks.json`, and OpenClaw does not double-fire `before_compaction` or
543+
`after_compaction` just because native Codex compaction hooks are available.
538544

539545
## Tools, media, and compaction
540546

@@ -558,6 +564,12 @@ records native compaction start and completion signals. It does not yet expose a
558564
human-readable compaction summary or an auditable list of which entries Codex
559565
kept after compaction.
560566

567+
On Codex app-server builds with native compaction hook support, Codex can also
568+
run its own `PreCompact` and `PostCompact` command hooks around that native
569+
operation. Those hooks are useful for Codex-owned audit and policy. OpenClaw
570+
still treats the app-server compaction item stream as the source for OpenClaw
571+
plugin `before_compaction` and `after_compaction` events.
572+
561573
Because Codex owns the canonical native thread, `tool_result_persist` does not
562574
currently rewrite Codex-native tool result records. It only applies when
563575
OpenClaw is writing an OpenClaw-owned session transcript tool result.

0 commit comments

Comments
 (0)