Worker Internal Workflow
Use this skill before splitting work inside a single Worker. WorkerFlow is not
TeamHarness delegation.
Decision
| Need |
Path |
| Current Worker can do it directly |
No subagent |
| Same Worker needs short parallel inspection |
QwenPaw native subagent |
Same Worker needs visible fan-out to custom roles, workspaces, AGENTS.md, or skills |
Dynamic workflow via worker_agentflow workflow_run |
| Same Worker needs one manually controlled temporary subagent |
create_temp_agent directly |
| Work needs a persistent team member or Leader acceptance |
Do not use WorkerFlow; use the team workflow |
Native Subagent
Use QwenPaw native subagents for short internal parallelism. The current Worker
still owns the final result.
Do not create a temporary agent when no custom prompt, workspace, or skill set
is required.
Temporary QwenPaw Agent
Use worker_agentflow with workflow_run when a custom AgentSpec-style
template has already been placed in the default QwenPaw workspace:
<QWENPAW_WORKING_DIR>/workspaces/default/subagents/<role>/
AGENTS.md
PROFILE.md # optional
SOUL.md # optional
skills/
<skill-id>/
SKILL.md
Use list_subagents first when you need to discover the templates available in
the default workspace. Use create_temp_agent directly only when you need
manual control outside a dynamic workflow.
Subagent template rules:
AGENTS.md should tell the temporary agent to begin analysis immediately.
AGENTS.md should forbid greetings, self-introductions, and capability
summaries.
AGENTS.md should define the subagent's focus area so the Worker can send the
complete source input instead of manually slicing the input.
- When multiple subagent results will be merged, each
AGENTS.md should require
the same fixed output shape.
Dynamic workflow lifecycle:
- Call
workflow_run with the explicit current DM/conversation roomId,
title, source input, optional merge.instruction, and either
subagents or DAG nodes.
- Each subagent or node must name a default-workspace template with
subagent
and a bounded task.
workflow_run starts the Matrix card, creates tmp-... subagents, creates the
run-level shared directory, stores workflow.json, and returns
submitInstructions for nodes that are ready now.
- Send each returned
submitPrompt to its agentId using the available
QwenPaw agent communication tools.
- When a subagent finishes, call
workflow_update with a steps row whose
id matches the node id, status is done, and summary contains the
short result.
- For DAG
nodes, inspect every workflow_update response. If it returns
readyInstructions, immediately send each returned submitPrompt to its
agentId.
- Use
workflow_update at meaningful phase changes: submitted, running,
retrying, merging, cleanup, done, or failed.
- Retry a timed-out subagent once when the task is still useful.
- Mark subagents that still fail as missing or failed in the merged result.
- Merge subagent results into the current Worker's own output.
- Delete every temporary agent with
delete_temp_agent.
- Call
workflow_finish or workflow_fail.
- After merging, either keep the shared run directory as evidence or remove it
with
cleanup_shared.
Example workflow_run input:
{
"action": "workflow_run",
"roomId": "!current-dm:example.test",
"runId": "run-review-auth",
"title": "Review auth module",
"input": "Review auth.py for this task...",
"subagents": [
{
"id": "security",
"subagent": "security-reviewer",
"task": "Check authentication and authorization risks."
},
{
"id": "tests",
"subagent": "test-reviewer",
"task": "Check test coverage gaps."
}
],
"merge": {
"instruction": "Return one severity-ordered finding list."
}
}
DAG nodes example:
{
"action": "workflow_run",
"roomId": "!current-dm:example.test",
"runId": "pig-diagnosis-b001",
"title": "猪病诊断报告生成",
"input": "批次号 B001 的猪病诊断请求...",
"nodes": [
{
"id": "base_info",
"name": "基础信息梳理",
"role": "基础信息梳理",
"subagent": "base-info-agent",
"task": "处理基础信息。"
},
{
"id": "feed_cough",
"name": "采食与咳喘指标",
"role": "采食与咳喘指标",
"subagent": "feed-cough-agent",
"task": "分析采食及咳嗽波动。"
},
{
"id": "pathogen",
"name": "病原线索分析",
"role": "病原线索分析",
"subagent": "pathogen-agent",
"task": "分析病原及亚型。"
},
{
"id": "disease_analysis",
"name": "疾病综合研判",
"role": "疾病综合研判",
"subagent": "disease-analysis-agent",
"task": "综合基础信息、采食咳嗽和病原结果,判断猪病。",
"dependsOn": ["base_info", "feed_cough", "pathogen"]
},
{
"id": "medication",
"name": "用药与处置措施",
"role": "用药与处置措施",
"subagent": "medication-measures-agent",
"task": "基于猪病分析生成药物及措施方案。",
"dependsOn": ["disease_analysis"]
},
{
"id": "diagnosis_advice",
"name": "诊断建议",
"role": "诊断建议",
"subagent": "diagnosis-advice-agent",
"task": "基于猪病分析生成诊断建议。",
"dependsOn": ["disease_analysis"]
},
{
"id": "report",
"name": "最终报告汇总",
"role": "最终报告汇总",
"subagent": "report-agent",
"task": "汇总上游结果生成最终诊断报告。",
"dependsOn": ["medication", "diagnosis_advice"]
}
]
}
For DAG workflows, workflow_run creates every node's temporary agent. Only
dependency-free nodes appear in submitInstructions. Dependent nodes appear in
waitingInstructions. The current Worker is the scheduler: submit ready nodes,
wait for their replies, call workflow_update with done steps, then submit
any downstream readyInstructions returned by that update. WorkerFlow uses the
done step ids as the dependency-completion signal and appends upstream summaries
to newly unblocked submit prompts.
File sharing:
- Native QwenPaw subagents share the current Worker's workspace.
- Temporary QwenPaw agents created through
/api/agents have separate
workspaces. Do not point their workspaceDir at the default workspace.
workflow_run and create_temp_agent expose a run-level shared directory:
<default-workspace>/shared/workerflow/<sharedRunId>/.
- Put input files under
shared/inputs/.
- Each subagent writes only under
shared/outputs/<agent-id>/.
- The subagent workspace contains
.workerflow/shared.json and a shared
symlink for discovery, but prompts should still include the absolute
shared.path, shared.inputs, and shared.output returned by the tool.
- Do not place the shared directory inside a temporary agent workspace, because
cleanupWorkspace may delete that workspace.
Workflow visibility:
- The current Worker is the Matrix sender for WorkerFlow workflow cards.
- Temporary agents do not send Matrix status directly.
- Prefer
workflow_run for visible multi-subagent work; it creates the first
Matrix m.notice card and records the returned eventId.
workflow_run and workflow_start require an explicit current
DM/conversation roomId.
WorkerFlow does not fallback to Team Room or personal room.
- Use
workflow_update, workflow_finish, and workflow_fail to edit the same
card through Matrix m.replace.
- The card state is also stored in
<default-workspace>/shared/workerflow/<run-id>/workflow.json.
- Show phase-level changes only: spawning subagents, running, retrying, merging,
cleanup, done, or failed.
- Do not expose full prompts, secrets, raw large inputs, or tool traces in the
card. Use shared paths and short summaries.
Fan-out rules:
- Send the full source input to each subagent unless there is a clear token,
privacy, or cost reason to narrow it.
- Let each subagent extract the subset relevant to its
AGENTS.md.
- Request a fixed output shape for all subagents when the results need
programmatic or low-friction merging.
- Keep a small ledger of created temporary agent ids so cleanup can run even
when one subagent fails.
- Keep the shared run id in the same ledger when file sharing is used.
Rules:
- Temporary agents are implementation details of the current Worker.
- Always use
tmp- ids for temporary agents.
- Do not store temporary agent ids as TeamHarness workers.
- Delete temporary agents after the bounded task completes or fails; treat this
as a finally step.
- If the work must survive the current Worker run, use a durable team workflow
instead.
1---2name: workerflow-internal-workflow3description: Use when a QwenPaw-backed Worker needs to decide whether to do work directly, use native subagents for internal parallelism, or create a temporary QwenPaw agent with a custom AGENTS.md and skills.4---56# Worker Internal Workflow78Use this skill before splitting work inside a single Worker. WorkerFlow is not9TeamHarness delegation.1011## Decision1213| Need | Path |14| --- | --- |15| Current Worker can do it directly | No subagent |16| Same Worker needs short parallel inspection | QwenPaw native subagent |17| Same Worker needs visible fan-out to custom roles, workspaces, `AGENTS.md`, or skills | Dynamic workflow via `worker_agentflow` `workflow_run` |18| Same Worker needs one manually controlled temporary subagent | `create_temp_agent` directly |19| Work needs a persistent team member or Leader acceptance | Do not use WorkerFlow; use the team workflow |2021## Native Subagent2223Use QwenPaw native subagents for short internal parallelism. The current Worker24still owns the final result.2526Do not create a temporary agent when no custom prompt, workspace, or skill set27is required.2829## Temporary QwenPaw Agent3031Use `worker_agentflow` with `workflow_run` when a custom AgentSpec-style32template has already been placed in the default QwenPaw workspace:3334```text35<QWENPAW_WORKING_DIR>/workspaces/default/subagents/<role>/36 AGENTS.md37 PROFILE.md # optional38 SOUL.md # optional39 skills/40 <skill-id>/41 SKILL.md42```4344Use `list_subagents` first when you need to discover the templates available in45the default workspace. Use `create_temp_agent` directly only when you need46manual control outside a dynamic workflow.4748Subagent template rules:4950- `AGENTS.md` should tell the temporary agent to begin analysis immediately.51- `AGENTS.md` should forbid greetings, self-introductions, and capability52 summaries.53- `AGENTS.md` should define the subagent's focus area so the Worker can send the54 complete source input instead of manually slicing the input.55- When multiple subagent results will be merged, each `AGENTS.md` should require56 the same fixed output shape.5758Dynamic workflow lifecycle:59601. Call `workflow_run` with the explicit current DM/conversation `roomId`,61 `title`, source `input`, optional `merge.instruction`, and either62 `subagents` or DAG `nodes`.632. Each subagent or node must name a default-workspace template with `subagent`64 and a bounded `task`.653. `workflow_run` starts the Matrix card, creates `tmp-...` subagents, creates the66 run-level shared directory, stores `workflow.json`, and returns67 `submitInstructions` for nodes that are ready now.684. Send each returned `submitPrompt` to its `agentId` using the available69 QwenPaw agent communication tools.705. When a subagent finishes, call `workflow_update` with a `steps` row whose71 `id` matches the node id, `status` is `done`, and `summary` contains the72 short result.736. For DAG `nodes`, inspect every `workflow_update` response. If it returns74 `readyInstructions`, immediately send each returned `submitPrompt` to its75 `agentId`.767. Use `workflow_update` at meaningful phase changes: submitted, running,77 retrying, merging, cleanup, done, or failed.788. Retry a timed-out subagent once when the task is still useful.799. Mark subagents that still fail as missing or failed in the merged result.8010. Merge subagent results into the current Worker's own output.8111. Delete every temporary agent with `delete_temp_agent`.8212. Call `workflow_finish` or `workflow_fail`.8313. After merging, either keep the shared run directory as evidence or remove it84 with `cleanup_shared`.8586Example `workflow_run` input:8788```json89{90 "action": "workflow_run",91 "roomId": "!current-dm:example.test",92 "runId": "run-review-auth",93 "title": "Review auth module",94 "input": "Review auth.py for this task...",95 "subagents": [96 {97 "id": "security",98 "subagent": "security-reviewer",99 "task": "Check authentication and authorization risks."100 },101 {102 "id": "tests",103 "subagent": "test-reviewer",104 "task": "Check test coverage gaps."105 }106 ],107 "merge": {108 "instruction": "Return one severity-ordered finding list."109 }110}111```112113DAG nodes example:114115```json116{117 "action": "workflow_run",118 "roomId": "!current-dm:example.test",119 "runId": "pig-diagnosis-b001",120 "title": "猪病诊断报告生成",121 "input": "批次号 B001 的猪病诊断请求...",122 "nodes": [123 {124 "id": "base_info",125 "name": "基础信息梳理",126 "role": "基础信息梳理",127 "subagent": "base-info-agent",128 "task": "处理基础信息。"129 },130 {131 "id": "feed_cough",132 "name": "采食与咳喘指标",133 "role": "采食与咳喘指标",134 "subagent": "feed-cough-agent",135 "task": "分析采食及咳嗽波动。"136 },137 {138 "id": "pathogen",139 "name": "病原线索分析",140 "role": "病原线索分析",141 "subagent": "pathogen-agent",142 "task": "分析病原及亚型。"143 },144 {145 "id": "disease_analysis",146 "name": "疾病综合研判",147 "role": "疾病综合研判",148 "subagent": "disease-analysis-agent",149 "task": "综合基础信息、采食咳嗽和病原结果,判断猪病。",150 "dependsOn": ["base_info", "feed_cough", "pathogen"]151 },152 {153 "id": "medication",154 "name": "用药与处置措施",155 "role": "用药与处置措施",156 "subagent": "medication-measures-agent",157 "task": "基于猪病分析生成药物及措施方案。",158 "dependsOn": ["disease_analysis"]159 },160 {161 "id": "diagnosis_advice",162 "name": "诊断建议",163 "role": "诊断建议",164 "subagent": "diagnosis-advice-agent",165 "task": "基于猪病分析生成诊断建议。",166 "dependsOn": ["disease_analysis"]167 },168 {169 "id": "report",170 "name": "最终报告汇总",171 "role": "最终报告汇总",172 "subagent": "report-agent",173 "task": "汇总上游结果生成最终诊断报告。",174 "dependsOn": ["medication", "diagnosis_advice"]175 }176 ]177}178```179180For DAG workflows, `workflow_run` creates every node's temporary agent. Only181dependency-free nodes appear in `submitInstructions`. Dependent nodes appear in182`waitingInstructions`. The current Worker is the scheduler: submit ready nodes,183wait for their replies, call `workflow_update` with done `steps`, then submit184any downstream `readyInstructions` returned by that update. WorkerFlow uses the185done step ids as the dependency-completion signal and appends upstream summaries186to newly unblocked submit prompts.187188File sharing:189190- Native QwenPaw subagents share the current Worker's workspace.191- Temporary QwenPaw agents created through `/api/agents` have separate192 workspaces. Do not point their `workspaceDir` at the default workspace.193- `workflow_run` and `create_temp_agent` expose a run-level shared directory:194 `<default-workspace>/shared/workerflow/<sharedRunId>/`.195- Put input files under `shared/inputs/`.196- Each subagent writes only under `shared/outputs/<agent-id>/`.197- The subagent workspace contains `.workerflow/shared.json` and a `shared`198 symlink for discovery, but prompts should still include the absolute199 `shared.path`, `shared.inputs`, and `shared.output` returned by the tool.200- Do not place the shared directory inside a temporary agent workspace, because201 `cleanupWorkspace` may delete that workspace.202203Workflow visibility:204205- The current Worker is the Matrix sender for WorkerFlow workflow cards.206- Temporary agents do not send Matrix status directly.207- Prefer `workflow_run` for visible multi-subagent work; it creates the first208 Matrix `m.notice` card and records the returned `eventId`.209- `workflow_run` and `workflow_start` require an explicit current210 DM/conversation `roomId`.211 WorkerFlow does not fallback to Team Room or personal room.212- Use `workflow_update`, `workflow_finish`, and `workflow_fail` to edit the same213 card through Matrix `m.replace`.214- The card state is also stored in215 `<default-workspace>/shared/workerflow/<run-id>/workflow.json`.216- Show phase-level changes only: spawning subagents, running, retrying, merging,217 cleanup, done, or failed.218- Do not expose full prompts, secrets, raw large inputs, or tool traces in the219 card. Use shared paths and short summaries.220221Fan-out rules:222223- Send the full source input to each subagent unless there is a clear token,224 privacy, or cost reason to narrow it.225- Let each subagent extract the subset relevant to its `AGENTS.md`.226- Request a fixed output shape for all subagents when the results need227 programmatic or low-friction merging.228- Keep a small ledger of created temporary agent ids so cleanup can run even229 when one subagent fails.230- Keep the shared run id in the same ledger when file sharing is used.231232Rules:233234- Temporary agents are implementation details of the current Worker.235- Always use `tmp-` ids for temporary agents.236- Do not store temporary agent ids as TeamHarness workers.237- Delete temporary agents after the bounded task completes or fails; treat this238 as a finally step.239- If the work must survive the current Worker run, use a durable team workflow240 instead.