Repository navigation
fix(doctor): clear stale Codex session state - #77565
Conversation
|
Codex review: found issues before merge. Summary Reproducibility: yes. source-level. A session configured for Next step before merge Security Review findings
Review detailsBest possible solution: Keep the plugin-owned repair direction, make route allowance state-kind aware so PI provider state does not preserve stale native runtime/harness/CLI bindings, then regenerate the SDK API baseline and rerun the targeted doctor/Codex tests plus changed gate. Do we have a high-confidence way to reproduce the issue? Yes, source-level. A session configured for Is this the best way to solve the issue? No. The repair seam is maintainable, but the current predicate is too coarse and the new public SDK export needs its baseline regenerated. Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 44a10ceea2a8. Re-review progress:
|
33cb592 to
3310a05
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3310a05073
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,12 @@ | |||
| import type { DoctorSessionRouteStateOwner } from "openclaw/plugin-sdk/runtime-doctor"; | |||
|
|
|||
| export const sessionRouteStateOwners: DoctorSessionRouteStateOwner[] = [ | |||
There was a problem hiding this comment.
Load the Codex doctor contract from npm installs
When Codex is installed as the official external npm plugin, this new contract is emitted by the plugin runtime build under dist/doctor-contract-api.js, while resolveContractApiPath() only probes <rootDir>/doctor-contract-api.{js,ts,...} and <rootDir>/contract-api.... Because the manifest registry uses the package root as rootDir, openclaw doctor --fix will never discover sessionRouteStateOwners for the npm-installed Codex plugin, so stale Codex session routing state remains uncleared on the main external-plugin install path; please either probe the dist/ sidecar or package/copy a root sidecar.
Useful? React with 👍 / 👎.
3310a05 to
ef32882
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef32882796
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const current = currentMutableStore[key]; | ||
| if ( | ||
| current && | ||
| applySessionRouteStateRepair({ entry: current, repair, now: repairedAt }) |
There was a problem hiding this comment.
Revalidate the session entry before applying repairs
If openclaw doctor --fix runs while the gateway is active, the session can change between the initial scan/confirmation and this updateSessionStore mutation. The mutator reloads the current store, but it applies the previously computed repair without checking that the current entry still has the same auto Codex state; for example, a user could select a Codex model/runtime in the interim and this stale auto model override repair would still delete the new providerOverride/modelOverride fields. Re-scan or validate the current entry inside the writer before clearing fields.
Useful? React with 👍 / 👎.
ef32882 to
3211a06
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3211a06bc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| params.entry.authProfileOverrideSource === "auto" && | ||
| ownsPrefixedValue(authProfilePrefixes, params.entry.authProfileOverride) | ||
| ) { | ||
| addReason(reasons, "auto auth profile override"); |
There was a problem hiding this comment.
Clear auto auth profiles with custom IDs
When an auto-selected profile ID does not start with one of the owner prefixes (for example a user-defined Codex profile named work whose store entry has provider openai-codex), this condition never records auto auth profile override, so doctor --fix can clear the stale Codex model/runtime/CLI state but leave authProfileOverride and authProfileOverrideSource: "auto" behind. Auth profile IDs are looked up as arbitrary keys in the auth-profile store, not guaranteed provider-prefixed, so this misses valid stale Codex auth state for custom profile names.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67d989a35e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const explicitOwnedOverride = | ||
| directOverrideIsOwned && directOverrideSource !== undefined && directOverrideSource !== "auto"; | ||
| if (!routeAllowsOwner && !explicitOwnedOverride) { |
There was a problem hiding this comment.
Clear pinned runtime separately from provider route
When the current config still includes a Codex-owned provider (for example as a fallback) but no longer uses the Codex runtime, routeAllowsOwner is true, so this block never evaluates agentHarnessId or the Codex CLI bindings for cleanup. That leaves agentHarnessId: "codex" in the session, and src/agents/command/attempt-execution.ts resolves that stored value before the configured runtime, so later message-channel runs remain pinned to Codex even after the runtime default moved away. Consider checking runtime-owned state against runtimeIds independently from provider-owned model refs.
Useful? React with 👍 / 👎.
Summary
doctor-contract-api, with Codex owning only IDs/prefixes rather than repair code.doctor --fix, while leaving explicit user choices for manual review.@latestso prerelease coverage does not drift on every package publish.1.16.0to clear the new high-severity production dependency audit advisory.Verification
pnpm test src/plugins/doctor-contract-registry.test.ts src/commands/doctor-session-state-providers.test.ts extensions/codex/index.test.ts test/scripts/plugin-prerelease-test-plan.test.ts -- --reporter=dotnode scripts/pre-commit/pnpm-audit-prod.mjs --audit-level=highpnpm crabbox:run -- --provider blacksmith-testbox --blacksmith-org openclaw --blacksmith-workflow .github/workflows/ci-check-testbox.yml --blacksmith-job check --blacksmith-ref main --idle-timeout 90m --ttl 240m --timing-json --shell -- "env CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_TEST_PROJECTS_PARALLEL=6 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 pnpm check:changed"(tbx_01kqtsftvsxv7t3dtn2f83s1td, exit 0)Refs #68615.