Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-5141: fix(agent): inject --yolo in Qwen headless runs so shell/edit/write tools are available (#5752)

Rusty Raven3171e6607fef
diff --git a/apps/docs/content/docs/install-agent-runtime.mdx b/apps/docs/content/docs/install-agent-runtime.mdx
index 973ef45de3..a1cd69d47d 100644
--- a/apps/docs/content/docs/install-agent-runtime.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.mdx
@@ -172,7 +172,7 @@ Agentic coding CLI using the ACP protocol over stdio (shares the transport with
### Qwen Code (Alibaba)
-Qwen Code uses its native JSONL protocol in daemon mode: `qwen -p <prompt> --output-format stream-json`. Session resumption works through `--resume`; the task runtime brief is written to `QWEN.md`; assigned skills are copied to `.qwen/skills/`; and personal skills use `$QWEN_HOME/skills/` (default `~/.qwen/skills/`).
+Qwen Code uses its native JSONL protocol in daemon mode: `qwen -p <prompt> --output-format stream-json --yolo`. Multica owns `--yolo` for unattended runs so shell, edit, and write tools remain available without an approval UI. This does not enable Qwen's sandbox: unless the deployment explicitly enables `--sandbox` or `QWEN_SANDBOX`, tools run with the daemon OS user's permissions and credential scope. Use `--exclude-tools` in custom arguments to hard-deny specific tools. Session resumption works through `--resume`; the task runtime brief is written to `QWEN.md`; assigned skills are copied to `.qwen/skills/`; and personal skills use `$QWEN_HOME/skills/` (default `~/.qwen/skills/`).
| | |
|---|---|
diff --git a/apps/docs/content/docs/providers.mdx b/apps/docs/content/docs/providers.mdx
index 8f722bbbd7..cd4df58ba8 100644
--- a/apps/docs/content/docs/providers.mdx
+++ b/apps/docs/content/docs/providers.mdx
@@ -99,7 +99,7 @@ From Alibaba. An agentic coding CLI. Uses the ACP protocol over stdio (shares a
### Qwen Code
-From Alibaba. Multica drives Qwen Code with its native non-interactive JSONL protocol, `qwen -p <prompt> --output-format stream-json`, and maps text, thinking, tool calls, tool results, session IDs, status, errors, and token usage into the normal task stream. **Session resumption works** through `--resume <id>`. The per-task runtime brief is written to `QWEN.md`; assigned skills are copied to `.qwen/skills/`; user skills are read from `$QWEN_HOME/skills/` (default `~/.qwen/skills/`). Select a default model with `MULTICA_QWEN_MODEL` or set a manual per-task value through Qwen's `--model` flag; Multica does not advertise an account-specific static catalog. A managed `mcp_config` is materialized into a 0600 temporary JSON file and passed as `--mcp-config <path>`, which Qwen gives highest precedence for that run; the file is removed when the process exits. Leave the field null to inherit native Qwen Code MCP settings.
+From Alibaba. Multica drives Qwen Code with its native non-interactive JSONL protocol, `qwen -p <prompt> --output-format stream-json --yolo`, and maps text, thinking, tool calls, tool results, session IDs, status, errors, and token usage into the normal task stream. Multica owns `--yolo` for unattended runs so shell, edit, and write tools remain available without an approval UI. This does not enable Qwen's sandbox: unless the deployment explicitly enables `--sandbox` or `QWEN_SANDBOX`, tools run with the daemon OS user's permissions and credential scope. Use `--exclude-tools` in custom arguments to hard-deny specific tools. **Session resumption works** through `--resume <id>`. The per-task runtime brief is written to `QWEN.md`; assigned skills are copied to `.qwen/skills/`; user skills are read from `$QWEN_HOME/skills/` (default `~/.qwen/skills/`). Select a default model with `MULTICA_QWEN_MODEL` or set a manual per-task value through Qwen's `--model` flag; Multica does not advertise an account-specific static catalog. A managed `mcp_config` is materialized into a 0600 temporary JSON file and passed as `--mcp-config <path>`, which Qwen gives highest precedence for that run; the file is removed when the process exits. Leave the field null to inherit native Qwen Code MCP settings.
### Trae
diff --git a/server/pkg/agent/qwen.go b/server/pkg/agent/qwen.go
index e67638d83f..d48658ddd4 100644
--- a/server/pkg/agent/qwen.go
+++ b/server/pkg/agent/qwen.go
@@ -21,6 +21,9 @@ type qwenBackend struct {
// qwenBlockedArgs are owned by Multica. Qwen accepts the task prompt and stream
// protocol as flags, so custom args must not replace either. Model/session are
// also selected by Multica, and safe mode disables the QWEN.md context file.
+// --yolo/-y, --approval-mode, and --core-tools are daemon-owned permission
+// flags; users may not disable bypass mode or narrow the core tool registry
+// from custom_args (use --exclude-tools to hard-deny specific tools instead).
var qwenBlockedArgs = map[string]blockedArgMode{
"-p": blockedWithValue,
"--prompt": blockedWithValue,
@@ -37,6 +40,10 @@ var qwenBlockedArgs = map[string]blockedArgMode{
"--chat-recording": blockedWithValue,
"--mcp-config": blockedWithValue,
"--safe-mode": blockedStandalone,
+ "--yolo": blockedStandalone,
+ "-y": blockedStandalone,
+ "--approval-mode": blockedWithValue,
+ "--core-tools": blockedWithValue,
}
func buildQwenArgs(prompt string, opts ExecOptions, logger *slog.Logger) []string {
@@ -47,6 +54,11 @@ func buildQwenArgs(prompt string, opts ExecOptions, logger *slog.Logger) []strin
if opts.ResumeSessionID != "" {
args = append(args, "--resume", opts.ResumeSessionID)
}
+ // --yolo is daemon-owned: Qwen Code's non-interactive mode filters out
+ // approval-requiring tools (run_shell_command, edit, write_file, etc.)
+ // unless bypass mode is active. All other adapters use an equivalent
+ // mechanism; this keeps Qwen headless runs consistent (MUL-5134).
+ args = append(args, "--yolo")
args = append(args, filterCustomArgs(opts.ExtraArgs, qwenBlockedArgs, logger)...)
args = append(args, filterCustomArgs(opts.CustomArgs, qwenBlockedArgs, logger)...)
return args
diff --git a/server/pkg/agent/qwen_test.go b/server/pkg/agent/qwen_test.go
index 3e1fd6876c..f4609a6307 100644
--- a/server/pkg/agent/qwen_test.go
+++ b/server/pkg/agent/qwen_test.go
@@ -32,10 +32,12 @@ func TestBuildQwenArgsKeepsProtocolManaged(t *testing.T) {
CustomArgs: []string{
"--prompt=replace", "-o", "json", "--model", "other", "--resume", "other-session",
"--safe-mode", "--chat-recording", "false", "--mcp-config", "injected-mcp.json", "--mcp-config=inline-mcp.json", "--debug",
+ "--yolo", "-y", "--approval-mode", "default", "--core-tools", "write_file", "--core-tools=run_shell_command",
+ "--allowed-tools", "read_file", "--exclude-tools", "monitor",
},
}, slog.Default())
joined := strings.Join(args, " ")
- for _, forbidden := range []string{"text", "replace", "other-session", "other", "--safe-mode", "--chat-recording", "injected-mcp.json", "inline-mcp.json"} {
+ for _, forbidden := range []string{"text", "replace", "other-session", "other", "--safe-mode", "--chat-recording", "injected-mcp.json", "inline-mcp.json", "default", "write_file", "run_shell_command"} {
if strings.Contains(joined, forbidden) {
t.Fatalf("managed argument %q leaked into %v", forbidden, args)
}
@@ -49,9 +51,25 @@ func TestBuildQwenArgsKeepsProtocolManaged(t *testing.T) {
t.Fatalf("args[%d] = %q, want %q; all=%v", i, args[i], want, args)
}
}
- if !strings.Contains(joined, "--sandbox") || !strings.Contains(joined, "--debug") {
+ if !strings.Contains(joined, "--sandbox") || !strings.Contains(joined, "--debug") ||
+ !strings.Contains(joined, "--allowed-tools read_file") || !strings.Contains(joined, "--exclude-tools monitor") {
t.Fatalf("non-managed custom args missing from %v", args)
}
+ // daemon-owned --yolo must be present; user's --yolo/-y must be stripped so
+ // it appears exactly once regardless of what custom_args contain.
+ if count := strings.Count(joined, "--yolo"); count != 1 {
+ t.Fatalf("--yolo count = %d in %v, want exactly 1 (daemon-owned)", count, args)
+ }
+}
+
+func TestBuildQwenArgsYoloAlwaysPresent(t *testing.T) {
+ t.Parallel()
+ // --yolo must be injected even when custom_args is empty: Qwen's
+ // non-interactive mode otherwise filters out shell, edit, and write tools.
+ args := buildQwenArgs("task", ExecOptions{}, slog.Default())
+ if !strings.Contains(strings.Join(args, " "), "--yolo") {
+ t.Fatalf("--yolo missing from base args %v", args)
+ }
}
func fakeQwenScript() string {