Skip to content

Commit 9fae744

Browse files
committed
fix(infra): resolve macOS product version via sw_vers for runtime prompt
- Add resolveRuntimeOsLabel() to src/infra/os-summary.ts that uses sw_vers -productVersion on Darwin instead of os.release() which returns the Darwin kernel version (e.g. 25.5.0) - Replace os.type() + os.release() with resolveRuntimeOsLabel() in cli-runner/helpers.ts, attempt.ts, and compact.ts runtime paths - On macOS 26 (Tahoe) this correctly shows "macOS 26.5.1" instead of "Darwin 25.5.0" in agent runtime prompts Fixes #95145
1 parent 22bdda2 commit 9fae744

4 files changed

Lines changed: 23 additions & 3 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 { resolveRuntimeOsLabel } 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: resolveRuntimeOsLabel(),
161162
arch: os.arch(),
162163
node: process.version,
163164
model: params.modelDisplay,

src/agents/embedded-agent-runner/compact.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
} from "../../infra/diagnostic-trace-context.js";
2525
import { formatErrorMessage } from "../../infra/errors.js";
2626
import { getMachineDisplayName } from "../../infra/machine-name.js";
27+
import { resolveRuntimeOsLabel } from "../../infra/os-summary.js";
2728
import { generateSecureToken } from "../../infra/secure-random.js";
2829
import { listRegisteredPluginAgentPromptGuidance } from "../../plugins/command-registry-state.js";
2930
import { getCurrentPluginMetadataSnapshot } from "../../plugins/current-plugin-metadata-snapshot.js";
@@ -1035,7 +1036,7 @@ async function compactEmbeddedAgentSessionDirectOnce(
10351036

10361037
const runtimeInfo = {
10371038
host: machineName,
1038-
os: `${os.type()} ${os.release()}`,
1039+
os: resolveRuntimeOsLabel(),
10391040
arch: os.arch(),
10401041
node: process.version,
10411042
model: `${provider}/${modelId}`,

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 { resolveRuntimeOsLabel } 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: resolveRuntimeOsLabel(),
19371938
arch: os.arch(),
19381939
node: process.version,
19391940
model: `${params.provider}/${params.modelId}`,

src/infra/os-summary.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ function macosVersion(): string {
1818
return out || os.release();
1919
}
2020

21+
/**
22+
* Resolves the OS label for runtime-prompt context (e.g., "macOS 26.5.1" on Darwin,
23+
* "Linux 6.8.0" on other platforms).
24+
*
25+
* On Darwin this uses `sw_vers -productVersion` instead of `os.release()` which
26+
* returns the Darwin kernel version (e.g., 25.5.0) that no longer maps to the
27+
* macOS marketing version starting with macOS 26 (Tahoe).
28+
*
29+
* Fixes #95145
30+
*/
31+
export function resolveRuntimeOsLabel(): string {
32+
if (os.platform() === "darwin") {
33+
return `macOS ${macosVersion()}`;
34+
}
35+
return `${os.type()} ${os.release()}`;
36+
}
37+
2138
/** Resolves a compact OS label for diagnostics, logs, and environment summaries. */
2239
export function resolveOsSummary(): OsSummary {
2340
const platform = os.platform();

0 commit comments

Comments
 (0)