Skip to content

fix(codex): carry selected models into prompt hooks - #140488

Merged
steipete merged 1 commit into
mainfrom
codex/130706-codex-hook-model-facts-20260906
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/130706-codex-hook-model-facts-20260906

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130706

What Problem This Solves

Codex prompt hooks on turns controlled by OpenClaw did not receive the selected provider/model. Plugins such as active-memory could therefore use the agent default instead of the model selected for the current turn.

Why This Change Was Made

Supply the logical selected model through the existing hook context. Keep model fields absent when supervision or a preserved native binding owns selection: the hook runs before native startup confirms those facts. Private transport overrides remain separate.

User Impact

Supporting plugins can inherit the selected model on host-controlled Codex turns. Native-owned sessions retain their existing unknown-model behavior before startup. No configuration, protocol or persistence surface changes.

Evidence

  • Managed cases failed before repair; a native-owner control caught an incomplete draft. Nine affected cases and 21 shared-hook tests pass, including fresh/resumed private transport and both native ownership modes.
  • Independent P2 review: zero findings across two passes. The full changed-code gate and all 103 exact-head CI checks are terminal without failures.
  • Live source execution with Codex 0.153.4 completed fresh and resumed authenticated turns on the same native thread. Both actual prompt callbacks and active-memory's real selector chose openai/gpt-5.5 over configured openai/gpt-5.4, and both native turns returned the injected marker. Requested/effective/response model facts agreed; no successful tool calls or reroute occurred.
  • Production +6/-0; tests +41/-2. The six lines carry two existing facts while preserving both native ownership exclusions.

The full live driver remains failed on two one-shot client cleanup could not be confirmed warnings. The ten cleanup/transport/launcher files are unchanged across base, PR and main. An independent auth-free initialize/close probe, with no model turn or hook, reproduced { exited: true, cleanup: "uncertain" }; all five recorded process identities were gone afterward. The live-test inventory found no matching survivors; three unreadable environment records were separately identified as host control-plane processes. All fixture roots were removed and the isolated Testbox was stopped and independently verified completed. Raw failed receipts remain unchanged.

Follow-up: native Codex one-shot cleanup confidence after official launcher shutdown. Exact signal attribution remains unproven. This PR's changed hook behavior is live-verified; warning-free shutdown, a packaged Gateway build, full active-memory recall-subagent inference, and native-owned supervision live flows are not claimed.

Include the logical provider and model for host-selected turns. Keep both supervised and independently native-owned models absent before startup confirms them, without exposing private transport overrides.

Related: #130706. Nine affected cases and 21 shared-hook tests passed, with failing-before controls and actual callback-to-recall-selector proof using synthetic native clients. Independent P2 review and the full changed gate passed.
@steipete steipete self-assigned this Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 6:31 PM ET / 22:31 UTC.

ClawSweeper review

What this changes

Pass the selected provider and logical model to Codex plugin hooks for OpenClaw-controlled turns, preserving unknown-model behavior for native-owned sessions and extending regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: current main and the latest release omit the selected model from Codex prompt-hook context. No introduced correctness or security defect was found, and the protected maintainer-authored PR should remain open.

Priority: P2
Reviewed head: 7ff7fcd1e5720698bba436bac371684636067ad7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused producer-level repair with meaningful ownership regression coverage and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository-state snapshot identifies a MEMBER author, so the ordinary contributor gate is exempt. Reported proof exercises Codex prompt callbacks and the Active Memory selector with synthetic native clients; it does not establish live inference, and no material authority change requires additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-state snapshot identifies a MEMBER author, so the ordinary contributor gate is exempt. Reported proof exercises Codex prompt callbacks and the Active Memory selector with synthetic native clients; it does not establish live inference, and no material authority change requires additional proof.
Evidence reviewed 8 items Introduced production change: The pinned introduction delta adds model facts only when neither supervision nor a preserved native-model binding owns selection. It reads the logical turn parameters rather than the private runtime override.
Current main and release still need the repair: Inspected this file with git show at fetched main e2a9f6e and release v2026.9.2. Both construct hook context without modelProviderId or modelId; no merged replacement is established by the supplied context.
Existing hook contract and consumer: PluginHookAgentContext already defines both optional model fields, and the embedded runner already populates them. Active Memory gives an explicit plugin model precedence, then the current hook model, then the configured agent default. This repairs missing producer facts without replacing user settings or introducing a parallel API.
Findings None None.
Security None None.

How this fits together

The Codex plugin prepares hook context before starting native inference. Plugins such as Active Memory use that context to choose a model for supporting work instead of falling back to the agent’s configured default.

flowchart TD
  A[Selected turn model] --> C[Codex hook context]
  B[Native session ownership] --> C
  C --> D{OpenClaw owns selection?}
  D -->|Yes| E[Include logical model]
  D -->|No| F[Leave model unknown]
  E --> G[Plugin model selection]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +6, Tests +39. Total +45 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 0 +6
Tests 1 41 2 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 47 2 +45

Review metrics

None.

Technical review

Best possible solution:

Keep model facts at the Codex hook-context producer, preserving explicit plugin overrides, logical model identity, and native selection ownership.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: select a host-controlled Codex model different from the agent default with no explicit Active Memory model override; current main omits the hook fields and the selector falls back to the default. This review did not execute that path.

Is this the best way to solve the issue?

Yes. Populating existing context fields at their producer is a narrow repair, and the exclusions preserve native ownership without exposing private transport model names.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e2a9f6eadb0c.

Labels

Label changes:

  • add P2: Missing model context can make supporting plugin work use the wrong configured model, with a bounded Codex hook impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository-state snapshot identifies a MEMBER author, so the ordinary contributor gate is exempt. Reported proof exercises Codex prompt callbacks and the Active Memory selector with synthetic native clients; it does not establish live inference, and no material authority change requires additional proof.

Label justifications:

  • P2: Missing model context can make supporting plugin work use the wrong configured model, with a bounded Codex hook impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository-state snapshot identifies a MEMBER author, so the ordinary contributor gate is exempt. Reported proof exercises Codex prompt callbacks and the Active Memory selector with synthetic native clients; it does not establish live inference, and no material authority change requires additional proof.

Evidence

What I checked:

  • Introduced production change: The pinned introduction delta adds model facts only when neither supervision nor a preserved native-model binding owns selection. It reads the logical turn parameters rather than the private runtime override. (extensions/codex/src/app-server/run-attempt-context.ts:110, 7ff7fcd1e572)
  • Current main and release still need the repair: Inspected this file with git show at fetched main e2a9f6e and release v2026.9.2. Both construct hook context without modelProviderId or modelId; no merged replacement is established by the supplied context. (extensions/codex/src/app-server/run-attempt-context.ts:104, e2a9f6eadb0c)
  • Existing hook contract and consumer: PluginHookAgentContext already defines both optional model fields, and the embedded runner already populates them. Active Memory gives an explicit plugin model precedence, then the current hook model, then the configured agent default. This repairs missing producer facts without replacing user settings or introducing a parallel API. (extensions/active-memory/query.ts:305, 7ff7fcd1e572)
  • Native dependency signal and execution order: runCodexAppServerAttempt prepares context and prompt before native runtime startup. The PR explicitly preserves unknown model facts until Codex confirms native selection; docs/plugins/codex-harness.md likewise assigns supervised model selection to native configuration. These claims make the Codex contract inspection applicable. (extensions/codex/src/app-server/run-attempt.ts:40, 7ff7fcd1e572)
  • Authoritative native model response: Personally inspected the sibling dependency at this SHA. Its resume processor returns model and provider from session_configured; the protocol declares those response fields and treats request model fields as overrides. Repository ownership was verified through the checkout’s cache remote, whose origin is https://github.com/openai/codex.git. (codex-rs/app-server/src/request_processors/thread_processor.rs:4006, 3d2ee51ca2d5)
  • Regression coverage and proof limits: Read the changed tests covering managed prompt callbacks, fresh/resumed private transport overrides, preserved native selection, and supervision. The captured PR body reports failing-before controls, nine affected cases, 21 shared-hook tests, and callback-to-selector checks using synthetic clients; it expressly disclaims authenticated inference and a complete provider round trip. No tests were executed during this read-only review. (extensions/codex/src/app-server/run-attempt.test.ts:3437, 7ff7fcd1e572)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ashawwal: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 3cfcf83 into main Sep 6, 2026
109 checks passed
@steipete
steipete deleted the codex/130706-codex-hook-model-facts-20260906 branch September 6, 2026 23:37
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Include the logical provider and model for host-selected turns. Keep both supervised and independently native-owned models absent before startup confirms them, without exposing private transport overrides.

Related: openclaw#130706. Nine affected cases and 21 shared-hook tests passed, with failing-before controls and actual callback-to-recall-selector proof using synthetic native clients. Independent P2 review and the full changed gate passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant