qwen-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseqwen-agent
qwen-agent
Offload menial, self-contained tasks to a Qwen model running inside a headless Claude Code instance (). Keeps expensive Claude reasoning for work that needs it.
claude-9arm将繁琐、独立的任务交给在无头Claude Code实例()中运行的Qwen模型。让昂贵的Claude推理能力用于真正需要它的工作。
claude-9armThe command
命令
claude-9armclaude --model qwen3.6-35b-a3b-pbash
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 , which Claude Code silently ignores with a warning (
--allowedTools '*'). That warning is expected and harmless — theWildcard tool name "*" is not supportedyou append is what takes effect.--allowedTools - For edit-only, lower-risk tasks you may instead use (auto-accepts file edits, but Bash still prompts — don't use it for verification/build/test runs).
--permission-mode acceptEdits
claude-9armclaude --model qwen3.6-35b-a3b-pbash
claude-9arm -p "<self-contained task prompt>" --allowedTools Bash Read Edit Write Glob Grep- 这是默认调用方式。标志列表限定了子代理无需提示即可使用的工具,这样它就能无人值守地完成繁琐任务。如果没有这个列表,子代理会在第一次编辑或命令时停滞等待批准。
- 该别名内置了,但Claude Code会静默忽略并给出警告(
--allowedTools '*')。这个警告是预期且无害的——你附加的Wildcard tool name "*" is not supported才会生效。--allowedTools - 对于仅编辑、低风险的任务,你可以改用(自动接受文件编辑,但Bash仍会提示——不要用于验证/构建/测试运行)。
--permission-mode acceptEdits
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 (, not
/Users/tpatinya/proj/src/foo.ts).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:
Good:
clean up the importsIn /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当作能力尚可但字面执行的初级开发者:详细列出步骤,保持范围紧凑。
错误示例:(清理导入)
正确示例:(在/Users/tpatinya/proj/src/api.ts中,移除未使用的导入并将剩余的导入语句按字母顺序排序。不要修改任何其他代码。确认文件仍能正常解析。)
clean up the importsIn /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.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 invocations (foreground, or background-parallel per the Return contract section).
claude-9arm - 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 resets between calls and can trip permission prompts. Don't rely on cwd:
cdcd &&- Put absolute paths in the prompt, or
- Pass to grant the subagent access to a directory.
--add-dir /abs/path
Bash工具的命令在每次调用后会重置,可能会触发权限提示。不要依赖当前工作目录:
cdcd &&- 在提示中使用绝对路径,或者
- 传递以授予子代理访问某个目录的权限。
--add-dir /abs/path
Return contract
返回约定
-
Default (text): qwen's final message prints to stdout — read it directly.
-
Need to parse the result: addand extract the
--output-format jsonfield.result -
Background / parallel (run several at once): redirect to a log and run with the Bash tool's, then read the log when it finishes:
run_in_background: truebashclaude-9arm -p "<task>" --allowedTools Bash Read Edit Write Glob Grep > /tmp/qwen-<label>.log 2>&1Launch 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: truebashclaude-9arm -p "<task>" --allowedTools Bash Read Edit Write Glob Grep > /tmp/qwen-<label>.log 2>&1将独立任务作为单独的后台运行启动;完成后收集每个日志。当委托2个或更多不相关的繁琐任务时使用此方法。
Workflow checklist
工作流程检查清单
- 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.
- 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").
- Write a fully self-contained prompt with absolute paths and acceptance criteria.
- Run (foreground), or background-redirect for parallel jobs.
claude-9arm -p "..." --allowedTools Bash Read Edit Write Glob Grep - Verify the output yourself — qwen is cheaper and less reliable. Check the file/result actually meets the acceptance criteria before reporting success.
- 确认任务是繁琐且低风险的(参见描述)。如果需要设计判断或本次聊天的上下文,自己处理——不要委托。
- 检查它是否适合qwen的128k上下文窗口——估算文件占用量并将大型任务拆分为有限的按文件/按目录的块(参见“注意上下文窗口”)。
- 编写一个完全独立的提示,包含绝对路径和验收标准。
- 运行(前台运行),或重定向到后台以并行运行任务。
claude-9arm -p "..." --allowedTools Bash Read Edit Write Glob Grep - 自行验证输出——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 skill, or by editing settings):
update-configjson
{ "permissions": { "allow": ["Bash(claude-9arm:*)"] } }要在委托运行时取消每次调用的权限提示,为该命令添加一个Bash允许规则(通过技能,或编辑设置):
update-configjson
{ "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.
架构/设计、需要推理的调试、安全敏感的更改、任何需要本次对话上下文的内容,或者错误的廉价模型编辑会导致高昂修复成本的任务。如有疑问,自己处理。