agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

[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`

Open faogomes opened this issue 4 months ago • 4 comments

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

  1. Windows, AO 0.11.2, OpenCode installed as native opencode.exe, daemon PATH without any directory providing sh (the normal case).
  2. Spawn an OpenCode worker session.
  3. 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\""
  1. ao session ls → session reaches no_signal; since the OpenCode process is still alive holding the worktree cwd, ao session kill then 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 env argv 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>\.opencode at 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_signal when watching the session list.
  • Duplicate search: #2688, #3110 (Claude Code PostToolUse hooks), #899 — none cover the plugin's sh -c hook wrapper.

faogomes avatar Jul 31 '26 19:07 faogomes

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.

dhruvil-codes avatar Aug 01 '26 07:08 dhruvil-codes

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.

dhruvil-codes avatar Aug 01 '26 08:08 dhruvil-codes

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.

somewherelostt avatar Aug 01 '26 15:08 somewherelostt

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.

codebanditssss avatar Oct 29 '26 16:10 codebanditssss