Repository navigation
improve(codex): safely reuse live app-server threads - #115089
Conversation
7f086ff to
ba6cb76
Compare
|
Codex review: found issues before merge. Reviewed July 28, 2026, 4:55 AM ET / 08:55 UTC. ClawSweeper reviewWhat this changesThe PR retains one compatible persistent Codex app-server thread per physical client so the next ordinary turn can reuse its live subscription instead of resuming it from storage. Merge readiness⛔ Blocked by patch quality or review findings - 7 items remain Keep this PR open: the warm-reuse optimization bypasses an upstream resume safety check because its new compatibility fingerprint omits the working directory and runtime workspace roots. A subsequent turn on the same physical client can therefore keep operating with the prior workspace identity instead of forcing the existing safe resume/reload path. Likely related people: steipete (high confidence, recent Codex lifecycle contributor). Priority: P1 Review scores
Verification
How this fits togetherThe Codex extension maps an OpenClaw session binding to a native Codex app-server thread. On each turn it decides whether to start, resume, or reuse that thread, and that choice controls the active workspace, tools, approvals, and sandbox context used by the native runtime. flowchart LR
A[OpenClaw session turn] --> B[Stored Codex thread binding]
B --> C[Lifecycle compatibility checks]
C --> D{Retained live thread matches?}
D -->|Yes| E[Reuse existing subscription]
D -->|No| F[Resume or start native thread]
F --> G[Upstream validates workspace and settings]
E --> H[Run Codex turn]
G --> H
Before merge
Findings
Agent review detailsSecurityNeeds attention: The warm-path identity omits upstream workspace fields, creating a concrete risk that a retained thread continues under the prior workspace boundary. PR surfaceSource +456, Tests +647. Total +1103 across 14 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Extend the warm-thread compatibility identity to include every upstream resume-visible workspace field, at minimum Do we have a high-confidence way to reproduce the issue? Yes, from source: retain a completed ordinary thread, then issue the next turn through the same physical client with a different Is this the best way to solve the issue? No: retaining a live thread is a reasonable optimization, but the current fingerprint is not the complete native resume identity. The safe implementation must include the upstream workspace mismatch inputs or deliberately fall back to resume whenever those values are not provably identical. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4d105ebdd0ec. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Related: #114907
What Problem This Solves
Fixes an issue where ordinary multi-turn Codex conversations unsubscribe and resume an already-loaded app-server thread after every successful turn, needlessly discarding live thread and response-session reuse. Fresh real-provider measurements also showed that isolated mock timings were insufficient evidence for a runtime speed claim.
Why This Change Was Made
Retain at most one successfully completed ordinary persistent Codex thread per physical app-server client and skip the next resume only when the persisted owner and the complete native resume identity match. Fingerprint requested and effective models/providers, authentication profile, approvals, sandbox, permissions, service tier, base/developer instructions, effective thread configuration, and canonical dynamic-tool schema. Consume thread ownership transactionally; explicitly release or retire an unsafe subscription on cancellation, binding conflicts, changed settings, or eviction. Keep incognito, context-engine, supervision, native-preserved, ring-zero, transient, and one-shot threads on their existing lifecycle.
The mismatch fallback follows upstream Codex itself:
codex-rs/app-server/src/request_processors/thread_processor.rsshuts down and removes a mismatched idle loaded thread after its last subscriber leaves before cold-resuming with the new settings. The warm implementation is isolated inextensions/codex/src/app-server/thread-lifecycle-warm.tsso the existing lifecycle remains below the repository line-limit gate.Includes the minimal same-PR fixture repairs needed to keep the actual current Codex baseline green: create canonical SQLite session entries using the real SDK contract, and freeze/restore the clock in the oversized image-timeout regression.
User Impact
Repeated ordinary Codex turns can reuse the live native conversation and its cached responses without crossing accounts, changing approval/sandbox policy, exposing secret-bearing configuration, or retaining transient sessions. Native
apply_patch, approvals, instruction follow-through, and source discovery remain operational. No new configuration, environment variable, persistent schema, or compatibility layer is introduced.Evidence
op), not mock AI: all five matched OpenClaw/Codex scenario pairs passed, including nativeapply_patch, approval follow-through, source/docs discovery, instruction follow-through, and a 20-turn conversation.