Skip to content

Commit 80ca484

Browse files
authored
feat(codex): bind context-engine projections to codex threads (#82351)
* feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
1 parent 90ae151 commit 80ca484

15 files changed

Lines changed: 1296 additions & 184 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Docs: https://docs.openclaw.ai
1212
- CLI/onboarding: localize the setup wizard and bundled channel setup flows for English, Simplified Chinese, and Traditional Chinese. (#80645) Thanks @GaosCode.
1313
- Agents/skills: cache hydrated `resolvedSkills` across warm gateway turns while keying reuse by the redacted effective config, reducing redundant skill snapshot rebuilds without crossing config-gated skill boundaries. (#81451) Thanks @solodmd.
1414
- Telegram/group chat: add opt-in `messages.groupChat.ambientTurns: "room_event"` handling so always-on ambient chatter can run as quiet room context and speak visibly only via the message tool. (#81317) Thanks @obviyus.
15+
- Codex/context engines: bind thread-bootstrap projection epochs to Codex app-server threads, carry redacted tool-result context into fresh threads, and rotate backend threads when projection state changes. (#82351) Thanks @jalehman.
1516

1617
### Fixes
1718

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
eed14a427f34d1531d63e5f1065ef2325b46f77e5a16ce809e5e845cd6700769 plugin-sdk-api-baseline.json
2-
d8d090e4858f8d619b2151d69b8dc992132bc8930e04b990e4a69a433fb19d41 plugin-sdk-api-baseline.jsonl
1+
ae6b95dffe88496aadee03e49b6b6db2db74d4bbd9b984be94a39d81df449f93 plugin-sdk-api-baseline.json
2+
08da4f6d26afff58fc1accb2f1b12c2d0ef740a0abf60cbdef43a32f422a4382 plugin-sdk-api-baseline.jsonl

docs/plugins/architecture-internals.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,16 @@ export default function (api) {
10571057
The factory `ctx` exposes optional `config`, `agentDir`, and `workspaceDir`
10581058
values for construction-time initialization.
10591059

1060+
`assemble()` may return `contextProjection` when the active harness has a
1061+
persistent backend thread. Omit it for legacy per-turn projection. Return
1062+
`{ mode: "thread_bootstrap", epoch }` when the assembled context should be
1063+
injected once into a backend thread and reused until the epoch changes. Change
1064+
the epoch after the engine's semantic context changes, such as after an
1065+
engine-owned compaction pass. Hosts may preserve tool-call metadata, input
1066+
shape, and redacted tool results in a thread-bootstrap projection so fresh
1067+
backend threads retain tool continuity without copying raw secret-bearing
1068+
payloads.
1069+
10601070
If your engine does **not** own the compaction algorithm, keep `compact()`
10611071
implemented and delegate it explicitly:
10621072

docs/plugins/codex-harness-runtime.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ diagnostic surfaces around that boundary.
2020
OpenClaw still owns channel routing, session files, visible message delivery,
2121
OpenClaw dynamic tools, approvals, media delivery, and a transcript mirror.
2222
Codex owns the canonical native thread, native model loop, native tool
23-
continuation, and native compaction.
23+
continuation, and native compaction unless the active OpenClaw context engine
24+
declares that it owns compaction.
2425

2526
## Thread bindings and model changes
2627

@@ -184,8 +185,17 @@ diagnostics bundle.
184185
## Compaction and transcript mirror
185186

186187
When the selected model uses the Codex harness, native thread compaction is
187-
delegated to Codex app-server. OpenClaw keeps a transcript mirror for channel
188-
history, search, `/new`, `/reset`, and future model or harness switching.
188+
delegated to Codex app-server unless an active context engine declares
189+
`ownsCompaction: true`. Owning context engines compact first and cause OpenClaw
190+
to abandon the old Codex backend thread so the next turn can rehydrate a fresh
191+
thread from engine-managed context. OpenClaw keeps a transcript mirror for
192+
channel history, search, `/new`, `/reset`, and future model or harness
193+
switching.
194+
195+
When a context engine requests Codex thread-bootstrap projection, OpenClaw
196+
projects tool-call names and ids, input shapes, and redacted tool-result content
197+
into the fresh Codex thread. It does not copy raw tool-call argument values into
198+
that projection.
189199

190200
The mirror includes the user prompt, final assistant text, and lightweight Codex
191201
reasoning or plan records when the app-server emits them. Today, OpenClaw only

docs/plugins/codex-harness.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ Use `openai/gpt-*` model refs for Codex-backed OpenAI agent turns. Prefer
119119
`openai-codex:*` auth profiles and `auth.order.openai-codex` remain valid, but
120120
do not write new `openai-codex/gpt-*` model refs.
121121

122-
Do not set `compaction.model` or `compaction.provider` on Codex-backed agents.
123-
Codex owns compaction through its native app-server thread state, so OpenClaw
122+
Do not set `compaction.model` or `compaction.provider` on Codex-backed agents
123+
unless a selected context engine owns compaction. Without an owning context
124+
engine, Codex compacts through its native app-server thread state, so OpenClaw
124125
ignores those local summarizer overrides at runtime and `openclaw doctor --fix`
125126
removes them when the agent uses Codex.
126127

@@ -131,6 +132,12 @@ Lossless remains supported as a context engine. Configure it through
131132
`compaction.provider: "lossless-claw"` shape to the Lossless context-engine slot
132133
when Codex is the active runtime.
133134

135+
When the active context engine reports `ownsCompaction: true`, `/compact` runs
136+
that engine's compaction lifecycle and invalidates the bound Codex app-server
137+
thread. The next Codex turn starts a fresh backend thread and rehydrates it from
138+
the context engine instead of layering Codex native compaction on top of the
139+
engine-owned semantic summary.
140+
134141
```json5
135142
{
136143
auth: {
@@ -625,8 +632,10 @@ The Codex harness changes the low-level embedded agent executor only.
625632
- Codex-native shell, patch, MCP, and native app tools are owned by Codex.
626633
OpenClaw can observe or block selected native events through the supported
627634
relay, but it does not rewrite native tool arguments.
628-
- Codex owns native compaction. OpenClaw keeps a transcript mirror for channel
629-
history, search, `/new`, `/reset`, and future model or harness switching.
635+
- Codex owns native compaction unless the active OpenClaw context engine
636+
declares `ownsCompaction: true`. OpenClaw keeps a transcript mirror for
637+
channel history, search, `/new`, `/reset`, and future model or harness
638+
switching.
630639
- Media generation, media understanding, TTS, approvals, and messaging-tool
631640
output continue through the matching OpenClaw provider/model settings.
632641
- `tool_result_persist` applies to OpenClaw-owned transcript tool results, not

0 commit comments

Comments
 (0)