Skip to content

fix(codex): prevent marketplace startup in rate-limit probes - #21617

Merged
nwparker merged 1 commit into
stablyai:mainfrom
nwparker:nwparker/bug-7725-disable-marketplace-probes
Sep 19, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
nwparker:nwparker/bug-7725-disable-marketplace-probes

Conversation

@nwparker

@nwparker nwparker commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca asks Codex for usage limits by starting a short-lived background server. Codex was also starting marketplace updates in that server, so a Git clone could keep running after Orca finished the usage check and leave a large temporary directory behind. The usage check now tells Codex to skip plugins and marketplace startup.

What Changed

Only the rate-limit RPC and PTY probe arguments include -c features.plugins=false; the normal read-only app-server arguments used by state-database recovery are unchanged. The probe override applies on macOS, Linux, Windows, and WSL.

Before, the rate-limit probe started Codex with the user's managed CODEX_HOME, which allowed marketplace synchronization and Git clones to begin. After, the probe still reads account/rateLimits/read but does not initialize the plugin marketplace path.

Why

Issue #7725 is real: reports include 4.3 GB on Windows 1.4.126, 27 GB and 16 GB on Windows 1.4.188, and larger cross-platform incidents. The reported trigger is a short-lived Codex app-server started by Orca's quota polling; Codex's marketplace clone can outlive that process.

Disabling plugins for this rate-limit probe removes the trigger without changing normal Codex sessions, state-database recovery, user marketplace data, or the configured runtime home. A cleanup sweep alone would only reclaim old directories and would need careful asynchronous ownership checks. Upstream Codex still needs to clean orphaned marketplace temp directories created by normal sessions and concurrent processes.

Linked Issue

Related to #7725

Visual Proof

N/A — this is a background process change with no UI or interaction change.

Testing

  • pnpm exec vitest run src/main/codex-accounts/wsl-codex-command.test.ts src/main/codex/codex-state-db-backfill-recovery.test.ts src/main/rate-limits/codex-fetcher-process-contract.test.ts src/main/rate-limits/codex-fetcher.test.ts src/main/rate-limits/codex-fetcher-probe-shutdown.test.ts src/main/rate-limits/codex-fetcher-rpc-exit-diagnostics.test.ts (54 tests)
  • pnpm run tc:node
  • pnpm run check:code-quality:changed
  • pnpm exec oxlint on changed files
  • Real authenticated Codex 0.155.1 exercise with CODEX_HOME=~/.codex: initialize and account/rateLimits/read both returned RPC results with plugins disabled.
  • Orca CLI read-only probes on reachable Windows hosts. The exact staging path was empty at probe time; related stale plugins-clone-* directories were present, confirming the unmanaged Codex temp lifecycle gap.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable.

Notes

The mitigation is cross-platform and applies to local and WSL rate-limit probes. It does not attempt to delete files from the user's default ~/.codex; that cleanup remains an upstream Codex responsibility. Existing Orca PR #6404 proposes managed-home cleanup but is held for synchronous recursive scanning and ownership concerns.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (CI will cover; focused checks pass locally)

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b45118bf-3788-4f4e-9096-6c8683a211a9

📥 Commits

Reviewing files that changed from the base of the PR and between fb4c202531ffbd221a9137b835a7a4e9a437bb1a and e7bd606.

📒 Files selected for processing (3)
  • src/main/codex-cli/codex-read-only-app-server-args.ts
  • src/main/rate-limits/codex-fetcher.test.ts
  • src/main/rate-limits/codex-fetcher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Codex CLI argument module now exports shared plugin-disabled arguments and rate-limit app-server arguments. The rate-limit fetcher uses these arguments for RPC probes and PTY launches on WSL, Windows, and other platforms. Related process-contract and fetcher tests now expect the updated arguments.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: preventing marketplace startup during Codex rate-limit probes.
Description check ✅ Passed The description covers the user impact, changes, rationale, linked issue, testing, visual proof, cross-platform considerations, and checklist status. The linked issue is provided as “Related to #7725”…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Disable Codex plugins in read-only app-server probes — adds -c features.plugins=false to CODEX_READ_ONLY_APP_SERVER_ARGS, so the rate-limit RPC probe and the state-DB backfill recovery no longer start Codex's plugin marketplace path.
  • PTY fallback parity — resolvePtyCommand appends the same override on the native, cmd.exe/win32, and WSL branches, so all four platforms match the RPC probe.
  • Test updates — the process-contract stub now requires the exact new argv, the WSL PTY fallback asserts the flag, and the state-DB recovery expected-args list was updated.

I verified the mechanism against upstream openai/codex: features.plugins is a documented key, PluginsConfigInput.plugins_enabled derives from features.enabled(Feature::Plugins), and both maybe_start_curated_repo_sync_for_config and maybe_start_plugin_startup_tasks_for_config are gated on it — so the flag does suppress the plugins-clone-* Git clone. FeaturesToml deserializes unknown feature keys into a flattened map and only warns, so this is safe on older Codex builds that predate the key.

ℹ️ Other short-lived codex app-server spawns still start with plugins enabled

The rate-limit probe is the reported and highest-frequency trigger, so scoping the fix here addresses the dominant cause of #7725. Two other short-lived spawns still launch codex app-server with plugins enabled, though, so they can also kick off the curated-repo clone this PR is suppressing.

Technical details
# Other short-lived app-server spawns not covered

## Affected sites
- `src/main/codex/codex-session-index-heal.ts:267` — `getSpawnArgsForWindows(command, ['app-server'])` against the system `~/.codex` home.
- `src/main/codex/codex-trust-grant-host.ts:76` — `getSpawnArgsForWindows(command, ['app-server'])` against the managed home (unless `useDefaultCodexHome`).

## Required outcome
- Confirm whether these probes should also pass `CODEX_DISABLE_PLUGINS_ARGS`, or record why plugins must stay enabled there. The trust-grant session reads `hooks/list`, which can include plugin-provided hooks, so disabling plugins could change its verification — this may be the reason for the current scope.

## Open questions for the human
- Is the fix intentionally limited to the read-only probes, with the heal/trust-grant probes left to upstream cleanup?

ℹ️ Nitpicks

  • The native and win32 PTY-fallback branches in resolvePtyCommand gained the new args but have no direct argument assertion; only the WSL PTY branch checks the flag (and loosely, via toContain). The primary RPC path is well pinned by the process-contract stub, so this is optional.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant