Skip to content

fix(agents): resolve Windows bare commands through PATHEXT - #135138

Merged
steipete merged 2 commits into
openclaw:mainfrom
gaoanze888:fix/windows-pathext-bare-command
Sep 1, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
gaoanze888:fix/windows-pathext-bare-command

Conversation

@gaoanze888

@gaoanze888 gaoanze888 commented Sep 1, 2026 •

Copy link
Copy Markdown

Closes #134960.

What Problem This Solves

An npm-installed CLI can fail Windows onboarding with executable cannot be bound to one durable absolute owner because identity lookup selects the neighboring POSIX shim before the Windows launcher. Selecting the .cmd path explicitly succeeds.

Why This Change Was Made

Use the existing Windows PATH/PATHEXT resolver at the command-identity boundary. Keep the relative-PATH and cwd-relative command checks before lookup, reject unresolved bare results, and retain the shared normalizer for explicit and home-relative paths. Artifact hashing, package eligibility, native executable names, and the exact bound child invocation stay with their existing owners. Production gains eight lines; the SDK and generic executable resolver are unchanged.

The existing identity and Windows spawn suites now run in the regular Windows CI shard. Native fixtures use file copies across toolcache/workspace drives and native path canonicalization. The unchanged-launcher check also requires an actual fingerprint before comparing it. POSIX retains its shebang-flag refusal; the Windows package cases verify that an external throwing hook named only in a shebang is never executed by the bound Node invocation.

User Impact

Eligible npm-installed CLI backends can bind using their normal command name while keeping the POSIX launcher available for Git Bash. This changes command selection, not which runtime artifacts qualify for a durable owner.

Thanks @Vasanthdev2004 for the report and reproduction, and @gaoanze888 for the original PATHEXT repair.

Evidence

  • Native baseline: Windows CI run on Windows Server 2025 and Node 22.23.2 reproduced both bare-command identity failures at test-only commit 31944c8. Explicit commands produced identities, then encountered a short-path fixture mismatch; an existing POSIX-only shebang expectation also failed. Those three test issues are corrected separately from the selector repair. The completed job log was preserved before the remaining test-only workflow was canceled.
  • Final local owner/caller proof: 60 passed, 10 Windows-only skips across identity, auth-epoch binding, Windows spawn, and generic executable lookup. Source fingerprints were unchanged throughout the run.
  • Final changed-file checks passed for the production owner and corrected identity tests, including production/test types, lint, dead-code checks, and repository guards. The unchanged package-script and SDK-test files retain their earlier passing checks. Fresh Codex P0 review and independent owner/dependency review found no actionable defect in the change.
  • Final native Windows proof: Windows Server 2025 / Node 22.23.2 job passed all 16 Windows identity cases (one intentional POSIX-only skip) and seven SDK cases. All four native/package × explicit/bare rows executed the returned command and arguments, required exit 0 and identity-ok, and passed. Home paths, missing PATH, relative paths, unsupported wrappers, and the inert shebang-hook control passed. The tested merge was fc1d30eaf0e14212201df01180cd9c5262688f5c, integrating the reviewed head into its base; the reviewed source/test/package bytes match exactly.
  • Exact head 966a5f8b35d186ce8dd2d9f35a03529a3c69f01c: CI run 33536039079 passed 246 checks with 13 skips, including both Windows jobs and the final gate. This head includes the separately landed protocol declaration build repair from fix: restore protocol declaration builds #135360. Fresh managed Codex P0 review and independent source review found no actionable defect.

The native tests exercise real command selection, artifact binding, and child processes. CI has no authenticated CLI account, so this does not claim a complete account-authenticated onboarding session.

Review follow-through: the Windows job now verifies selection, binding, and actual child execution, which the earlier fixtures did not. It uses npm-style on-disk layouts; npm installation and account onboarding are not run in CI. The repaired boundary is command lookup, and the published installer contracts were inspected separately.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 1, 2026, 7:21 AM ET / 11:21 UTC.

ClawSweeper review

What this changes

The PR routes bare Windows CLI backend commands through PATHEXT so executable identity binding selects npm’s .cmd or .exe launcher rather than an extensionless POSIX shim.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

No blocking correctness finding: this is a focused, source-supported repair for the linked Windows binding bug. It must remain open because the prior rank-up request is still unmet: the PR has only synthetic tests and no redacted after-fix Windows npm-global binding-and-launch trace.

Priority: P1
Reviewed head: 66f169badfeb2df8e7b267062f81bd7b84895150

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-supported, but external real Windows behavior proof remains absent.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The changed production owner is resolveCommandPath, which feeds CLI backend identity binding before launch. The PR supplies focused filesystem fixtures and reported checks, but no after-fix real Windows npm-global CLI resolve/bind/launch trace; add redacted terminal output or an artifact, then update the PR body for re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed production owner is resolveCommandPath, which feeds CLI backend identity binding before launch. The PR supplies focused filesystem fixtures and reported checks, but no after-fix real Windows npm-global CLI resolve/bind/launch trace; add redacted terminal output or an artifact, then update the PR body for re-review.
Evidence reviewed 7 items Current-main failure mechanism: Current main sends a bare command to the generic executable resolver, whose Windows extension list probes the extensionless filename before PATHEXT entries; the Windows identity path then rejects a direct shebang invocation.
Shared execution behavior: The pre-existing Windows spawn helper resolves bare names through PATH and PATHEXT before wrapper inspection, which is the behavior the new identity branch adopts.
Caller and owner boundary: CLI runtime fingerprinting invokes executable identity with the configured backend command before the backend can be bound to a durable runtime artifact.
Findings None None.
Security None None.

How this fits together

Before a CLI backend can be used, OpenClaw resolves and fingerprints its configured executable as a durable runtime owner. Windows npm global installs provide multiple launcher files, so identity resolution must select the same executable route used by process spawning.

flowchart LR
  A[Configured bare command] --> B[Executable identity resolver]
  B --> C{Windows bare name?}
  C -->|Yes| D[PATHEXT launcher lookup]
  C -->|No| E[General path lookup]
  D --> F[Durable executable identity]
  E --> F
  F --> G[CLI backend binding and launch]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed production owner is resolveCommandPath, which feeds CLI backend identity binding before launch. The PR supplies focused filesystem fixtures and reported checks, but no after-fix real Windows npm-global CLI resolve/bind/launch trace; add redacted terminal output or an artifact, then update the PR body for re-review.
  • Resolve merge risk (P1) - Merging changes which launcher existing Windows bare-command profiles fingerprint and bind; synthetic fixtures do not yet prove an actual npm-global package resolves, binds, and launches correctly on Windows.
  • Resolve merge risk (P1) - This bug fix adds 6 production lines, justified by reusing the existing canonical Windows spawn resolver at the identity boundary; a net-neutral alternative would require broadening the generic resolver API solely for this one platform rule.
  • Complete next step (P2) - The remaining merge blocker is contributor-supplied real Windows behavior proof, not a bounded repair task.
Agent review details

Security

None.

PR surface

Source +6, Tests +49. Total +55 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 0 +6
Tests 2 50 1 +49
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 56 1 +55

Review metrics

Metric Value Why it matters
Production versus test delta production +6/-0; tests +50/-1 The only production growth routes one Windows branch to an existing resolver; the remaining change is focused regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #134960
Summary: This PR directly implements the linked issue’s described mismatch between executable identity resolution and Windows spawn resolution.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Add real Windows binding proof (recommended)
    Provide a redacted terminal trace from a Windows npm-global CLI installation showing the bare command resolves, binds, and launches after this change.

Technical review

Best possible solution:

Keep one shared PATHEXT resolution rule for Windows identity and spawning, then merge after a redacted real Windows npm-global CLI trace shows bare-command resolution, binding, and launch.

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

Yes—source reproducible: current main probes the extensionless shim first and rejects its direct shebang, while the shared Windows spawn path already uses PATHEXT. A reviewer-side Windows execution was not performed.

Is this the best way to solve the issue?

Yes. Routing the identity lookup through the existing PATHEXT-aware spawn resolver removes the two-resolver disagreement; retrying later in Windows identity handling would duplicate lookup policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6465153422d8.

Labels

Label justifications:

  • P1: The linked report describes Windows CLI backend onboarding and binding failing for npm-global installations.
  • merge-risk: 🚨 compatibility: Bare command resolution changes for existing Windows configurations that rely on PATH and PATHEXT launcher precedence.
  • merge-risk: 🚨 auth-provider: The resolved executable becomes part of CLI backend identity and provider binding, so an unexpected launcher choice can prevent authentication setup.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed production owner is resolveCommandPath, which feeds CLI backend identity binding before launch. The PR supplies focused filesystem fixtures and reported checks, but no after-fix real Windows npm-global CLI resolve/bind/launch trace; add redacted terminal output or an artifact, then update the PR body for re-review.

Evidence

What I checked:

  • Current-main failure mechanism: Current main sends a bare command to the generic executable resolver, whose Windows extension list probes the extensionless filename before PATHEXT entries; the Windows identity path then rejects a direct shebang invocation. (src/agents/cli-executable-identity.ts:170, 6465153422d8)
  • Shared execution behavior: The pre-existing Windows spawn helper resolves bare names through PATH and PATHEXT before wrapper inspection, which is the behavior the new identity branch adopts. (src/plugin-sdk/windows-spawn.ts:141, 6465153422d8)
  • Caller and owner boundary: CLI runtime fingerprinting invokes executable identity with the configured backend command before the backend can be bound to a durable runtime artifact. (src/agents/cli-auth-epoch.ts:334, 66f169badfeb)
  • Introduced change verified: The reviewed head has merge-base 93b4d34 as its recorded parent, and its only production hunk adds the Windows bare-command branch at this resolver boundary. (src/agents/cli-executable-identity.ts:170, 66f169badfeb)
  • Focused regression coverage: The added identity test creates adjacent extensionless and .cmd launchers and asserts .cmd selection plus exe-entrypoint; the helper test also checks PATHEXT selection. These are valuable boundary tests but not a real npm-global Windows run. (src/agents/cli-executable-identity.test.ts:97, 66f169badfeb)
  • Prior review continuity: The previous completed ClawSweeper review of this same head requested a redacted real Windows npm-global resolve/bind/launch trace. The current supplied PR body lists focused tests and checks but contains no such after-fix trace or artifact. (66f169badfeb)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted Windows terminal trace using an npm-global CLI package that shows the bare command resolving, binding, and launching after this change.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-01T11:12:38.211Z sha 66f169badfeb2df8e7b267062f81bd7b84895150 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 1, 2026
gaoanze and others added 2 commits September 1, 2026 10:08
Keep canonical Windows command selection inside the identity owner, preserve explicit and home-path normalization, and reject unresolved bare commands. Exercise the bound native and package invocations in the regular Windows CI shard.

Co-authored-by: gaoanze <[email protected]>
@steipete
steipete force-pushed the fix/windows-pathext-bare-command branch from 66f169b to 966a5f8 Compare September 1, 2026 17:08
@steipete
steipete merged commit 6c6716a into openclaw:main Sep 1, 2026
319 of 321 checks passed
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…135138)

* fix(agents): resolve Windows bare commands through PATHEXT

* fix(agents): verify Windows CLI launcher ownership

Keep canonical Windows command selection inside the identity owner, preserve explicit and home-path normalization, and reject unresolved bare commands. Exercise the bound native and package invocations in the regular Windows CI shard.

Co-authored-by: gaoanze <[email protected]>

---------

Co-authored-by: gaoanze <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
synthalorian added a commit to synthalorian/openclaw that referenced this pull request Sep 6, 2026
…on Windows

On Windows, the claude-cli backend cannot launch Claude Code because
resolveClaudeAgentSdkOptions passes the bare command string (claude) as
pathToClaudeCodeExecutable. The Agent SDK resolves this to npm's
extensionless POSIX shim (a shell script), which fails to spawn on Windows.

The identity layer already has the correct answer after openclaw#135138:
resolveCliExecutableIdentity returns the resolved .cmd path and the actual
.exe entrypoint. This fix threads the identity result through to the SDK
options resolver so it can use invocation.command on win32.

Changes:
- Add executableIdentity to CliBackendExecuteContext
- Add executableIdentity to PreparedCliRunContext
- Store executableIdentity in context when resolved in execute.ts
- Pass executableIdentity through to plugin context in execute-plugin.ts
- Use identity-resolved path in agent-sdk.runtime.ts on win32
- Add regression tests for Windows and non-Windows paths

Fixes openclaw#138424
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: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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.

Windows: CLI backends fail to bind — identity resolver picks npm's extensionless sh shim over .cmd

2 participants