Repository navigation
Conversation
Signed-off-by: Ho Lim <[email protected]>
Signed-off-by: Ho Lim <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed July 26, 2026, 7:32 PM ET / 23:32 UTC. ClawSweeper reviewWhat this changesRoutes Codex budget-triggered CLI compaction to the authenticated app-server request, resumes the persisted thread for post-run compaction, and adds lifecycle coverage that prevents API-key-backed context-engine fallback. Merge readinessThe reported OAuth-only failure is concrete and this PR now includes credible after-fix runtime evidence, but a merge verdict needs a maintainer or reviewer who can inspect the exact current-main lifecycle and sibling Priority: P1 Review scores
Verification
How this fits togetherThe CLI compaction lifecycle runs after an agent turn when its context budget is exceeded. For a Codex OAuth session, the agent harness and bundled Codex extension must keep compaction on the authenticated app-server connection rather than handing it to OpenClaw’s direct OpenAI context engine. flowchart LR
A[Completed Codex agent turn] --> B[CLI budget check]
B --> C[Codex harness selection]
C --> D[Resume persisted app-server thread]
D --> E[Native Codex compaction]
E --> F[Terminal event and cleanup]
E --> G[Successful session state]
Decision needed
Why: Repository policy makes direct inspection of the sibling Codex source a hard gate for a Codex protocol verdict; the managed sandbox prevented that inspection in this review. Before merge
Agent review detailsSecurityNone. PR surfaceSource +80, Tests +118. Total +198 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain native Codex compaction for OAuth-only budget maintenance, with direct review of the Codex app-server protocol and focused confirmation that non-Codex harnesses still use the existing timeout and fallback behavior. Do we have a high-confidence way to reproduce the issue? Yes in the supplied evidence: an OAuth-only Codex session with a small context budget reaches the native budget-compaction path without API-key fallback. This review could not independently rerun or source-trace that path because the managed sandbox rejected read-only commands before execution. Is this the best way to solve the issue? Unclear pending direct Codex protocol inspection. Routing the Codex-owned budget path to its authenticated app-server is the narrower solution than treating a missing API key as a benign fallback, but the exact resume-and-cleanup sequence needs contract confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c66ca2fbb2b0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Signed-off-by: Ho Lim <[email protected]>
|
Thanks @HOYALIM for the deep investigation — the failure chain you documented in #114155 is real and confirmed on current Closing the PR because the ownership rework points the fix the other way: after #115284/#115514, the contract is "Codex owns native-thread token pressure; OpenClaw owns the host transcript byte fuse" — and codex-rs genuinely runs inline auto-compaction during turns ( |
Closes #114155
What Problem This Solves
Budget-triggered compaction for Codex OAuth sessions called the ordinary native harness hook. Codex correctly reported that its app-server owns automatic compaction, but the CLI lifecycle then fell back to API-key-backed context-engine compaction. OAuth-only sessions could therefore fail with
No API key found for provider "openai"after a successful turn.Why This Change Was Made
Codex already exposes a private native compaction request that permits non-manual
thread/compact/starton the authenticated app-server connection. The CLI budget path now selects that existing request only when the pinned harness is Codex. Post-run compaction resumes the persisted thread on the newly leased app-server client before starting compaction, then unsubscribes after terminal completion.This restores the native OAuth compaction contract established by #95831 without adding configuration or changing public APIs. Codex retains its terminal-event watchdog and transcript ownership until native compaction settles; other harnesses retain the existing outer timeout and fallback behavior.
User Impact
Codex OAuth-only sessions can perform budget maintenance without requiring a separate OpenAI API key or turning a completed response into a failed run. The lifecycle removes the direct context-engine fallback for Codex-owned automatic compaction.
Evidence
Current-head real behavior proof used GitHub CI's
dist-runtime-buildartifact for merge commit11f1bf65369dee35bde860f2932e1f271bf6a8a9, whose parents are currentmain(c66ca2fbb2b038f4796abfa76bd52dcc3b675b02) and branch head850c9fa7b09216222b444f1d4aa104118e124e35.A real loopback Gateway ran one Codex session with a deliberately small 4,000-token context budget and a dense prompt.
OPENAI_API_KEYandOPENAI_BASE_URLwere both unset; runtime logs confirmed external CLI OAuth bootstrap.Redacted observed result:
The completed answer remained successful while the persisted Codex thread was resumed and compacted natively after one-shot app-server cleanup.
Validation
node_modules/.bin/vitest run src/agents/command/cli-compaction.test.ts extensions/codex/src/app-server/compact.test.ts --maxWorkers=2-> 3 loaded files, 85 tests passed.0 -> 1, context-engine compaction and maintenance calls1 -> 0.oxfmt,oxlint, andgit diff --check-> passed.codex review --base upstream/main-> no actionable findings; independently confirmedthread/resume -> thread/compact/start -> thread/unsubscribeagainst the Codex protocol.AI-assisted: yes. I traced the CLI budget lifecycle, reproduced the OAuth-only product path, found the one-shot app-server lifecycle gap, added focused lifecycle and stale-binding tests, and reviewed the final diff.
Signed-off-by: Ho Lim [email protected]