#5950: Improvement/windows shell enhancement
agents
Cluster:
Build and Fix Enhancements
Summary
Improves PowerShell execution reliability on Windows environments.
Changes
- ExecutionPolicy Bypass: Adds `-ExecutionPolicy Bypass` to the PowerShell arguments in `shell-utils.ts`.
- Reason: This ensures that local scripts (including npm/pnpm spawns or user scripts) run smoothly even on Windows systems with restrictive default execution policies, preventing common `PSSecurityException` errors during tool execution.
- Safety: Retains the existing `resolvePowerShellPath()` logic to ensure the correct executable is used.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR’s stated goal is to improve PowerShell execution reliability on Windows by adding `-ExecutionPolicy Bypass` in `src/agents/shell-utils.ts`.
However, the changeset also introduces several new behavioral features unrelated to shell execution:
- A SmartRouter system that dynamically selects models and writes daily usage stats (`src/agents/smart-router.ts`, `src/agents/model-experience.ts`, plus integration in `src/agents/pi-embedded-runner/run.ts`).
- New “smart rate limit” retry behavior that waits before failing over (`src/agents/pi-embedded-runner/run.ts`).
- A new context-optimizer that calls Gemini’s cachedContents REST API and injects `cachedContent` into model calls (`src/features/context-optimizer/index.ts`, hooked in `src/agents/pi-embedded-runner/run/attempt.ts`).
- Repo/workflow changes like adding `package-lock.json` and altering `.gitattributes`.
Main issues are around unexpected behavior changes (automatic model switching), retry/compaction flag coupling, and new network+cache behavior without explicit feature gating. There are also a few Windows/dev-experience concerns (hard-coded paths in .bat scripts, pnpm→npx build change).
<h3>Confidence Score: 2/5</h3>
- This PR is not safe to merge as-is due to multiple unrelated behavioral changes and new ungated runtime side effects.
- While the PowerShell `-ExecutionPolicy Bypass` change is reasonable, the PR also adds automatic model routing, rate-limit wait logic, and a Gemini context caching feature that performs additional network requests and global caching. These changes can affect correctness, security/compliance expectations, and operational behavior, and they are not clearly gated or scoped to the PR’s stated purpose.
- src/agents/pi-embedded-runner/run.ts, src/agents/pi-embedded-runner/run/attempt.ts, src/features/context-optimizer/index.ts, src/agents/smart-router.ts, scripts/run-node.mjs, run_openclaw.bat, .gitattributes, package-lock.json
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#18493: making pnpm build:ui and pnpm build to work on windows
by darkpowerxo · 2026-02-16
78.1%
#12871: fix: use bash and warn about shell injection (issue #12836)
by ambicuity · 2026-02-09
76.6%
#9250: Fix: Add shell:true for Windows .cmd files to prevent spawn EINVAL ...
by vishaltandale00 · 2026-02-05
76.4%
#21215: Windows PowerShell reliability fixes (exec shim + Discord numeric p...
by musosoft · 2026-02-19
76.3%
#5168: Fix: force UTF-8 for Windows exec
by ManojINaik · 2026-01-31
75.3%
#11951: Prepending Windows Node to PATH didn’t help
by tranhoangtu-it · 2026-02-08
75.2%
#11300: feat(exec): make shell configurable via tools.exec.shell
by imjszhang · 2026-02-07
75.1%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
74.1%
#8876: Confirmaciones para equipo de IT
by m4xjunior · 2026-02-04
74.1%
#6888: feat: PowerShell completion install/uninstall + templates script + ...
by ThinkIbrokeIt · 2026-02-02
74.0%