Repository navigation
fix(codex): stop post-tool summaries switching accounts and models - #136758
Conversation
Capture source-ready model/profile facts and preserve prepared host auth for private summary turns. Attribute final answers to the admitted native selection. When supervision owns native auth, retain the existing honest no-summary reply instead of selecting an outer account or model. Preserve ordinary host-auth and user-home sidecalls without replaying completed actions. Fixes #136724
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 2, 2026, 8:31 PM ET / September 3, 2026, 00:31 UTC. ClawSweeper reviewWhat this changesThe PR captures the completed Codex thread’s model, provider, and host-auth selection for private post-tool summaries, while supervised native sessions use the existing honest fallback instead of borrowing host credentials. Merge readiness⛔ Blocked before merge - 1 item remains Keep open. This maintainer-authored PR has a source-grounded repair for the linked Codex account/model-switching bug, and the central change is not present on current main; no blocking correctness finding was identified. Priority: P1 Review scores
Verification
How this fits togetherThe Codex plugin executes native tool turns and, when a turn finishes without visible assistant text, can request a bounded private final summary. The plugin passes its result to the embedded agent runner, which either delivers the attributed summary or records and sends the existing fallback reply. flowchart LR
A[Native Codex tool turn] --> B[Ready thread selection]
B --> C[Verified settled transcript]
C --> D{Authentication owner}
D -->|Host-authenticated| E[Private bounded summary]
D -->|Supervised native session| F[Honest fallback]
E --> G[Agent reply delivery]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +69, Tests +1290, Docs +28. Total +1387 across 18 files. View PR surface stats
Review metrics
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:
Technical reviewBest possible solution: Preserve the captured ready-thread selection and prepared host-auth route for ordinary finalization, while keeping supervised native-auth turns on the non-replaying fallback path. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main passes outer model/provider/profile fields into the private finalizer, while the reviewed fixture constructs divergent host and native selections around that exact path. This read-only review did not execute the fixture. Is this the best way to solve the issue? Yes. Capturing selection at the ready-thread owner and reusing the already prepared host-auth handoff removes the competing outer selection; retaining the core fallback is safer than inventing a supervised native credential transfer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b7fa0f52c6a9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready at 824c7ee. Accepting the recommended supervised fallback from the ClawSweeper ownership review. This is the intentional stock-Codex/OpenClaw-only auth boundary: a supervised native connection does not authorize selecting a different host account to obtain a summary. Ordinary host-auth and ordinary user-home sidecalls remain supported. No completed action is replayed and no finalizer tool capability is widened. Exact-head CI run 33699175608 is completed/success for that SHA, including the required openclaw/ci-gate. This completes the review's outstanding exact-head-check condition; no correctness or security finding remained. Local proof includes four real stock-Codex ownership cases (three demonstrated pre-fix failures plus the preserved user-home contrast), owner/core/sibling coverage, the successful private-QA build, and two real isolated-Gateway QA scenarios. The observed delivery was one fallback after one write and one copy in chat history. Exact local commands, fixture corrections/reruns, resumed check-plan results, and the sanitized QA verdict are recorded in the PR's Evidence section. Fresh independent Codex autoreview at P1 was scoped-clean with no accepted/actionable findings. The native fixture uses synthetic accounts/provider responses; no production account/state, live OAuth/OpenAI, native catalog admission, full native-to-Gateway flow, or external real-channel proof is claimed. Source delta is +69, tests/support +1290, docs +28; there are no new config, schema, dependency, or production-module surfaces. |
|
Merged via squash.
|
…136758) Capture source-ready model/profile facts and preserve prepared host auth for private summary turns. Attribute final answers to the admitted native selection. When supervision owns native auth, retain the existing honest no-summary reply instead of selecting an outer account or model. Preserve ordinary host-auth and user-home sidecalls without replaying completed actions. Fixes openclaw#136724
Closes #136724
What Problem This Solves
Fixes an issue where Codex users completed tool work but the post-tool summary switched to an outer account/model, or failed because those unrelated host settings were unavailable. A supervised native connection owns its authentication; a fresh private Codex home cannot inherit that account.
Why This Change Was Made
The settled-turn owner now records the ready thread's model/provider and resolved host profile selector alongside the existing bounded, verified transcript projection. Ordinary finalization reuses the canonical prepared-auth handoff, including the exact prepared API key or selected subscription profile, and retains its existing private-stdio isolation. The bounded turn inherits the model admitted by
thread/start; final assistant attribution comes from that response while the bounded result's catalog-ID contract remains unchanged for other callers.Genuine supervision instead publishes the existing frozen
source: "unavailable"marker with an explicit diagnostic reason. Keeping the finalizer callback present preserves the core's established honest fallback. No host account is selected, no native credentials are copied, no follow-up native inference is attempted, and completed actions are not replayed. Stock Codex has no generic attested zero-tool summary operation on that native connection; this change does not invent one.This is OpenClaw-only: no Codex changes or custom binary, dependency bump, configuration/environment surface, SQLite migration, sidebar changes, or terminal UI changes. The existing private-turn capability restrictions and bounded empty-answer retry remain unchanged.
User Impact
Ordinary host-authorized summaries continue to work, including preserve-native-model-only bindings and the documented ordinary
homeScope: "user"private-host-auth sidecall. Supervised turns that already return a final answer are unchanged. When a supervised tool-only turn needs a reply, users receive:The completed outcome, tool receipts, transcript prefix, and native binding remain intact. The distinction is documented in Codex runtime behavior and auth/environment isolation.
Evidence
Reproduction and ownership proof
The composed fixture uses the stock managed Codex 0.152.1 binary, disposable homes, two synthetic accounts, a loopback Responses server, real native command execution, and real transcript persistence. Against pre-fix
65e5b2e19c9db6460494682bacc4bee10db755fd, three cases failed and the ordinary user-home contrast passed. All four cases pass with the repair:The source command marker remains exactly one line. The model contrast uses two stock models in the same native multi-agent generation, without overriding catalog/model metadata. The native command fixture is POSIX-only; the owner-boundary tests are platform-independent.
Core tests separately exercise the actual finalization backend and SQLite persistence for an unavailable harness, proving one fallback payload/row, unchanged original evidence, and no original-attempt replay. API-key/subscription selection, normalized-away provider metadata, cancellation/write fencing, empty output, catalog aliases, media, hosted search, and isolated completion are covered by focused sibling tests.
User-visible delivery proof
Both existing QA scenarios passed against the built candidate using an isolated real Gateway, mock provider, and synthetic QA channel:
{ "providerMode": "mock-openai", "channelDriver": "qa-channel", "gateway": "isolated real child", "results": [ { "scenario": "settled-write-finalizer-exhaustion-fallback", "status": "pass", "providerRequests": 4, "writes": 1, "finalizationRequests": 2, "outboundFallbackReplies": 1 }, { "scenario": "gateway-settled-finalizer-exhaustion-fallback", "status": "pass", "providerRequests": 4, "finalizationRequests": 2, "fallbackRowsInChatHistory": 1 } ] }These QA scenarios cover the common fallback-delivery path after empty-finalizer exhaustion. The unavailable-native producer and thrown-unavailable core path are covered separately above. This is not live OAuth/OpenAI, native catalog admission, a full native-to-Gateway flow, or a real external-channel claim. No production account, Gateway, or state was used.
Dependency contract checked
Directly inspected
openai/codextagrust-v0.152.1, peeled commit5adb68a49933ae446bf11935662c83dba55a0804: thread start parameters and returned selection, turn model override semantics, model metadata overriding code-mode flags, and exec/wait registration. Ordinary inference still usestool_choice: "auto"; disabling environments is not a generic no-tools acknowledgement.Validation and scope
Focused coverage spans 358 tests across 13 files, including four stock-native cases and 22 core finalization tests. The last broad run had three stale sibling assertions expecting the removed per-turn model override; those were corrected and both sibling files passed 23/23 on rerun. The final real-backend fallback fixture also passed after replacing an unbound-method assertion with an explicitly owned replay spy.
The build passed with
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build. All steps selected bycheck:changedwere completed: its aggregate run reached core lint after the structural guards and all typechecks passed; the test-only lint issue was fixed, then the affected canonical type graph, core/plugin lint, and remaining storage/media/sidecar/import-cycle gates passed. There are 0 runtime import cycles. This records resumed validation, not a claim that one aggregate invocation exited green. Fresh independent Codex autoreview at P1 returned scoped-clean with no accepted/actionable findings.Local proof commands
OPENCLAW_STATE_DIR="$(mktemp -d)" node scripts/check-changed.mjsLOC: production 89 added / 20 removed (+69); tests/support 1,598 added / 308 removed (+1,290); docs 29 added / 1 removed (+28). No generated, lockfile, or dependency changes.
Production delta is +69 lines across four existing plugin modules; no new production module. The growth carries source-owned selection, reuses prepared auth, records unsupported native ownership, and fences final writes rather than retaining a borrowed native client or adding a second execution path. Test/test-support and documentation deltas are reported separately.
The nearby thread-cleanup fixture now waits for actual
turn/startreadiness and aborts/joins its attempt on failure instead of imposing a five-second cold-start assumption. No runtime timeout was enlarged.A cross-generation preserve-model fixture also exposed a separate pre-finalization rotation path. That finding was handed to the active native-ownership work; this PR does not change rotation or session-lock policy.