Skip to content

Commit 4bc13ab

Browse files
authored
Merge c99a46c into 545ad7f
2 parents 545ad7f + c99a46c commit 4bc13ab

30 files changed

Lines changed: 4119 additions & 172 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
53b7621e99d75b98ecc8f4389d38900f84cf213f95dbcc877f36125d763c660d config-baseline.json
2-
e92bbf45714e418383118098d4ff15d347fa8ffc7e7837b437b522d2b59ce9fe config-baseline.core.json
1+
1bc41871069122543c0820a6beebcc085003750a7fffce27494573712b905d96 config-baseline.json
2+
35e51bc55d3169981d09b6a660e385e6048fceecd6786ff058dcf497430a9681 config-baseline.core.json
33
b901fb766edfd9df630690281476fc4032c64772f69d1d8f7b2e0e913a90f229 config-baseline.channel.json
44
5c214ab364011fd95735755f9fa4298aa4de8ad81144ae8dd08d969bb7ba318b config-baseline.plugin.json

docs/gateway/config-agents.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ Periodic heartbeat runs.
658658
model: "openrouter/anthropic/claude-sonnet-4-6", // optional compaction-only model override
659659
truncateAfterCompaction: true, // rotate to a smaller successor JSONL after compaction
660660
maxActiveTranscriptBytes: "20mb", // optional preflight local compaction trigger
661+
maxActiveTranscriptTokens: "120k", // optional Codex native thread token reuse guard
661662
notifyUser: true, // send brief notices when compaction starts and completes (default: false)
662663
memoryFlush: {
663664
enabled: true,
@@ -683,6 +684,7 @@ Periodic heartbeat runs.
683684
- `postCompactionSections`: optional AGENTS.md H2/H3 section names to re-inject after compaction. Reinjection is disabled when unset or set to `[]`. Explicitly setting `["Session Startup", "Red Lines"]` enables that pair and preserves the legacy `Every Session`/`Safety` fallback. Enable this only when the extra context is worth the risk of duplicating project guidance already captured in the compaction summary.
684685
- `model`: optional `provider/model-id` override for compaction summarization only. Use this when the main session should keep one model but compaction summaries should run on another; when unset, compaction uses the session's primary model.
685686
- `maxActiveTranscriptBytes`: optional byte threshold (`number` or strings like `"20mb"`) that triggers normal local compaction before a run when the active JSONL grows past the threshold. Requires `truncateAfterCompaction` so successful compaction can rotate to a smaller successor transcript. Disabled when unset or `0`.
687+
- `maxActiveTranscriptTokens`: optional Codex app-server native-thread token reuse guard (`number` or strings like `"120k"`). When unset, OpenClaw uses Codex's reported model context window with a 300000-token fallback recovery fuse. Set a positive value to override that fuse, or `0` to disable only this token guard while preserving byte limits and semantic binding invalidation.
686688
- `notifyUser`: when `true`, sends brief notices to the user when compaction starts and when it completes (for example, "Compacting context..." and "Compaction complete"). Disabled by default to keep compaction silent.
687689
- `memoryFlush`: silent agentic turn before auto-compaction to store durable memories. Set `model` to an exact provider/model such as `ollama/qwen3:8b` when this housekeeping turn should stay on a local model; the override does not inherit the active session fallback chain. Skipped when workspace is read-only.
688690

docs/plugins/codex-harness-reference.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,26 @@ injected; heartbeat turns get a collaboration-mode pointer to read the file when
423423
it exists and is non-empty. `BOOTSTRAP.md` and `MEMORY.md` when present are
424424
forwarded as OpenClaw turn input reference context.
425425

426+
These bootstrap bytes are not the same thing as the native reuse guard. The
427+
active-token guard is a warm-thread reuse threshold over the persisted/native
428+
Codex transcript and mirrored session totals; it is not simply "bootstrap size".
429+
When unset, OpenClaw uses Codex's reported model context window with a
430+
300000-token fallback recovery fuse. Operators can set `maxActiveTranscriptTokens`
431+
to a lower threshold when legacy native threads should rotate earlier.
432+
433+
The token-efficient context-engine path is `thread_bootstrap`. When the saved
434+
Codex binding still matches the active context-engine id, policy fingerprint,
435+
projection epoch/fingerprint, and dynamic-tool surface, OpenClaw treats the
436+
large bootstrap/projection payload as already present in the native thread and
437+
logs `thread-bootstrap-semantic-reuse` instead of reprojecting it every turn.
438+
Successful context-engine-owned compaction preserves that binding when the
439+
projection mode remains `thread_bootstrap`: same-file compaction leaves it in
440+
place, and successor-transcript rollover copies it to the successor before
441+
clearing the archived original. If those identities change, OpenClaw starts a
442+
fresh Codex thread and reprojects context once for the new epoch. This keeps
443+
long-running agents fast without pretending a stale bootstrap or stale
444+
context-engine projection is still valid.
445+
426446
## Environment overrides
427447

428448
Environment overrides remain available for local testing:

docs/plugins/codex-harness-runtime.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ OpenClaw returns after starting that native operation. It does not wait for
218218
completion, impose a separate OpenClaw timeout, restart the shared Codex
219219
app-server, or record the operation as an OpenClaw-completed compaction.
220220

221+
If context-engine overflow recovery rotates a transcript before a turn starts,
222+
OpenClaw preserves compatible `thread_bootstrap` bindings when their semantic
223+
identity still matches the projected context. Legacy, ownerless, and
224+
non-bootstrap bindings are abandoned so the next turn can rehydrate a fresh
225+
thread from engine-managed context.
226+
221227
When a context engine requests Codex thread-bootstrap projection, OpenClaw
222228
projects tool-call names and ids, input shapes, and redacted tool-result content
223229
into the fresh Codex thread. It does not copy raw tool-call argument values into
@@ -233,6 +239,59 @@ Because Codex owns the canonical native thread, `tool_result_persist` does not
233239
currently rewrite Codex-native tool result records. It only applies when
234240
OpenClaw is writing an OpenClaw-owned session transcript tool result.
235241

242+
## Troubleshooting token pressure
243+
244+
Codex harness latency can come from three different pressure points. They look
245+
similar in logs, but they have different fixes.
246+
247+
| Pressure point | Owner | What it means |
248+
| --------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
249+
| Model or app-server context limit | Codex app-server | Codex accepted a native thread or turn and then rejected, compacted, or failed because the real model request could not fit. |
250+
| OpenClaw assembly precheck | OpenClaw | OpenClaw's rendered turn prompt, developer instructions, context-engine projection, media, and reserves are too large before the turn is submitted to app-server. |
251+
| Native-thread reuse rotation | OpenClaw + Codex | OpenClaw has a saved Codex thread binding, but the persisted/native transcript is over the configured warm-thread reuse guard or the binding identity no longer matches. |
252+
253+
The native-thread reuse guard is not the model context window. When unset,
254+
OpenClaw uses Codex's reported model context window, with a 300000-token
255+
fallback recovery fuse when Codex has not reported one. It is a proactive
256+
threshold for deciding whether an existing native Codex thread is still a good
257+
warm resume candidate. Setting `maxActiveTranscriptTokens` to `120k` preserves
258+
an 86000 token native rollout on models with smaller reported windows, while
259+
setting it to `50k` rotates a 60000 token binding. Setting the token guard to
260+
`0` disables only proactive token rotation; byte guards and semantic binding
261+
checks can still rotate.
262+
263+
For context-engine `thread_bootstrap`, the efficient path is a matching
264+
context-engine id, policy fingerprint, projection epoch, projection
265+
fingerprint, and dynamic-tool surface. In that case OpenClaw logs
266+
`thread-bootstrap-semantic-reuse` and skips the proactive token and byte guards,
267+
because the large projection was already bootstrapped into that Codex thread.
268+
Successful context-engine-owned compaction preserves that binding when the
269+
projection remains `thread_bootstrap`. If compaction keeps the same session
270+
file, the binding stays in place. If compaction rolls over to a successor
271+
session file, OpenClaw copies the binding to the successor and clears the
272+
archived original so the next turn can resume the warm Codex thread. Legacy,
273+
ownerless, or non-bootstrap bindings are still invalidated by compaction.
274+
When any semantic identity changes, OpenClaw starts a fresh native thread and
275+
emits `codex.native_thread.lifecycle` with a rotation reason such as
276+
`projection-mismatch`, `context-engine-binding-mismatch`,
277+
`dynamic-tools-mismatch`, `mcp-config-mismatch`,
278+
`environment-selection-mismatch`, `native-tool-surface-disabled`,
279+
`plugin-app-config-mismatch`, `auth-profile-mismatch`, `missing-thread-binding`,
280+
`app-server-rejected-thread`, `native-token-guard`, or `native-byte-guard`.
281+
Compaction itself emits either `context-engine-compaction-preserved-binding` or
282+
`context-engine-compaction-invalidated-binding` so the outcome is visible even
283+
when no fresh thread is started immediately.
284+
285+
The trusted lifecycle diagnostic includes counts, hashed comparison
286+
fingerprints, and basename session-file labels for rollover, but not raw prompt
287+
text, bootstrap file contents, tool arguments, local absolute paths, or secrets.
288+
Its companion log entry is intentionally lower-cardinality and omits scoped
289+
thread/session ids and fingerprints. Use the trusted event to answer whether a
290+
slow Codex session is
291+
rebuilding context because the warm native thread exceeded a guard, because
292+
OpenClaw assembled too much prompt/context, or because Codex itself rejected the
293+
native thread or turn.
294+
236295
## Media and delivery
237296

238297
OpenClaw continues to own media delivery and media provider selection. Image,

0 commit comments

Comments
 (0)