Skip to content

Commit e2f241d

Browse files
committed
fix(agents): use macOS product version in runtime prompt OS metadata
os.release() returns the Darwin kernel version (e.g. "25.5.0"), which diverged from the macOS marketing version starting with macOS 26 Tahoe. This caused agents to report "Darwin 25.5.0" instead of "Darwin 26.5.1". Add resolveAgentOsString() that uses sw_vers -productVersion on Darwin and update all three agent runtime-info sites to use it. Closes #95145
1 parent 78d1b4a commit e2f241d

4 files changed

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

src/infra/os-summary.ts

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

21+
/**
22+
* Resolves the OS version string for agent runtime prompts.
23+
* On macOS this uses sw_vers -productVersion (e.g. "26.5.1") instead
24+
* of os.release() which returns the Darwin kernel version (e.g. "25.5.0")
25+
* that diverged from the marketing version starting with macOS 26 Tahoe.
26+
*/
27+
export function resolveAgentOsString(): string {
28+
if (os.platform() === "darwin") {
29+
return `${os.type()} ${macosVersion()}`;
30+
}
31+
return `${os.type()} ${os.release()}`;
32+
}
33+
2134
/** Resolves a compact OS label for diagnostics, logs, and environment summaries. */
2235
export function resolveOsSummary(): OsSummary {
2336
const platform = os.platform();

0 commit comments

Comments
 (0)