Skip to content

Commit e61380f

Browse files
committed
fix(infra): propagate macOS product version to runtime prompt metadata (fixes #95145)
- Cache macosVersion() result to avoid double sw_vers probe - Route cli-runner and embedded attempt OS fields through resolveOsSummary - Update os-summary test expectations for darwin release = product version
1 parent f12f0a1 commit e61380f

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/agents/cli-runner/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { ThinkLevel } from "../../auto-reply/thinking.js";
1919
import type { ChatType } from "../../channels/chat-type.js";
2020
import type { CliBackendConfig } from "../../config/types.js";
2121
import type { OpenClawConfig } from "../../config/types.openclaw.js";
22+
import { resolveOsSummary } from "../../infra/os-summary.js";
2223
import { privateFileStore } from "../../infra/private-file-store.js";
2324
import { tempWorkspace } from "../../infra/private-temp-workspace.js";
2425
import { resolvePreferredOpenClawTmpDir } from "../../infra/tmp-openclaw-dir.js";
@@ -157,7 +158,7 @@ export function buildCliAgentSystemPrompt(params: {
157158
sessionKey: params.sessionKey,
158159
sessionId: params.sessionId,
159160
host: "openclaw",
160-
os: `${os.type()} ${os.release()}`,
161+
os: `${os.type()} ${resolveOsSummary().release}`,
161162
arch: os.arch(),
162163
node: process.version,
163164
model: params.modelDisplay,

src/agents/embedded-agent-runner/run/attempt.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { isEmbeddedMode } from "../../../infra/embedded-mode.js";
4444
import { formatErrorMessage } from "../../../infra/errors.js";
4545
import { resolveHeartbeatSummaryForAgent } from "../../../infra/heartbeat-summary.js";
4646
import { getMachineDisplayName } from "../../../infra/machine-name.js";
47+
import { resolveOsSummary } from "../../../infra/os-summary.js";
4748
import { createCodexNativeWebSearchWrapper } from "../../../llm/providers/stream-wrappers/openai.js";
4849
import type { AssistantMessage } from "../../../llm/types.js";
4950
import { listRegisteredPluginAgentPromptGuidance } from "../../../plugins/command-registry-state.js";
@@ -1933,7 +1934,7 @@ export async function runEmbeddedAttempt(
19331934
sessionKey: params.sessionKey,
19341935
sessionId: params.sessionId,
19351936
host: machineName,
1936-
os: `${os.type()} ${os.release()}`,
1937+
os: `${os.type()} ${resolveOsSummary().release}`,
19371938
arch: os.arch(),
19381939
node: process.version,
19391940
model: `${params.provider}/${params.modelId}`,

src/infra/os-summary.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ describe("resolveOsSummary", () => {
3737
expected: {
3838
platform: "darwin",
3939
arch: "arm64",
40-
release: "24.0.0",
40+
// On darwin, release uses sw_vers -productVersion, not os.release()
41+
// (kernel 24.0.0 → macOS 15.4). #95145
42+
release: "15.4",
4143
label: "macos 15.4 (arm64)",
4244
},
4345
},

src/infra/os-summary.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ function macosVersion(): string {
2121
/** Resolves a compact OS label for diagnostics, logs, and environment summaries. */
2222
export function resolveOsSummary(): OsSummary {
2323
const platform = os.platform();
24-
const release = platform === "darwin" ? macosVersion() : os.release();
24+
// On darwin, os.release() returns the Darwin kernel version (e.g. "25.5.0"),
25+
// not the macOS product version ("26.5.1"). Use macosVersion() which calls
26+
// sw_vers -productVersion to get the actual macOS version. (#95145)
27+
const darwinProductVersion = platform === "darwin" ? macosVersion() : null;
28+
const release = darwinProductVersion ?? os.release();
2529
const arch = os.arch();
2630
const cacheKey = `${platform}\0${release}\0${arch}`;
2731
// Cache by stable os.* facts; darwin's sw_vers lookup is comparatively slow
@@ -32,7 +36,7 @@ export function resolveOsSummary(): OsSummary {
3236
}
3337
const label = (() => {
3438
if (platform === "darwin") {
35-
return `macos ${macosVersion()} (${arch})`;
39+
return `macos ${darwinProductVersion} (${arch})`;
3640
}
3741
if (platform === "win32") {
3842
return `windows ${release} (${arch})`;

0 commit comments

Comments
 (0)