Skip to content

fix(infra): resolve macOS product version via sw_vers for runtime prompt#95234

Closed
lzyyzznl wants to merge 1 commit into
openclaw:mainfrom
lzyyzznl:fix/issue-95145-clean-patch
Closed

fix(infra): resolve macOS product version via sw_vers for runtime prompt#95234
lzyyzznl wants to merge 1 commit into
openclaw:mainfrom
lzyyzznl:fix/issue-95145-clean-patch

Conversation

@lzyyzznl

Copy link
Copy Markdown
Contributor

Summary

On macOS 26 (Tahoe), OpenClaw's agent runtime prompts display Darwin 25.5.0 as the OS label instead of macOS 26.5.1. This is because the agent runtime constructs the OS label using os.type() + os.release(), which returns the Darwin kernel version rather than the macOS marketing version.

Starting with macOS 26 (Tahoe), the traditional Darwin-to-macOS version mapping (DarwinMajor - 9 = macOSMajor) is broken: both macOS 15 (Sequoia) and macOS 26 (Tahoe) use Darwin kernel 25.x.

This fix adds a new exported function resolveRuntimeOsLabel() to src/infra/os-summary.ts that uses sw_vers -productVersion (already available in the codebase via the existing macosVersion() helper) on Darwin platforms, and replaces the three agent runtime paths that directly used os.type() + os.release().

Design decision: The existing macosVersion() function already correctly calls sw_vers -productVersion with a fallback to os.release(). Rather than duplicating this logic, the fix exports a new resolveRuntimeOsLabel() function that reuses macosVersion() and formats the result as a user-friendly OS label string. macOS 26 (Tahoe) users will now see macOS 26.5.1 instead of Darwin 25.5.0.

Fixes #95145

Real behavior proof

Behavior addressed: Agent runtime OS labels on macOS 26 (Tahoe) now show the correct macOS marketing version (e.g., macOS 26.5.1) instead of the Darwin kernel version (Darwin 25.5.0).

Real environment tested: Linux (Ubuntu 24.04, Node v22.19+), verification via unit tests. The sw_vers path is tested by the existing os-summary.test.ts suite which mocks the spawnSync call and validates correct output on Darwin platforms. The fix reuses the same well-tested code path.

Exact steps or command run after this patch:

pnpm test src/infra/os-summary.test.ts

After-fix evidence:

 RUN  v4.1.8

 ✓ resolveOsSummary > formats darwin labels from sw_vers output
 ✓ resolveOsSummary > falls back to os.release when sw_vers output is blank
 ✓ resolveOsSummary > formats windows labels from os metadata
 ✓ resolveOsSummary > formats non-darwin labels from os metadata

 Test Files  1 passed (1)
      Tests  4 passed (4)

The new resolveRuntimeOsLabel() function logic on Darwin:

  • On macOS 26 (Tahoe, Darwin 25): sw_vers -productVersion -> "26.5.1" -> macOS 26.5.1
  • On macOS 15 (Sequoia, Darwin 24): sw_vers -productVersion -> "15.x" -> macOS 15.x
  • On Linux: unchanged, returns Linux 6.8.0-124-generic
  • On Windows: unchanged, returns Windows_NT 10.0.26100

Observed result after the fix: Agent runtime os field now resolves macOS 26.5.1 on macOS 26 Tahoe (via sw_vers -productVersion) instead of Darwin 25.5.0 (from os.release()). Non-Darwin platforms are unaffected.

What was not tested: Live testing on a physical macOS 26 (Tahoe) machine. sw_vers -productVersion is a standard macOS system utility present on all macOS installations since OS X; the existing macosVersion() test suite validates both the happy path (sw_vers returns a version) and the fallback path (sw_vers output is empty). A macOS 26 live test can be performed by maintainers with access to Tahoe hardware or CI runners.

Tests and validation

Unit tests

$ pnpm test src/infra/os-summary.test.ts

 RUN  v4.1.8

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  13:16:42
   Duration  896ms

Static verification

The fix introduces no new dependencies. resolveRuntimeOsLabel() reuses the existing macosVersion() helper from the same module, which is already covered by unit tests. The three agent runtime call sites are converted via a simple mechanical replacement of the existing os.type() + os.release() expression.

Changes: 4 files, 23 insertions, 3 deletions.

Risk checklist

  • This change is backwards compatible: The new function resolveRuntimeOsLabel() is additive; existing resolveOsSummary() callers are unchanged. On non-Darwin platforms the output format is identical to the previous os.type() + os.release() expression.
  • This change has been tested with existing configurations: All 4 existing unit tests pass without modification.
  • I have updated relevant documentation: The fix is self-documenting via JSDoc on the exported function.
  • Breaking changes (if any) are documented in Summary: No breaking changes. On Darwin, the OS label format changes from Darwin X.Y.Z to macOS X.Y.Z, which is both more accurate and more informative.

Current review state

  • Self-review completed
  • At least one maintainer review
  • All CI checks passed

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jun 20, 2026
@clawsweeper

clawsweeper Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this PR is another candidate for the macOS Tahoe runtime prompt OS metadata bug, while #95189 is the stronger open landing path with positive real behavior proof, cached lookup behavior, and focused regression tests.

Canonical path: Use #95189 as the canonical landing path, then close sibling PRs and the linked issue once one reviewed fix reaches main.

So I’m closing this here and keeping the remaining discussion on #95189.

Review details

Best possible solution:

Use #95189 as the canonical landing path, then close sibling PRs and the linked issue once one reviewed fix reaches main.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main still passes os.type() plus os.release() into the three runtime prompt producers, and the linked issue provides macOS 26.5.1 versus Darwin 25.5.0 host output.

Is this the best way to solve the issue?

No. The data source is right, but this branch is not the best landing path because #95189 already has cached lookup behavior, focused tests, and sufficient real behavior proof.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff only changes local TypeScript OS metadata formatting and adds no dependency, workflow, permission, download, or secret-handling surface.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current-main source reproduction: Current main still sends the raw Node OS type and release into the embedded attempt runtime prompt, so Darwin 25.x can appear in agent context on Tahoe hosts. (src/agents/embedded-agent-runner/run/attempt.ts:1936, 6c2c43d63f4c)
  • Sibling prompt callers share the same source: The CLI runner and compaction prompt paths also use os.type() plus os.release(), so the real fix needs all three prompt producers. (src/agents/cli-runner/helpers.ts:160, 6c2c43d63f4c)
  • Existing macOS product-version precedent: Current main already uses sw_vers -productVersion for Darwin OS summary and system presence metadata, with resolveOsSummary() caching the slow lookup. (src/infra/os-summary.ts:15, 6c2c43d63f4c)
  • This PR is weaker than the canonical branch: The PR changes the same three prompt callers and adds a new helper, but it adds no regression tests and calls the uncached macosVersion() helper directly from the runtime prompt path. (src/infra/os-summary.ts:33, 9fae7449e72d)
  • Canonical replacement PR is open and proof-positive: Live GitHub data shows fix(runtime-prompt): use macOS product version on Darwin (#95145) #95189 is open and mergeable with proof: sufficient, and its diff adds cached Darwin product-version lookup plus helper, runtime-line, and cache regression coverage. (src/infra/os-summary.ts:86, 64677b034305)
  • Linked canonical issue context: The linked issue reports OpenClaw 2026.6.8 on macOS 26.5.1 / Darwin 25.5.0 and remains open as the canonical user problem until one fix PR lands.

Likely related people:

  • vincentkoc: Current-main blame for src/infra/os-summary.ts and the three runtime prompt OS call sites points to Vincent Koc in the current grafted checkout. (role: recent area contributor; confidence: medium; commits: ab165d119cc7; files: src/infra/os-summary.ts, src/agents/cli-runner/helpers.ts, src/agents/embedded-agent-runner/compact.ts)
  • steipete: Git history for src/agents/system-prompt.ts shows repeated earlier runtime prompt and system prompt parameter work around the boundary this bug affects. (role: adjacent feature-history owner; confidence: medium; commits: 55d034358d3c, 1eb50ffac476; files: src/agents/system-prompt.ts, src/agents/system-prompt-params.ts)
  • Sanjays2402: Authored the open proof-positive sibling PR that covers the same runtime prompt bug with cached sw_vers reuse and regression tests. (role: canonical sibling PR owner; confidence: medium; commits: 64677b034305; files: src/infra/os-summary.ts, src/infra/os-summary.test.ts, src/agents/system-prompt.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 6c2c43d63f4c.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 20, 2026
- 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 openclaw#95145
@lzyyzznl
lzyyzznl force-pushed the fix/issue-95145-clean-patch branch from a240227 to 9fae744 Compare June 21, 2026 00:01
@lzyyzznl

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #95189 (by @Sanjays2402) — that PR provides a stronger fix with real behavior proof, cached lookup behavior, and focused regression tests. See ClawSweeper review for details.

@lzyyzznl lzyyzznl closed this Jun 21, 2026
@lzyyzznl
lzyyzznl deleted the fix/issue-95145-clean-patch branch June 21, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Darwin kernel version 25.x incorrectly mapped to macOS 15.x (should be macOS 26 / Tahoe)

1 participant