qwen-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

qwen-agent

qwen-agent

Offload menial, self-contained tasks to a Qwen model running inside a headless Claude Code instance (
claude-9arm
). Keeps expensive Claude reasoning for work that needs it.
繁琐、独立的任务交给在无头Claude Code实例(
claude-9arm
)中运行的Qwen模型。让昂贵的Claude推理能力用于真正需要它的工作。

The command

命令

claude-9arm
is a shell alias →
claude --model qwen3.6-35b-a3b
routed through the 9arm gateway. Run it headless with
-p
:
bash
claude-9arm -p "<self-contained task prompt>" --allowedTools Bash Read Edit Write Glob Grep
  • This is the default invocation. The flag list scopes which tools the subagent may use without a prompt, so it can finish a menial job unattended. Without it the subagent stalls waiting for approval on the first edit or command.
  • The alias bakes in
    --allowedTools '*'
    , which Claude Code silently ignores with a warning (
    Wildcard tool name "*" is not supported
    ). That warning is expected and harmless — the
    --allowedTools
    you append is what takes effect.
  • For edit-only, lower-risk tasks you may instead use
    --permission-mode acceptEdits
    (auto-accepts file edits, but Bash still prompts — don't use it for verification/build/test runs).
claude-9arm
是一个Shell别名 → 通过9arm网关路由到
claude --model qwen3.6-35b-a3b
。使用
-p
参数以无头模式运行:
bash
claude-9arm -p "<self-contained task prompt>" --allowedTools Bash Read Edit Write Glob Grep
  • 这是默认调用方式。标志列表限定了子代理无需提示即可使用的工具,这样它就能无人值守地完成繁琐任务。如果没有这个列表,子代理会在第一次编辑或命令时停滞等待批准。
  • 该别名内置了
    --allowedTools '*'
    ,但Claude Code会静默忽略并给出警告(
    Wildcard tool name "*" is not supported
    )。这个警告是预期且无害的——你附加的
    --allowedTools
    才会生效。
  • 对于仅编辑、低风险的任务,你可以改用
    --permission-mode acceptEdits
    (自动接受文件编辑,但Bash仍会提示——不要用于验证/构建/测试运行)。

Writing the task prompt (most important step)

编写任务提示(最重要的步骤)

The qwen subagent has zero context from this conversation. A vague prompt is the #1 failure mode. Every prompt must be standalone:
  • Absolute paths for every input and output file (
    /Users/tpatinya/proj/src/foo.ts
    , not
    foo.ts
    ).
  • Explicit inputs, outputs, and acceptance criteria — what to change, what "done" looks like.
  • No references to "the file we discussed", "above", or prior turns.
  • Treat qwen as a capable-but-literal junior: spell out the steps, keep scope tight.
Bad:
clean up the imports
Good:
In /Users/tpatinya/proj/src/api.ts, remove unused imports and sort the remaining import statements alphabetically. Do not change any other code. Confirm the file still parses.
qwen子代理完全没有本次对话的上下文。模糊的提示是导致失败的头号原因。每个提示必须是独立的:
  • 每个输入和输出文件都使用绝对路径
    /Users/tpatinya/proj/src/foo.ts
    ,而不是
    foo.ts
    )。
  • 明确输入、输出和验收标准——要修改什么,“完成”的标准是什么。
  • 不要引用“我们讨论过的文件”、“上面”或之前的对话内容。
  • 把qwen当作能力尚可但字面执行的初级开发者:详细列出步骤,保持范围紧凑。
错误示例:
clean up the imports
(清理导入) 正确示例:
In /Users/tpatinya/proj/src/api.ts, remove unused imports and sort the remaining import statements alphabetically. Do not change any other code. Confirm the file still parses.
(在/Users/tpatinya/proj/src/api.ts中,移除未使用的导入并将剩余的导入语句按字母顺序排序。不要修改任何其他代码。确认文件仍能正常解析。)

Mind the context window (128k)

注意上下文窗口(128k)

Qwen runs with a 128k-token context window — much smaller than Claude's. The whole job (your prompt + every file it reads + its own reasoning and edits) has to fit inside it. Size each delegated task to the model, not just to "is it menial":
  • Estimate the footprint before delegating: roughly the bytes of files it must read + open + write, ÷ 4 ≈ tokens. If a single task would pull in large files or many files at once, it won't fit.
  • Break large jobs into independent chunks that each touch a bounded slice — e.g. one file (or a few small ones) per run, one directory per run, one log segment per run. Run the chunks as separate
    claude-9arm
    invocations (foreground, or background-parallel per the Return contract section).
  • Don't make it read what it doesn't need. Point it at the exact files/paths required; never tell it to "scan the repo" or read a whole large tree.
  • Watch for context-exhaustion symptoms when verifying: truncated edits, ignored later instructions, or a summary that omits files it was told to touch usually mean the task overflowed — split it smaller and retry.
When a job is inherently too big to slice cleanly (it needs whole-codebase context to do correctly), that's a sign it isn't a qwen task — keep it yourself.
Qwen运行在128k令牌的上下文窗口中——比Claude的小得多。整个任务(你的提示 + 它读取的每个文件 + 它自己的推理和编辑)必须容纳在这个窗口内。要根据模型的能力来调整每个委托任务的大小,而不仅仅是看“是否繁琐”:
  • 委托前估算占用量:大致计算它必须读取、打开、写入的文件字节数 ÷4 ≈ 令牌数。如果单个任务会引入大文件或同时处理多个文件,可能无法容纳。
  • 将大型任务拆分为独立的块,每个块只处理有限的部分——例如每次运行处理一个文件(或几个小文件)、一个目录、一段日志。将这些块作为单独的
    claude-9arm
    调用运行(前台运行,或根据“返回约定”部分后台并行运行)。
  • 不要让它读取不需要的内容。指向它所需的确切文件/路径;永远不要让它“扫描仓库”或读取整个大型目录树。
  • 验证时注意上下文耗尽的症状:截断的编辑、忽略后续指令,或总结中遗漏了它被告知要处理的文件,通常意味着任务超出了上下文窗口——将其拆分为更小的任务并重试。
如果某个任务本质上太大而无法清晰拆分(它需要整个代码库的上下文才能正确完成),这表明它不适合交给qwen处理——你自己来做。

Working directory

工作目录

The Bash tool's
cd
resets between calls and
cd &&
can trip permission prompts. Don't rely on cwd:
  • Put absolute paths in the prompt, or
  • Pass
    --add-dir /abs/path
    to grant the subagent access to a directory.
Bash工具的
cd
命令在每次调用后会重置,
cd &&
可能会触发权限提示。不要依赖当前工作目录:
  • 在提示中使用绝对路径,或者
  • 传递
    --add-dir /abs/path
    以授予子代理访问某个目录的权限。

Return contract

返回约定

  • Default (text): qwen's final message prints to stdout — read it directly.
  • Need to parse the result: add
    --output-format json
    and extract the
    result
    field.
  • Background / parallel (run several at once): redirect to a log and run with the Bash tool's
    run_in_background: true
    , then read the log when it finishes:
    bash
    claude-9arm -p "<task>" --allowedTools Bash Read Edit Write Glob Grep > /tmp/qwen-<label>.log 2>&1
    Launch independent tasks as separate background runs; collect each log on completion. Use this when delegating 2+ unrelated menial jobs.
  • 默认(文本):qwen的最终消息会打印到标准输出——直接读取即可。
  • 需要解析结果:添加
    --output-format json
    并提取
    result
    字段。
  • 后台/并行(同时运行多个任务):重定向到日志文件并使用Bash工具的
    run_in_background: true
    运行,完成后读取日志:
    bash
    claude-9arm -p "<task>" --allowedTools Bash Read Edit Write Glob Grep > /tmp/qwen-<label>.log 2>&1
    将独立任务作为单独的后台运行启动;完成后收集每个日志。当委托2个或更多不相关的繁琐任务时使用此方法。

Workflow checklist

工作流程检查清单

  1. Confirm the task is menial and low-risk (see description). If it needs design judgment or this chat's context, do it yourself — don't delegate.
  2. Check it fits qwen's 128k context window — estimate the file footprint and split large jobs into bounded per-file/per-dir chunks (see "Mind the context window").
  3. Write a fully self-contained prompt with absolute paths and acceptance criteria.
  4. Run
    claude-9arm -p "..." --allowedTools Bash Read Edit Write Glob Grep
    (foreground), or background-redirect for parallel jobs.
  5. Verify the output yourself — qwen is cheaper and less reliable. Check the file/result actually meets the acceptance criteria before reporting success.
  1. 确认任务是繁琐且低风险的(参见描述)。如果需要设计判断或本次聊天的上下文,自己处理——不要委托。
  2. 检查它是否适合qwen的128k上下文窗口——估算文件占用量并将大型任务拆分为有限的按文件/按目录的块(参见“注意上下文窗口”)。
  3. 编写一个完全独立的提示,包含绝对路径和验收标准。
  4. 运行
    claude-9arm -p "..." --allowedTools Bash Read Edit Write Glob Grep
    (前台运行),或重定向到后台以并行运行任务。
  5. 自行验证输出——qwen更便宜但可靠性更低。在报告成功之前,检查文件/结果是否确实符合验收标准。

One-time setup (optional, removes repeated prompts)

一次性设置(可选,消除重复提示)

To stop per-call permission prompts on delegated runs, add a Bash allow rule for the command (via the
update-config
skill, or by editing settings):
json
{ "permissions": { "allow": ["Bash(claude-9arm:*)"] } }
要在委托运行时取消每次调用的权限提示,为该命令添加一个Bash允许规则(通过
update-config
技能,或编辑设置):
json
{ "permissions": { "allow": ["Bash(claude-9arm:*)"] } }

When NOT to delegate

不要委托的情况

Architecture/design, debugging that needs reasoning, security-sensitive changes, anything requiring this conversation's context, or tasks where a wrong cheap-model edit is costly to catch. When in doubt, keep it.
架构/设计、需要推理的调试、安全敏感的更改、任何需要本次对话上下文的内容,或者错误的廉价模型编辑会导致高昂修复成本的任务。如有疑问,自己处理。