Repository navigation
perf(codex): reuse unchanged inference request bytes - #155987
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 7:23 PM ET / 23:23 UTC (Revision 2). ClawSweeper reviewWhat this changesThe Codex inference relay preserves unchanged request bytes and HTTP compression, with transport regression coverage and updated documentation. Merge readiness✅ Ready for maintainer review The optimization remains useful: current main still reserializes unchanged requests. The focused patch preserves validation and instruction injection, and no actionable correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s private Codex relay receives native model requests, validates their context, and adds parent-only instructions when needed. It forwards those requests to the provider over HTTP or WebSockets. flowchart TD
A[Native Codex request] --> B[Private inference relay]
B --> C[Validate request and context]
C --> D{Instructions need injection?}
D -->|Yes| E[Inject and encode]
D -->|No| F[Reuse valid original bytes]
E --> G[Revalidate and forward to provider]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +9, Tests +88, Docs +4. Total +101 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep context preparation as the sole instruction owner and reuse native bytes whenever it leaves the request unchanged. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: this is a performance optimization. Current-main source confirms the redundant serialization and recompression; supplied measurements exercise that cost. Is this the best way to solve the issue? Yes. Reusing the existing context owner’s unchanged-object result avoids duplicate policy and preserves the established injection and validation paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 370e17484d58. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit '7d7f977ccfc1ac177526232e4f4960febd010015': (91 commits) test: avoid unused target setup in package profile fixtures (#155972) fix(worktrees): batch snapshot metadata reads test(plugin-state): distinguish borrowed and foreign lifecycle owners refactor(agents): share external harness session and attempt machinery (#152181) chore(i18n): refresh native locales (#156006) chore(test): retain Doctor fixture settlement diagnostics (#155944) perf(codex): reuse unchanged inference request bytes (#155987) perf(test): prepare snapshot ownership subprocess imports (#155973) perf(test): consolidate channel registry coverage (#155014) fix(runtime): preserve Node worker dependencies and cleanup diagnostics (#155292) perf(test): prepare worktree GC child runtime (#155928) fix(ui): open browser cards after delayed panel renders (#153253) fix(update): retain the running updater by hard link instead of copying the package (#155977) feat(decisions): add explicit evaluation and Labs opt-in foundation (#155134) fix(state): preserve lifecycle custody across worker dispatch improve: reuse shared tooling fixtures and defer legacy updater proof (#155731) improve(ui): reduce real-Gateway test preparation (#155979) perf(state): move session RPC SQL off the Gateway main thread (#155740) docs(freebsd): explain native Codex runtime limits (#155980) fix(qa): count Code Mode nested tool activity as transcript tool evidence (#155976) ...
What Problem This Solves
Large native Codex requests were serialized again by the inference relay even when no parent-local instructions changed, and zstd HTTP bodies were recompressed unnecessarily.
User Impact
Unchanged requests use less allocation and CPU in the relay. Parent-local instruction injection, request validation, current-generation checks, the 32 MiB body limit, admission, backpressure, and transport ownership remain intact. No configuration or migration is required.
Why This Change Was Made
The context owner already returns the original parsed object when no injection is needed. The relay now uses that decision to retain valid native UTF-8 bytes and, for unchanged HTTP requests, the original compressed wire body. Malformed UTF-8 retains the previous decode-and-serialize replacement behavior. Injected requests still take the existing encoding path.
Native source inspection verified typed Responses request encoding and typed tool schemas before raw JSON wrapping. Byte preservation keeps native number and escape representations intact instead of normalizing them through JavaScript.
Evidence
pnpm test <file> --maxWorkers=1: HTTP file 7 tests, 75.56 s wall including cold worker compilation (~0.6 s test bodies); proxy file 19 tests, 6.07 s wall (~0.5 s test bodies). Exact-run CI grouped Codex selection: 81.27 s Vitest duration; 203 s for the fullchecks-node-changed-extensions-config-1job, including setup and other selected files. These are grouped timings, not per-file timings.gpt-5.5and returned exactRELAY_OK(7.974 s). The broad live invocation was interrupted after that completed case; a second injected-context provider case did not complete. This is acceptance evidence, not provider performance evidence.node:bufferUTF-8 path, zstd forwarding, capacity and backpressured cancellation.