[Bug]: Windows: OpenCode plugin hooks are invoked via `sh -c` — `sh` is not on a normal Windows PATH, every hook dies, session stuck in `no_signal`
Summary
AO's OpenCode adapter signals session activity through an AO-managed OpenCode plugin (ao-activity.ts), installed per-worktree into <worktree>\.opencode before launch. The plugin maps session.created / message.updated / session.status to hook commands of the form:
sh -c 'if ! command -v ao >/dev/null 2>&1; then exit 0; fi; exec ao hooks opencode <hookName>'
sh does not exist on a normal Windows PATH. OpenCode boots, creates its session, does its work — and every hook dies before exec, so no signal ever reaches the daemon: first_signal_at stays NULL and the session degrades to no_signal even though the agent completed its task.
Steps to reproduce
- Windows, AO 0.11.2, OpenCode installed as native
opencode.exe, daemon PATH without any directory providingsh(the normal case). - Spawn an OpenCode worker session.
- Watch the OpenCode log for the worktree session:
level=ERROR message="hook session-start failed: Executable not found in $PATH: \"sh\""
level=ERROR message="hook user-prompt-submit failed: Executable not found in $PATH: \"sh\""
level=ERROR message="hook stop failed: Executable not found in $PATH: \"sh\""
ao session ls→ session reachesno_signal; since the OpenCode process is still alive holding the worktree cwd,ao session killthen also hits the Windows cleanup 500 (#3408).
Proof by inversion: start the daemon with a PATH that includes a directory providing sh (e.g. C:\Program Files\Git\usr\bin) → zero hook errors in the OpenCode log, session transitions idle → working (signals flowing), task completes, and ao session kill returns killed (workspace preserved) cleanly.
Expected behavior
On Windows, the plugin emits the hook command without the sh -c wrapper (or resolves sh explicitly / uses a native invocation), so signals flow on a stock Windows install.
Actual behavior
Every hook fails with Executable not found in $PATH: "sh"; session shows no_signal despite the agent working; kill then 500s per #3408.
AO version
0.11.2 (desktop app; bundled daemon resources\daemon\ao.exe)
Environment
Windows 10 Pro (10.0.19045) x64; ConPTY runtime; native opencode.exe
Logs / extra context
- Same Windows-portability class as #2688 (Unix
envargv prefix in the OpenCode adapter, already fixed): the adapter path works, but assumes Unix coreutils at runtime. - Note the plugin is installed correctly per-worktree (verified: 21 files under
<worktree>\.opencodeat T+5 s); only the hook execution is broken. - Unrelated observation while measuring, possibly worth a docs note: OpenCode boot on a mid-range Windows machine took ~70–85 s between config load and session creation, so signals only start ~90 s after spawn — easy to misread as
no_signalwhen watching the session list. - Duplicate search: #2688, #3110 (Claude Code PostToolUse hooks), #899 — none cover the plugin's
sh -chook wrapper.
I investigated this and it looks like the hook command is always wrapped in sh -c. I'll work on a Windows-specific invocation and open a PR.
I found the root cause (sh -c is hardcoded in the OpenCode activity plugin). I'm validating a cross-platform fix to ensure it actually resolves the Windows hook failure without changing Unix behavior before opening a PR.
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @illegalcall
- @pulkit7070
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @pulkit7070 here.
For faster context or live questions, you can also join the AO Discord.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
i ran an opencode session on windows after fixing a separate launch error in my local desktop copy. the session ran ao version, and ao recorded its activity. i did not see the no_signal behavior on this setup.