Skip to content

fix(cli): avoid os.cpus during startup prompt#4717

Merged
can1357 merged 1 commit into
mainfrom
farm/f6f543ea/avoid-os-cpus-startup
Jul 6, 2026
Merged

fix(cli): avoid os.cpus during startup prompt#4717
can1357 merged 1 commit into
mainfrom
farm/f6f543ea/avoid-os-cpus-startup

Conversation

@roboomp

@roboomp roboomp commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Repro

A focused regression test spies on node:os.cpus while building a minimal system prompt: bun test /tmp/system-prompt-os-cpus-repro.test.ts. Before the fix it failed with Expected number of calls: 0 and Received number of calls: 1, proving buildSystemPrompt() synchronously reached os.cpus() on the startup prompt path.

Cause

packages/coding-agent/src/system-prompt.ts built the workstation block via getEnvironmentInfo(), which read os.cpus()[0]?.model; on Linux/Bun this can trigger per-logical-CPU sysfs frequency reads before the TUI becomes usable.

Fix

  • Added async Linux CPU model discovery that parses the first model name from /proc/cpuinfo and returns no CPU line on platforms without that cheap source.
  • Moved CPU discovery into the existing bounded system-prompt preparation fan-out so it shares timeout/fallback handling with other startup probes.
  • Added a regression test asserting system prompt construction does not call os.cpus().
  • Added the coding-agent changelog entry for Bug: omp startup blocks for seconds on many-core Linux hosts due to os.cpus() in system prompt #4712.

Verification

bun test packages/coding-agent/src/system-prompt.test.ts passed: 5 tests, 12 expectations. bun test /tmp/system-prompt-os-cpus-repro.test.ts passed after the fix. bun check passed for all workspace packages. Fixes #4712

Read the Linux CPU model from /proc/cpuinfo during system prompt construction instead of calling os.cpus(), which can synchronously probe every logical CPU frequency file on many-core hosts.

Fixes #4712
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

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

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: omp startup blocks for seconds on many-core Linux hosts due to os.cpus() in system prompt

2 participants