SIGN IN SIGN UP

MUL-5466 fix(agent): deliver the qwen prompt on stdin, not argv (#7343)

* fix(agent): route qwen launch through the Windows invocation chooser

On Windows npm installs qwen as qwen.cmd, a batch shim. Spawning a .cmd
goes through cmd.exe, whose %* forwarding re-tokenises the raw command
line, so the `-p <prompt>` value and the `--output-format stream-json`
flags buildQwenArgs puts behind it are mangled whenever the daemon's
structured chat prompt carries newlines, quotes or `&`. Qwen then runs
without a usable prompt or without stream-json, exits 0 after emitting a
single unparseable stdout line, and finalizeStreamResult reports "qwen
stream ended without terminal result". A short manual `qwen -p "hallo"`
never hits the mangling, which is why the CLI looked healthy in isolation.

Mirror the existing cursor/pi/copilot fix instead of inventing a new
mechanism: resolve qwen.ps1 next to the .cmd and invoke PowerShell with
`-File <ps1>` directly so Go hands each argv token whole, staying on the
official launch path. qwenBackend.Execute now builds its process through
Command.execVia(chooseQwenInvocation, ...) rather than Command.exec; on
macOS/Linux the chooser is a passthrough and behaviour is unchanged.

Fixes #6082

* test(agent): cover qwen's stdin prompt delivery and update signatures

buildQwenArgs dropped its prompt parameter in the prior commit (the
prompt now goes on stdin, not argv), so the existing unit tests needed
their call sites and assertions updated to match — including an
explicit check that "-p" never appears in argv again.

Adds TestQwenBackendDeliversPromptOnStdin: a round-trip regression
guard proving a prompt containing embedded double quotes, an em dash,
and shell metacharacters reaches the child process byte-for-byte via
stdin, the way cursor-agent and Pi already do (#5649's fix). The fake
qwen script now optionally captures stdin to a file the same way it
already captures argv.

* test(agent): cover qwen Windows PowerShell launch

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: J <bohan@devv.ai>
Co-authored-by: multica-agent <github@multica.ai>
D
Danila Katalshov committed
bdcb231ba00415c952e0d46ca6a90ae9273b4ff3
Parent: 1cff79d
Committed by GitHub <noreply@github.com> on 8/24/2026, 7:08:14 AM