Repository navigation
fix(gateway): reject model selections without an activatable harness - #134837
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 1:32 AM ET / 05:32 UTC. ClawSweeper reviewWhat this changesThis PR rejects session model selections whose required embedded harness has no enabled plugin owner, preserving the previous model selection and sticky default. Merge readinessThe focused Gateway repair matches the linked model-picker defect and has no concrete patch defect in review. It remains open because it intentionally changes compatibility behavior and is a maintainer-authored, maintainer-labeled PR awaiting that decision and exact-head CI. Priority: P1 Review scores
Verification
How this fits togetherGateway session creation and patch requests resolve a requested model before persisting it for later agent turns. The new admission check consults plugin activation metadata so an unusable model is rejected before it becomes session state. flowchart LR
A[Control UI or client] --> B[Gateway session request]
B --> C[Resolve model selection]
C --> D{Required harness available?}
D -->|Yes| E[Persist session selection]
D -->|No| F[Return recovery guidance]
E --> G[Agent turn]
Decision needed
Why: The patch deliberately changes the observable failure point for existing sessions and sticky defaults. Before merge
Agent review detailsSecurityNone. PR surfaceSource +24, Tests +50, Docs +7. Total +81 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt the documented save-time rejection contract while retaining the existing prepared-run guard as defense in depth. Do we have a high-confidence way to reproduce the issue? Yes. The pre-change session projection persisted an allowed model without checking its harness owner, while the existing turn path rejects a missing prepared harness; the PR adds direct handler coverage for both creation and patching. Is this the best way to solve the issue? Yes, subject to the compatibility decision. The shared session projection is the producer that persists the unusable selection, and the repair reuses the existing activation planner without loading plugin runtime code. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6bfac98ca38e. LabelsLabel 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
HistoryReview history (1 earlier review cycle)
|
7b26e65 to
b34390d
Compare
|
Merged via squash.
|
Preserve the interrupted worker's seven pending files alongside 81fd1a7. This is an incomplete recovery checkpoint, not a land-ready change. Related: #134468 and #134304. Reported by @goslingmanagment. The session selection work is already merged separately in #134837. The recovery-only production delta remains +107, exceeding this sweep's net-zero constraint. Pending owner tests expose contextless disabled-policy and mixed-owner diagnostic gaps. Gateway selection coverage also exposed an enabled-to-disabled fixture race with background sticky config writes. Build, changed checks, and final branch review are not complete. Co-authored-by: Jason (Json) <[email protected]>
* fix(agents): show recovery when a model harness is unavailable Carry the prepared plugin generation's activation and owner facts to the final harness guard. Reuse the scoped registry owner for direct agents and provider usage, preserving loaded request plugins when adding a selection. Put recovery commands before longer details so the first bounded chat error retains the operator's next action. Fixes #134304. Reported by @goslingmanagment. Release-note context: unavailable model harnesses explain plugin recovery while model status continues to report route availability independently of Gateway liveness. Co-authored-by: Jason (Json) <[email protected]> * chore: preserve blocked harness recovery checkpoint Preserve the interrupted worker's seven pending files alongside 81fd1a7. This is an incomplete recovery checkpoint, not a land-ready change. Related: #134468 and #134304. Reported by @goslingmanagment. The session selection work is already merged separately in #134837. The recovery-only production delta remains +107, exceeding this sweep's net-zero constraint. Pending owner tests expose contextless disabled-policy and mixed-owner diagnostic gaps. Gateway selection coverage also exposed an enabled-to-disabled fixture race with background sticky config writes. Build, changed checks, and final branch review are not complete. Co-authored-by: Jason (Json) <[email protected]> * fix(agents): preserve exact harness recovery policy Diagnose unavailable harness owners from the prepared registry, preserve explicit policy for direct hosts, and classify mixed/default-enabled owners correctly. Reuse activation context and shared registry load options; keep borrowed Gateway registry dependencies lazy. Join sticky config mutations before Gateway fixture teardown. Co-authored-by: Json <[email protected]> * test(gateway): join sticky mutations with explicit cleanup Keep the original ordered activation assertions while awaiting every captured config mutation in a lint-safe try/finally. Co-authored-by: Json <[email protected]> * test: isolate provider hook proofs by execution mode The previous case bundled compilation and four fresh subprocesses under one deadline. Give source and compiled execution their own cases, compile only the compiled case, and retain both provider scopes, lifecycle assertions, and the existing timeout. Co-authored-by: Json <[email protected]> --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Json <[email protected]>
…penclaw#134837) * fix(gateway): reject model selections without an activatable harness * test(gateway): provide harness owner in sticky model fixture
…5118) * fix(agents): show recovery when a model harness is unavailable Carry the prepared plugin generation's activation and owner facts to the final harness guard. Reuse the scoped registry owner for direct agents and provider usage, preserving loaded request plugins when adding a selection. Put recovery commands before longer details so the first bounded chat error retains the operator's next action. Fixes openclaw#134304. Reported by @goslingmanagment. Release-note context: unavailable model harnesses explain plugin recovery while model status continues to report route availability independently of Gateway liveness. Co-authored-by: Jason (Json) <[email protected]> * chore: preserve blocked harness recovery checkpoint Preserve the interrupted worker's seven pending files alongside 81fd1a7. This is an incomplete recovery checkpoint, not a land-ready change. Related: openclaw#134468 and openclaw#134304. Reported by @goslingmanagment. The session selection work is already merged separately in openclaw#134837. The recovery-only production delta remains +107, exceeding this sweep's net-zero constraint. Pending owner tests expose contextless disabled-policy and mixed-owner diagnostic gaps. Gateway selection coverage also exposed an enabled-to-disabled fixture race with background sticky config writes. Build, changed checks, and final branch review are not complete. Co-authored-by: Jason (Json) <[email protected]> * fix(agents): preserve exact harness recovery policy Diagnose unavailable harness owners from the prepared registry, preserve explicit policy for direct hosts, and classify mixed/default-enabled owners correctly. Reuse activation context and shared registry load options; keep borrowed Gateway registry dependencies lazy. Join sticky config mutations before Gateway fixture teardown. Co-authored-by: Json <[email protected]> * test(gateway): join sticky mutations with explicit cleanup Keep the original ordered activation assertions while awaiting every captured config mutation in a lint-safe try/finally. Co-authored-by: Json <[email protected]> * test: isolate provider hook proofs by execution mode The previous case bundled compilation and four fresh subprocesses under one deadline. Give source and compiled execution their own cases, compile only the compiled case, and retain both provider scopes, lifecycle assertions, and the existing timeout. Co-authored-by: Json <[email protected]> --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Json <[email protected]>
… not enabled (#169412) ## What Problem This Solves Fixes: `/model openai/<model>` fails with `requires agent harness "codex", but no enabled plugin provides it` when the Codex plugin is not enabled, even though the same model already runs in that session. ## User Impact User impact: operators without the Codex plugin can switch back to an OpenAI model in the TUI, Control UI, and other session-patch clients. Turns already ran these models on the built-in OpenClaw runtime; only the selection check refused them. A model explicitly pinned to `agentRuntime: codex` is still rejected when no plugin provides Codex. ## Why This Change Was Made OpenAI routes prefer Codex implicitly. When that harness is unavailable, a turn falls back to OpenClaw (`implicit-unavailable` in `resolveAgentHarnessAvailabilityDecision`). The model-selection gate added in #134837 read the read-only projection instead, which keeps the bare `codex` id, so it rejected selections that would run fine. The gate now asks for the execution decision through `resolveEffectiveAgentRuntime({ mode: "execution" })`; thinking validation keeps the projection. ## Evidence - Real `openclaw chat` (local embedded, copied operator config with no Codex plugin enabled, real OpenAI and Claude CLI): gpt-6-astra turn → `/model` Claude → `/model openai/gpt-6-astra` printed `model set to openai/gpt-6-astra` and the next turn answered. The installed build failed this step with the error above. - New `src/gateway/sessions-patch.harness-selection.test.ts`: the implicit case fails on `main` and passes here; the explicit Codex pin case still rejects on both. Cost: `pnpm test src/gateway/sessions-patch.harness-selection.test.ts --maxWorkers=1` ≈ 20 s wall, tests ≈ 0.8 s. - `pnpm test src/gateway/sessions-patch.test.ts`: 127 passed. - `node scripts/check-changed.mjs`: all green (typecheck core + core tests) except the dead-export scan, which lists only unchanged `ui/` and `src/` exports already present on `main`. Co-authored-by: Ayaan Zaidi <[email protected]>
… not enabled (#169412) ## What Problem This Solves Fixes: `/model openai/<model>` fails with `requires agent harness "codex", but no enabled plugin provides it` when the Codex plugin is not enabled, even though the same model already runs in that session. ## User Impact User impact: operators without the Codex plugin can switch back to an OpenAI model in the TUI, Control UI, and other session-patch clients. Turns already ran these models on the built-in OpenClaw runtime; only the selection check refused them. A model explicitly pinned to `agentRuntime: codex` is still rejected when no plugin provides Codex. ## Why This Change Was Made OpenAI routes prefer Codex implicitly. When that harness is unavailable, a turn falls back to OpenClaw (`implicit-unavailable` in `resolveAgentHarnessAvailabilityDecision`). The model-selection gate added in #134837 read the read-only projection instead, which keeps the bare `codex` id, so it rejected selections that would run fine. The gate now asks for the execution decision through `resolveEffectiveAgentRuntime({ mode: "execution" })`; thinking validation keeps the projection. ## Evidence - Real `openclaw chat` (local embedded, copied operator config with no Codex plugin enabled, real OpenAI and Claude CLI): gpt-6-astra turn → `/model` Claude → `/model openai/gpt-6-astra` printed `model set to openai/gpt-6-astra` and the next turn answered. The installed build failed this step with the error above. - New `src/gateway/sessions-patch.harness-selection.test.ts`: the implicit case fails on `main` and passes here; the explicit Codex pin case still rejects on both. Cost: `pnpm test src/gateway/sessions-patch.harness-selection.test.ts --maxWorkers=1` ≈ 20 s wall, tests ≈ 0.8 s. - `pnpm test src/gateway/sessions-patch.test.ts`: 127 passed. - `node scripts/check-changed.mjs`: all green (typecheck core + core tests) except the dead-export scan, which lists only unchanged `ui/` and `src/` exports already present on `main`. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit f17ac94)
… not enabled (openclaw#169412) ## What Problem This Solves Fixes: `/model openai/<model>` fails with `requires agent harness "codex", but no enabled plugin provides it` when the Codex plugin is not enabled, even though the same model already runs in that session. ## User Impact User impact: operators without the Codex plugin can switch back to an OpenAI model in the TUI, Control UI, and other session-patch clients. Turns already ran these models on the built-in OpenClaw runtime; only the selection check refused them. A model explicitly pinned to `agentRuntime: codex` is still rejected when no plugin provides Codex. ## Why This Change Was Made OpenAI routes prefer Codex implicitly. When that harness is unavailable, a turn falls back to OpenClaw (`implicit-unavailable` in `resolveAgentHarnessAvailabilityDecision`). The model-selection gate added in openclaw#134837 read the read-only projection instead, which keeps the bare `codex` id, so it rejected selections that would run fine. The gate now asks for the execution decision through `resolveEffectiveAgentRuntime({ mode: "execution" })`; thinking validation keeps the projection. ## Evidence - Real `openclaw chat` (local embedded, copied operator config with no Codex plugin enabled, real OpenAI and Claude CLI): gpt-6-astra turn → `/model` Claude → `/model openai/gpt-6-astra` printed `model set to openai/gpt-6-astra` and the next turn answered. The installed build failed this step with the error above. - New `src/gateway/sessions-patch.harness-selection.test.ts`: the implicit case fails on `main` and passes here; the explicit Codex pin case still rejects on both. Cost: `pnpm test src/gateway/sessions-patch.harness-selection.test.ts --maxWorkers=1` ≈ 20 s wall, tests ≈ 0.8 s. - `pnpm test src/gateway/sessions-patch.test.ts`: 127 passed. - `node scripts/check-changed.mjs`: all green (typecheck core + core tests) except the dead-export scan, which lists only unchanged `ui/` and `src/` exports already present on `main`. Co-authored-by: Ayaan Zaidi <[email protected]>
… not enabled (#169412) ## What Problem This Solves Fixes: `/model openai/<model>` fails with `requires agent harness "codex", but no enabled plugin provides it` when the Codex plugin is not enabled, even though the same model already runs in that session. ## User Impact User impact: operators without the Codex plugin can switch back to an OpenAI model in the TUI, Control UI, and other session-patch clients. Turns already ran these models on the built-in OpenClaw runtime; only the selection check refused them. A model explicitly pinned to `agentRuntime: codex` is still rejected when no plugin provides Codex. ## Why This Change Was Made OpenAI routes prefer Codex implicitly. When that harness is unavailable, a turn falls back to OpenClaw (`implicit-unavailable` in `resolveAgentHarnessAvailabilityDecision`). The model-selection gate added in #134837 read the read-only projection instead, which keeps the bare `codex` id, so it rejected selections that would run fine. The gate now asks for the execution decision through `resolveEffectiveAgentRuntime({ mode: "execution" })`; thinking validation keeps the projection. ## Evidence - Real `openclaw chat` (local embedded, copied operator config with no Codex plugin enabled, real OpenAI and Claude CLI): gpt-6-astra turn → `/model` Claude → `/model openai/gpt-6-astra` printed `model set to openai/gpt-6-astra` and the next turn answered. The installed build failed this step with the error above. - New `src/gateway/sessions-patch.harness-selection.test.ts`: the implicit case fails on `main` and passes here; the explicit Codex pin case still rejects on both. Cost: `pnpm test src/gateway/sessions-patch.harness-selection.test.ts --maxWorkers=1` ≈ 20 s wall, tests ≈ 0.8 s. - `pnpm test src/gateway/sessions-patch.test.ts`: 127 passed. - `node scripts/check-changed.mjs`: all green (typecheck core + core tests) except the dead-export scan, which lists only unchanged `ui/` and `src/` exports already present on `main`. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit f17ac94)
Fixes #134305. Reported by @goslingmanagment. Related: #134468 adds execution-time recovery diagnostics for already-broken configurations.
What Problem This Solves
The Control UI could save a model whose required embedded harness had no installed, activatable plugin owner.
sessions.patchcommitted the model and other patch fields, then sticky persistence could replace the configured default.sessions.createlikewise accepted an unusable model. The next turn failed before inference.This remains reproducible on main
61404b6c2a9. Merged #134463 (84e81339c2c3) pairs the full model catalog with native-auth evidence; it does not validate harness ownership before saving a session selection.Why This Change Was Made
Validate harness ownership in the shared
sessions.create/sessions.patchprojection before committing any patch fields or publishing sticky defaults. Reuse the canonical runtime policy, manifest activation planner, and Gateway metadata snapshot. Installed lazy owners remain selectable without importing their runtime; missing, disabled, denied, or untrusted owners are rejected.Explicit selections and null/default resets now share one application step. Installation and capability consent stay with setup. ACP and CLI backends retain their existing selection owners.
The maintainer decision requested by ClawSweeper is resolved: reject an unavailable harness before saving, preserve the previous selection, and explain recovery. Exact-head CI remains a landing requirement.
User Impact
An unavailable selection returns actionable guidance and preserves the previous model, other session fields, and configured default. The model-selection docs describe the check and recovery. This restores the intended Gateway picker behavior for the 2026.8.1 regression reported in #134305; it does not authenticate providers or certify later runtime initialization.
Production: +48/-24, net +24. Tests: +97/-47, net +50. Docs: +7. The production growth adds the missing admission boundary while removing duplicate model-application code. No configuration option, protocol version, dependency, public API, or SQLite schema was added.
Named follow-up — apply harness admission to
/modeldirectives:src/auto-reply/reply/model-runtime-normalization.ts:89-102can accept a cataloged selection without checking its harness owner, andsrc/auto-reply/reply/directive-handling.impl.ts:489persists it. This PR protects Gateway session selection; it does not claim every model-selection surface is covered.Evidence
The original regression failed both real Gateway handlers before the fix: patch saved the unavailable model and another field, while create admitted an unusable row. The refreshed focused run passed 118 tests: 35 session-handler, 19 sticky-selection, 35 harness-owner, 23 registry, and 6 usage cases. Coverage includes missing owners, explicit Codex denial, enabled/disabled/denied generic harnesses, agent/global policy, aliases, and unchanged session/config after rejection. Cold fixture runtimes throw if imported, proving selection remains lazy.
The sticky-selection fixture now supplies the installed Codex owner required by its OpenAI route through the shared metadata fixture builder. This preserves real activation-policy checks and removes 29 test lines.
Actual Gateway RPC proof: both PRs were applied over main
61404b6c2a9and exercised together using a built Gateway, authenticated WebSocket RPC, synthetic config markedlastTouchedVersion: "2026.7.1-2", a freshOPENCLAW_STATE_DIR, and a random loopback port excluding 18789. The drivers stop their own Gateway afterward. No external provider inference or operator state was used.Each driver first creates
agent:main:harness-proofwithsynthetic/workingand labelBefore selection, then sends:{"method":"sessions.patch","params":{"key":"agent:main:harness-proof","model":"openai/gpt-5.6-sol","label":"Should not persist"}} {"method":"sessions.create","params":{"key":"agent:main:unavailable-create","model":"openai/gpt-5.6-sol"}}INVALID_REQUESTINVALID_REQUESTShould not persistBefore selectionBefore selectionfalsetruetrueopenai/gpt-5.6-solsynthetic/workingsynthetic/workingThe missing-owner response was:
The disabled-plugin case returned the same guidance naming
codex. A separate configured agent already using the broken model receivedchat.send; the Gateway emitted visiblechaterror events containingreason=owner-plugin-not-activatable. The disabled case also named ownercodexand theplugins disabledblocker. These paired runs verify selection rejection and the companion execution diagnostic. The first event exposed a truncation issue in the companion PR. The final rebuilt rerun now includes the complete Doctor command in the first implicit-Codex chat error./healthand/readyzremained HTTP 200 in these runs; this PR does not change their meaning.Direct dependency inspection covered Codex's
codex-rs/app-server/src/request_processors/catalog_processor.rs:242-295andaccount_processor.rs:1034-1090: catalog listing and auth status are separate from OpenClaw plugin-host availability.Final validation:
node scripts/run-vitest.mjs src/agents/harness/runtime-plugin.test.ts src/agents/runtime-plugins.test.ts src/plugins/provider-runtime.usage-harness.test.ts src/gateway/server.sessions.agent-model-catalog.test.ts src/gateway/server-methods/sessions-mutations.sticky-model.test.ts(118 passed), then the final harness-owner suite (35 passed). The combinedpnpm buildpassed in 22m2s. Additionalnode scripts/check-changed.mjs --base 61404b6c2a91871b2a4f5819ca98b06a90077796 -- <the 11 changed files>is still running and is not claimed as completed proof.node /tmp/harness-live-missing.mjs final-missing(port 57540) andnode /tmp/harness-live-implicit.mjs final-implicit(port 57551). Both rejected patch/create and preserved state. The implicit Codex fixture has no explicit runtime override; its first chat error includes the completeopenclaw doctor --fixcommand and the disabled-plugin reason. The missing-harness first event contains complete enable/reinstall/restart guidance.b34390d4cf76fadb569d5673dcec9402aadd46f9:.agents/skills/autoreview/scripts/autoreview --mode branch --base aadafdc198c062d61c0c4dc182d311232df6df03 --max-priority P2; scoped-clean with no accepted/actionable P0–P2 findings.b34390d4cf76fadb569d5673dcec9402aadd46f9.node scripts/watch-pr-ci.mjs 134837 b34390d4cf76fadb569d5673dcec9402aadd46f9returnedGREEN. Latest ClawSweeper comment has noRank-up moves:section; its before-merge requests are resolved by the explicitly authorized early-rejection decision, the shared projection boundary, and green exact-head CI. Native prepare/merge remains the required landing path.The upgrade-shaped fixture also passed:
node /tmp/harness-live-legacy-doctor.mjs final-legacy-doctorrandoctor --fix --non-interactiveagainst actual v2026.7.1-2agents.listand legacyopenai-codexreferences before starting the Gateway. Doctor exited 0, migrated the route toopenai, then both selections rejected with the harness reason, state stayed unchanged, and the first broken-turn error retainedopenclaw doctor --fix.Before / After
These original screenshots show the real Control UI with mock-Gateway responses. They are rendering evidence, distinct from the actual Gateway RPC proof above.
Before: the unavailable model remains selected and sending fails.
After: recovery guidance appears and the previous model remains selected.