fix(agents): preserve Codex auth for compaction fallback#88130
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 29, 2026, 8:24 PM ET / 00:24 UTC. Summary PR surface: Source +163, Tests +604. Total +767 across 15 files. Reproducibility: yes. for source-level reproduction: the linked issue gives concrete release steps, and current main still resolves compaction routing through the OpenClaw/direct OpenAI path in the implicated helper. I did not run a live Codex OAuth gateway flow in this read-only review. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the auth-routing fix after maintainer acceptance or live proof that Codex OAuth compaction works without Do we have a high-confidence way to reproduce the issue? Yes for source-level reproduction: the linked issue gives concrete release steps, and current main still resolves compaction routing through the OpenClaw/direct OpenAI path in the implicated helper. I did not run a live Codex OAuth gateway flow in this read-only review. Is this the best way to solve the issue? Mostly yes: the PR targets the compaction runtime/auth boundary and adds focused coverage for the important variants. The remaining gap is merge-readiness proof, not an obvious code-shape blocker. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 43658872d90b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +163, Tests +604. Total +767 across 15 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49d1941401
ℹ️ 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".
| return Boolean( | ||
| findNormalizedProviderValue(params.config?.models?.providers, OPENAI_CODEX_PROVIDER_ID), | ||
| ); |
There was a problem hiding this comment.
Route Codex runtime without a provider config entry
When a Codex-backed agent follows the documented quickstart config (enable the codex plugin, use openai/gpt-*, and sign in with openai-codex OAuth, without adding models.providers.openai-codex), this new guard returns false even though the active harness runtime is Codex. That sends compaction back through the direct openai provider, so OAuth-only installs still hit the missing OPENAI_API_KEY path this patch is meant to fix; resolveModelAsync("openai-codex", ...) already supports built-in Codex model fallback without requiring this config entry.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b60113bcc
ℹ️ 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".
| senderId: params.params.senderId, | ||
| provider: params.params.provider, | ||
| modelId: params.params.model, | ||
| harnessRuntime: params.params.agentHarnessId, |
There was a problem hiding this comment.
Thread the policy runtime into queued compaction
When the OpenAI/Codex route is selected by the harness policy rather than an explicit agentHarnessId, this still passes only params.params.agentHarnessId into buildEmbeddedCompactionRuntimeContext. The surrounding queued path computes ceHarnessPolicy.runtime and uses it for model loading/token budget, but the runtimeContext handed to contextEngine.compact() keeps harnessRuntime undefined, so resolveEmbeddedCompactionTarget() falls back to the OpenClaw route and leaves runtimeProvider unset. In the default Codex-OAuth OpenAI session, plugin-owned/context-engine fallback compaction therefore still receives openai without the openai-codex runtime provider and can hit the direct OPENAI_API_KEY failure this patch is meant to avoid.
Useful? React with 👍 / 👎.
6b60113 to
e05907e
Compare
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
|
/allow-dependencies-change removal-only root shrinkwrap sync after tokenjuice left the root dependency graph on current main |
|
/allow-dependencies-change removal-only root shrinkwrap sync after tokenjuice left the root dependency graph on current main |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0129adabc
ℹ️ 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".
| provider: params.provider, | ||
| modelId: params.model, | ||
| authProfileId: params.authProfileId, | ||
| harnessRuntime: params.agentHarnessId ?? runtimeHarnessPolicy.runtime, |
There was a problem hiding this comment.
Honor the compaction model runtime before routing
When agents.defaults.compaction.model switches to a different OpenAI model that has a provider/model agentRuntime.id: "openclaw", this still feeds resolveEmbeddedCompactionTarget() the harness policy resolved from the pre-override model. In an OpenAI session that defaults to Codex and has openai-codex configured, compaction is therefore routed through openai-codex even though the configured compaction model explicitly opted back into the OpenClaw runtime; the queued path repeats the same preliminary-policy pattern. Resolve the harness policy from the final compaction provider/model before using it for runtime-provider selection.
Useful? React with 👍 / 👎.
d0129ad to
37f3fc2
Compare
|
/allow-dependencies-change removal-only root shrinkwrap sync after tokenjuice left the root dependency graph on current main |
1 similar comment
|
/allow-dependencies-change removal-only root shrinkwrap sync after tokenjuice left the root dependency graph on current main |
37f3fc2 to
dfa13bb
Compare
476ee83 to
ac6f93d
Compare
Summary
Fixes #86820.
OpenAI compaction now preserves the selected Codex runtime route when the session actually ran under the Codex harness. Codex OAuth sessions load compaction models through
openai-codexinstead of falling back to directopenaiAPI-key auth.The fix is selected-runtime scoped. Direct OpenAI API-key sessions, OpenClaw-pinned sessions, implicit-only Codex defaults, and custom OpenAI-compatible base URLs stay on their direct OpenAI path. Explicit model/provider runtime policy is honored when no concrete session pin exists, sandbox-scoped policy keys are used for preflight compaction, and the selected harness plugin is cold-loaded before routed model/context lookup.
Delegated context-engine compaction now carries
agentHarnessIdback into the runtime bridge so timeout/overflow recovery keeps the same selected harness.Verification
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/compact.hooks.test.ts src/agents/harness/selection.test.ts src/agents/harness/runtime-plugin.test.tspnpm tsgo:prodpnpm check:test-typespnpm lint --threads=8git diff --check origin/main...HEADgit diff --check/Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/mainReal behavior proof
Behavior addressed: Codex OAuth-backed OpenAI compaction no longer drops the selected Codex runtime route or asks for direct OpenAI API-key auth during manual, queued, delegated timeout, or delegated overflow compaction.
Real environment tested: Local source checkout with focused regression tests, production/test type checks, lint, whitespace checks, and Codex autoreview; no live Codex OAuth account flow was executed from this checkout.
Exact steps or command run after this patch: focused Vitest command above;
pnpm tsgo:prod;pnpm check:test-types;pnpm lint --threads=8;git diff --check origin/main...HEAD;git diff --check; branch autoreview command above.Evidence after fix: Regression tests cover selected Codex runtime routing through
openai-codex, OpenClaw/direct OpenAI preservation when Codex was only implicit, explicit runtime policy without a persisted pin, concrete session pin preservation, sandbox/runtime-policy key handling, custom OpenAI-compatible base URL preservation, queued context-engine runtime context, selected native harness compaction, and delegated runtime context carryingagentHarnessId.Observed result after fix: Focused Vitest passed 6 files and 236 tests; production and test type checks exited cleanly; oxlint exited cleanly; whitespace checks exited cleanly; branch autoreview reported no accepted/actionable findings.
What was not tested: A live installed OpenClaw gateway with real Codex OAuth compaction and no
OPENAI_API_KEY.