From 843974a58dbae2818376159bad86b766b4c4a913 Mon Sep 17 00:00:00 2001 From: Emil Shanaty Date: Wed, 28 Oct 2026 00:33:08 +0300 Subject: [PATCH] Prune agent-swarm to a genuinely lite core --- README.md | 6 +- agent-swarm/README.ru.md | 6 +- agent-swarm/SKILL.md | 11 +- agent-swarm/assets/brief.md.tmpl | 71 ------ agent-swarm/assets/prerequisites.md.tmpl | 30 --- agent-swarm/assets/report.schema.json | 52 ----- agent-swarm/assets/task.md.tmpl | 52 ----- agent-swarm/assets/verdict.schema.json | 10 - agent-swarm/assets/verifier.md.tmpl | 55 ----- agent-swarm/assets/verify.workflow.js | 88 -------- agent-swarm/assets/wave.workflow.js | 100 --------- agent-swarm/references/orchestration.md | 211 ------------------ agent-swarm/references/packets.md | 150 ------------- agent-swarm/references/playbook.md | 264 ----------------------- agent-swarm/references/token-economy.md | 106 --------- 15 files changed, 5 insertions(+), 1207 deletions(-) delete mode 100644 agent-swarm/assets/brief.md.tmpl delete mode 100644 agent-swarm/assets/prerequisites.md.tmpl delete mode 100644 agent-swarm/assets/report.schema.json delete mode 100644 agent-swarm/assets/task.md.tmpl delete mode 100644 agent-swarm/assets/verdict.schema.json delete mode 100644 agent-swarm/assets/verifier.md.tmpl delete mode 100644 agent-swarm/assets/verify.workflow.js delete mode 100644 agent-swarm/assets/wave.workflow.js delete mode 100644 agent-swarm/references/orchestration.md delete mode 100644 agent-swarm/references/packets.md delete mode 100644 agent-swarm/references/playbook.md delete mode 100644 agent-swarm/references/token-economy.md diff --git a/README.md b/README.md index 13f8cbb..3742eed 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,7 @@ product acceptance. Тяжёлые темы вынесены в опционал - [Описание на русском](agent-swarm/README.ru.md) - [Инструкции скилла](agent-swarm/SKILL.md) -- [Runbook](agent-swarm/references/playbook.md) -- [Cookbook по `workflow`](agent-swarm/references/orchestration.md) - [Domain-адаптеры](agent-swarm/references/domains.md) -- [Token economy](agent-swarm/references/token-economy.md) - [Prerequisite gate](agent-swarm/references/prerequisites.md) - [Product quality gates](agent-swarm/references/product-quality.md) - [Изолированное визуальное тестирование](agent-swarm/references/visual-testing.md) @@ -37,7 +34,6 @@ agent-swarm/ ├── SKILL.md # тонкий core: режимы + инварианты ├── README.ru.md # краткое описание ├── evals/ # baseline vs with-skill, 3 задачи, scorecard -├── references/ # опциональные модули: playbook, packets, domains, quality, tokens... -├── assets/ # шаблоны, схемы, workflow-скрипты +├── references/ # только domains, prerequisites, product quality, visual testing └── scripts/audit-scope.mjs # проверка ownership ``` diff --git a/agent-swarm/README.ru.md b/agent-swarm/README.ru.md index 73e46be..5f48615 100644 --- a/agent-swarm/README.ru.md +++ b/agent-swarm/README.ru.md @@ -68,20 +68,16 @@ implementer + один critic обычно дают более цельный UI Читать только по необходимости: -- `references/playbook.md` — подробный runbook для больших swarm. -- `references/packets.md` — шаблоны brief/task/verifier. -- `references/orchestration.md` — `workflow`, батчи, ретраи. - `references/domains.md` — адаптеры для кода/research/контента/данных/дизайна/ops. - `references/prerequisites.md` — preflight и политика установки. -- `references/token-economy.md` — бюджеты, контекст, delta-review. - `references/visual-testing.md` — изолированные display, скриншоты, computer-use. - `references/product-quality.md` — performance/UX/baseline/human acceptance. - `evals/` — как проверять сам скилл (baseline vs with-skill). ## Настройка -- Шаблоны: `assets/`. - Проверка скоупа: `node scripts/audit-scope.mjs --init` перед стартом, затем `node scripts/audit-scope.mjs`. +- Для swarm пишите brief/tasks сами; обязательных шаблонов больше нет. - Для директорий в `plan.json` используйте glob `path/**`, включая ещё не созданные папки. - Перед изменением скилла прочитайте `evals/README.md`; не считайте, что новая версия лучше старой без сравнения. diff --git a/agent-swarm/SKILL.md b/agent-swarm/SKILL.md index aa73c76..8e66c2b 100644 --- a/agent-swarm/SKILL.md +++ b/agent-swarm/SKILL.md @@ -71,21 +71,16 @@ Optional, for resumability and coordination — not a requirement for every task - `.swarm/reports/Txx.json` — structured evidence, if the lead needs to triage many workers; - `.swarm/reviews/Vxx.md` — independent verdict and findings. -Use the batched runner in `assets/wave.workflow.js` when `workflow` exists; otherwise use `subagent` -or direct sequential work. Never relaunch an oversubscribed fan-out. Read `references/playbook.md` -for the detailed runbook, `references/packets.md` for cards and `references/orchestration.md` for -tool specifics — only when the task needs them. +Use the available concurrency directly. If `workflow`/`subagent` is unavailable, work sequentially with +the same brief and scopes; never relaunch an oversubscribed fan-out. There are no mandatory templates: +write a one-page brief and cards yourself, or use the bundled `evals/` only to test the skill. ## Optional modules Read only what applies: -- `references/playbook.md` — detailed swarm runbook, gates, recovery. -- `references/packets.md` — brief/task/verifier templates and examples. -- `references/orchestration.md` — `workflow` patterns, retries, batching. - `references/domains.md` — software, research, content, data, design, operations. - `references/prerequisites.md` — preflight, install/approval policy. -- `references/token-economy.md` — budgets, context discipline, delta review. - `references/visual-testing.md` — isolated displays, screenshots, computer-use limits. - `references/product-quality.md` — performance/UX/baseline/human acceptance. - `evals/` — how to test this skill itself (baseline vs with-skill, trigger checks). diff --git a/agent-swarm/assets/brief.md.tmpl b/agent-swarm/assets/brief.md.tmpl deleted file mode 100644 index d277d2a..0000000 --- a/agent-swarm/assets/brief.md.tmpl +++ /dev/null @@ -1,71 +0,0 @@ -# Swarm brief — {{TASK}} - -## Goal -{{One paragraph. What must exist when the swarm is done.}} - -## Success criteria -- [ ] {{Criterion}} — verified by {{check, command, artifact or citation}} -- [ ] {{Criterion}} — verified by {{check, command, artifact or citation}} - -Scope is checked by the lead with the skill's `scripts/audit-scope.mjs`; workers do not run it. - -## Non-goals -- {{What must not change or be attempted.}} - -## Quality profile -- Profile: {{prototype / product}} -- Performance budget: {{p95 frame time / latency / startup / memory, or n/a}} -- Baseline version/scenarios: {{version + 3–5 step scenario, or none}} -- User acceptance owner: {{name / pending}} -- Release build command: {{command or n/a}} - -## Domain profile -- Domain: {{software / research / content / data / design / operations}} -- Primary artifacts: {{paths, sections, datasets, renders, services}} -- Evidence type: {{command / artifact / citation / metric / render}} -- Evidence commands or sources: {{commands, URLs, access notes}} -- Approval boundaries: {{what needs human confirmation}} - -## Stack and commands (when applicable) -| Action | Command | -|---|---| -| build | `{{command or n/a}}` | -| test | `{{command or n/a}}` | -| lint | `{{command or n/a}}` | -| run | `{{command or n/a}}` | -| evidence | `{{screenshot/citation/metric command}}` | - -## Artifact / source map -| Path, source or artifact | Role | -|---|---| -| `{{path/url/artifact}}` | {{one line}} | - -## Conventions and invariants -- {{Naming, error handling, test style, formatting.}} -- {{Data or API invariants that must not break.}} - -## Hazards -- {{Generated files, migrations, flaky tests, shared ports, secrets, caches.}} -- {{Generated or vendored paths that must not be edited.}} - -## Prerequisites -- Status: {{passed / needs_user / degraded}} -- Details: `.swarm/prerequisites.md` -- Missing/blocked: {{items or none}} -- User approval: {{approved/declined/pending}} - -## Token / effort budget -- Hard budget: {{tokens or n/a}}; reserve {{20–30%}} for verification and integration. -- Prefer vertical slices and files under ~800 lines. -- Workers read the listed inputs/ranges, not the whole repository. - -## Frozen contracts -See `.swarm/contracts.md`. Do not change an interface without returning `blocked`. - -## Global forbidden actions -- No installs, repo-wide format/lint/codegen, migrations, deployments, external publishes, dev servers, or git writes without explicit scope. -- No edits outside your task's write scope. -- Do not edit `.swarm/brief.md`, `plan.*`, `contracts.md`, or another task's files or reports. - -## Reporting -Write `.swarm/reports/{{ID}}.json` and return the same object. Use `.swarm/report.schema.json`. diff --git a/agent-swarm/assets/prerequisites.md.tmpl b/agent-swarm/assets/prerequisites.md.tmpl deleted file mode 100644 index 24bc11e..0000000 --- a/agent-swarm/assets/prerequisites.md.tmpl +++ /dev/null @@ -1,30 +0,0 @@ -# Prerequisites — {{TASK}} - -Checked before dispatch. Do not print secrets. - -## Required - -| Item | Check command | Status | Version / error | Owner | -|---|---|---|---|---| -| {{tool/runtime}} | `{{command}}` | {{pass/missing/needs_user}} | {{version or exact error}} | lead | - -## Optional / degraded - -| Item | Check | Impact if missing | Decision | -|---|---|---|---| -| {{display/GPU/service}} | `{{command}}` | {{reduced scope}} | {{skip/ask/install}} | - -## User approval - -- Missing item: {{name}} -- Why required: {{acceptance check}} -- Proposed command/scope: `{{command}}` ({{project-local/user/system}}) -- Alternatives: {{existing path / reduced scope / stop}} -- User decision: {{pending/approved/declined}} -- Recorded in `state.json`: {{passed/needs_user/degraded}} - -## Baseline - -- Build: `{{command}}` → {{result}} -- Tests: `{{command}}` → {{result}} -- Visual/smoke: `{{command}}` → {{result}} diff --git a/agent-swarm/assets/report.schema.json b/agent-swarm/assets/report.schema.json deleted file mode 100644 index fa43ce3..0000000 --- a/agent-swarm/assets/report.schema.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "type": "object", - "properties": { - "task_id": { "type": "string" }, - "status": { - "type": "string", - "enum": ["done", "partial", "blocked", "failed"] - }, - "verdict": { - "type": "string", - "enum": ["pass", "pass_with_risks", "fail"] - }, - "summary": { "type": "string" }, - "files_changed": { - "type": "array", - "items": { "type": "string" } - }, - "acceptance": { - "type": "array", - "items": { - "type": "object", - "properties": { - "check": { "type": "string" }, - "result": { "type": "string", "enum": ["pass", "fail", "not_run"] }, - "evidence": { "type": "string" } - }, - "required": ["check", "result"] - } - }, - "evidence": { - "type": "array", - "items": { "type": "string" } - }, - "issues": { - "type": "array", - "items": { "type": "string" } - }, - "assumptions": { - "type": "array", - "items": { "type": "string" } - }, - "blocked_question": { "type": "string" } - }, - "required": [ - "task_id", - "status", - "summary", - "files_changed", - "evidence", - "acceptance" - ] -} diff --git a/agent-swarm/assets/task.md.tmpl b/agent-swarm/assets/task.md.tmpl deleted file mode 100644 index c4a4e73..0000000 --- a/agent-swarm/assets/task.md.tmpl +++ /dev/null @@ -1,52 +0,0 @@ -# {{ID}} — {{title}} - -Role: worker | Wave: {{n}} | Depends on: {{ids or —}} | Effort: {{S/M/L}} - -## Objective -{{1–3 sentences. What must exist when done.}} - -## Why -{{Which success criterion this serves.}} - -## Inputs (read first) -- `.swarm/brief.md` -- `.swarm/contracts.md` §{{section}} -- `{{artifact/source}}`: {{path:start-end, URL, dataset, design file}} - -## Deliverables -- `{{new or changed path/artifact}}` — {{what}} -- `{{test/evidence artifact}}` — {{what it proves}} - -## Write scope (only these) -- `{{glob or exact path}}` - -## Read-only -- `{{path}}` - -## Contract -{{Exact signature, data shape, CLI behavior, or output format.}} - -## Constraints -- {{No new dependencies, style, performance, compatibility.}} -- Context budget: read only the inputs above; if you need more than {{N}} additional files, return `blocked` instead of exploring the whole repo. -- Prerequisites are lead-owned: do not install tools, packages or system dependencies. If one is missing, return `blocked` with the exact check and error. -- Do not run the full test suite unless the card explicitly asks; run targeted checks. - -## Acceptance (re-runnable) -1. `{{command or artifact path}}` → {{expected result/state}} -2. `{{citation check / metric / render at sizes}}` → {{expected result}} -3. Every criterion must have evidence a fresh verifier can reproduce. - -If the quality profile is `product` and this task touches UI/interaction, also record: -- release-build p95 frame time and input latency at the target size; -- the 3–5 step user scenario; -- baseline comparison (new must not be worse). - -## Report -`.swarm/reports/{{ID}}.json` per `.swarm/report.schema.json`; status `done|partial|blocked|failed`. -Keep the report to summary + evidence lines; raw logs go to `.swarm/tmp/{{ID}}/`. - -## Stop conditions -- Time box: 25 minutes for S/M, 45–60 minutes for L, or 3 failed attempts at the same step. -- A load-bearing unknown, a needed file outside scope, or a broken contract → `blocked` with the exact question. Do not guess. -- If a sibling task's in-flight file causes a compile/test failure outside your scope, wait briefly and report `partial` with the exact external error; never edit that file. diff --git a/agent-swarm/assets/verdict.schema.json b/agent-swarm/assets/verdict.schema.json deleted file mode 100644 index 63b26a1..0000000 --- a/agent-swarm/assets/verdict.schema.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "type": "object", - "properties": { - "task_id": { "type": "string" }, - "verdict": { "type": "string", "enum": ["pass", "pass_with_risks", "fail"] }, - "summary": { "type": "string" }, - "review_file": { "type": "string" } - }, - "required": ["task_id", "verdict", "summary", "review_file"] -} diff --git a/agent-swarm/assets/verifier.md.tmpl b/agent-swarm/assets/verifier.md.tmpl deleted file mode 100644 index 5198511..0000000 --- a/agent-swarm/assets/verifier.md.tmpl +++ /dev/null @@ -1,55 +0,0 @@ -# {{ID}} — verify {{task IDs}} - -You did not write this work. Do not fix it. Do not trust worker summaries. - -## Inputs -- Task cards: {{paths}} -- Changed files/artifacts or diff: {{paths or command}} -- Acceptance checks: {{commands, artifact paths, citations, metrics}} - -## For each criterion -| Criterion | Evidence (command/artifact/citation/metric) | Observed | Pass/Fail | -|---|---|---|---| -| {{criterion}} | {{command, path, URL or check}} | {{observed}} | {{pass/fail}} | - -For research/content, cite the exact source and date. For data, record input hash, row count and -metric. For design, record the rendered artifact and sizes. For software, record the command and -output. Evidence must be reproducible by a fresh verifier. - -## Also check -- Scope: every changed file is owned by the task. -- Contracts: signatures and data shapes match `.swarm/contracts.md`. -- Tests: assert real behavior; no silent skips; no snapshot updates. -- Edge cases named in the task card. - -## Freeze -Do not install tools or dependencies; prerequisites are lead-owned. If a required check cannot run, -report `not_run` with the exact missing item — do not change the environment. -The tree is frozen during verification. Do not edit product source, tests, docs or manifests. If you need a gate script that rewrites generated files, copy it/hash-check it instead of changing the tree. - -## Visual checks -For GUI products, run the app in your own isolated Xvfb/display (never a shared desktop). Capture the default size, the minimum size, empty/error states and every modal. Record the screenshot path and exact command alongside each finding; a screenshot without a command is not evidence. - -Computer-use (mouse/keyboard) is an optional last-resort tier: one agent, disposable desktop/VM, after deterministic checks, never parallel, never the sole evidence. Prefer app screenshot mode or scripted input. - -## Product quality (product profile only) -Verify the release/optimized build, not a debug build: -- p50/p95 frame time at the target size, input-to-visible latency, startup, idle CPU/memory; -- the 3–5 step real user scenario, not just a screenshot; -- baseline comparison on the same scenario (regression = fail); -- report `not_run` if these were not measured. - -A technical pass is **not** product acceptance. The user still runs the artifact and gives an explicit -verdict (usable / usable with issues / not usable). Do not mark the product gate `pass` on the user's -behalf. - -## Verdict -`pass` / `pass_with_risks` / `fail` — with the top risks and exact repro commands. -For product-profile work, `pass` requires functional + measured performance + UX scenario + baseline; -otherwise use `pass_with_risks` with missing gates named, or `not_run`. - -## Report -Keep the review to findings + commands + evidence (target 5–8k tokens); raw logs stay in `.swarm/tmp/`. Review the diff and affected checks, not the whole repository. -FIRST write the full review to `.swarm/reviews/{{ID}}.md`. Then return only the minimal structured verdict: -`{task_id, verdict, summary, review_file}` per `.swarm/verdict.schema.json`. -The review file is the source of truth; it must exist even if the structured reply is lost. Do not return a long findings array in the workflow schema. diff --git a/agent-swarm/assets/verify.workflow.js b/agent-swarm/assets/verify.workflow.js deleted file mode 100644 index a076baa..0000000 --- a/agent-swarm/assets/verify.workflow.js +++ /dev/null @@ -1,88 +0,0 @@ -// agent-swarm verification runner — copy into the `script` field of the workflow tool. -// args: { -// wave?: number, -// tasks: [{ id: string, review: string }], // review = .swarm/reviews/Vxx.md -// concurrency?: number // verifier slots; default 4, keep free slots -// } -// -// The detailed review is written to disk BEFORE the structured verdict is -// returned. The workflow schema is intentionally tiny: a long findings array is -// easy to get wrong and a schema miss must not destroy the verification work. - -const VERDICT = { - type: "object", - properties: { - task_id: { type: "string" }, - verdict: { type: "string", enum: ["pass", "pass_with_risks", "fail"] }, - summary: { type: "string" }, - review_file: { type: "string" } - }, - required: ["task_id", "verdict", "summary", "review_file"] -}; - -const CONCURRENCY = Math.max( - 1, - Math.min(Number(args.concurrency) || 4, 8) -); - -const promptFor = (t, attempt) => [ - `You are verifier ${t.id}. You did not write this work; do not fix it and do not edit product source, tests, docs or manifests.`, - `Read .swarm/brief.md, the relevant .swarm/tasks/*.md cards, .swarm/contracts.md, and the implementation.`, - `Work only in ${t.review} and .swarm/tmp/${t.id}/. Copy or hash-check generated files instead of rewriting the tree.`, - `Verify against the original acceptance criteria, not the worker's summary. Run the commands yourself and record exact commands + observed results. Findings need file:line, reproduction, expected vs actual.`, - `Freeze assumption: the tree is not being edited during this wave. If you see a stale/inconsistent build, say so; do not fix it.`, - `FIRST write the full review to ${t.review}. THEN return only {task_id, verdict, summary, review_file}; keep summary <= 2000 chars. The review file is the source of truth and must exist even if the structured reply fails.`, - `Verdict rules: "fail" for critical/major product gaps; "pass_with_risks" for minor or documented-scope risks; "pass" only when no material issue remains.`, - attempt > 1 - ? `The previous structured reply was unusable. Preserve the review file; return the four required fields only.` - : "" -].filter(Boolean).join("\n"); - -const failed = (t, why) => ({ - task_id: t.id, - verdict: "fail", - summary: why, - review_file: t.review -}); - -async function runOne(t) { - for (let attempt = 1; attempt <= 2; attempt++) { - try { - const r = await agent(promptFor(t, attempt), { - label: t.id, - phase: `verify ${args.wave || ""}`.trim(), - schema: VERDICT - }); - if (r && r.verdict) return r; - log(`${t.id}: attempt ${attempt} produced no usable verdict`); - } catch (error) { - const message = String(error && error.message ? error.message : error); - if (/(limit|spawn|could not start|active child|capacity|start a child)/i.test(message)) { - log(`${t.id}: scheduling error: ${message}`); - return failed(t, `scheduling error: ${message}`); - } - throw error; - } - } - return failed(t, "no usable structured verdict; see review file"); -} - -phase(`verify${args.wave ? ` ${args.wave}` : ""}`); -log(`Dispatching ${args.tasks.length} verifier(s) in batches of ${CONCURRENCY}`); - -const results = []; -for (let start = 0; start < args.tasks.length; start += CONCURRENCY) { - const batch = args.tasks.slice(start, start + CONCURRENCY); - const batchResults = await parallel(batch.map((t) => () => runOne(t))); - results.push(...batchResults); -} - -return { - wave: args.wave || null, - concurrency: CONCURRENCY, - total: results.length, - pass: results.filter((r) => r && r.verdict === "pass").length, - pass_with_risks: results.filter((r) => r && r.verdict === "pass_with_risks").length, - fail: results.filter((r) => !r || r.verdict === "fail").length, - results -}; diff --git a/agent-swarm/assets/wave.workflow.js b/agent-swarm/assets/wave.workflow.js deleted file mode 100644 index eacb32b..0000000 --- a/agent-swarm/assets/wave.workflow.js +++ /dev/null @@ -1,100 +0,0 @@ -// agent-swarm batched worker runner — copy into the `script` field of the workflow tool. -// args: { -// wave: number, -// tasks: [{ id: string, write: string[] }], -// schema: object, // paste assets/report.schema.json -// concurrency?: number // <= free active-child slots; default 6 -// } -// -// The runner starts tasks in chunks instead of one giant fan-out. This matters -// because `parallel` is not a queue and the runtime active-child cap is -// host-specific; a single spawn-limit throw inside an unbounded fan-out can -// abort the whole wave. Each `agent()` call is guarded so a scheduling failure -// becomes a structured result for that task, and completed chunks are kept. - -const REPORT = args.schema; -if (!REPORT) throw new Error("args.schema is required (paste assets/report.schema.json)"); - -const CONCURRENCY = Math.max( - 1, - Math.min(Number(args.concurrency) || 6, 8) -); - -const promptFor = (t, attempt) => [ - `You are agent ${t.id} in a coordinated swarm.`, - `Read .swarm/brief.md, .swarm/tasks/${t.id}.md, and .swarm/contracts.md first.`, - `Write only within: ${(t.write || []).join(", ") || "(read-only task)"}, plus your own report, review, and scratch under .swarm/reports/, .swarm/reviews/, and .swarm/tmp/${t.id}/.`, - `Do not edit other tasks' files or reports; do not run installs, repo-wide format/lint/codegen, migrations, dev servers, or git writes.`, - `Run the acceptance checks and record exact commands and results.`, - `Write .swarm/reports/${t.id}.json and return the same object.`, - `If a load-bearing unknown or a needed file outside scope blocks you, return status "blocked" with blocked_question; do not guess.`, - `If you hit a compile/test failure caused by a sibling task's in-flight file, wait briefly and retry; report status "partial" with the exact external error rather than editing outside your scope.`, - attempt > 1 - ? `A previous attempt produced no usable report. Re-read the task and fix the cause or report the exact blocker.` - : "" -].filter(Boolean).join("\n"); - -const failed = (t, why, scheduling = false) => ({ - task_id: t.id, - status: "failed", - summary: why, - files_changed: [], - evidence: scheduling ? [`scheduling failure: ${why}`] : [], - acceptance: [], - issues: [why], - assumptions: [], - spawn_error: scheduling -}); - -async function runOne(t) { - for (let attempt = 1; attempt <= 2; attempt++) { - try { - const r = await agent(promptFor(t, attempt), { - label: t.id, - phase: `wave ${args.wave}`, - schema: REPORT - }); - if (r && r.status !== "failed") return r; - log(`${t.id}: attempt ${attempt} produced no usable report`); - } catch (error) { - const message = String(error && error.message ? error.message : error); - // A spawn/limit error is a scheduling problem: keep the batch, report it. - // Any other throw (bad hook option, unsupported schema) should still fail - // loudly so the script is fixed instead of silently swallowing a mistake. - if (/(limit|spawn|could not start|active child|capacity|start a child)/i.test(message)) { - log(`${t.id}: scheduling error: ${message}`); - return failed(t, `scheduling error: ${message}`, true); - } - throw error; - } - } - return failed(t, "no usable report after 2 attempts"); -} - -phase(`wave ${args.wave}`); -log(`Dispatching ${args.tasks.length} task(s) in batches of ${CONCURRENCY}`); - -const results = []; -for (let start = 0; start < args.tasks.length; start += CONCURRENCY) { - const batch = args.tasks.slice(start, start + CONCURRENCY); - log(`Batch ${Math.floor(start / CONCURRENCY) + 1}: ${batch.map((t) => t.id).join(", ")}`); - const batchResults = await parallel(batch.map((t) => () => runOne(t))); - results.push(...batchResults); -} - -const spawnErrors = results.filter((r) => r && r.spawn_error).length; -if (spawnErrors > 0) { - log(`${spawnErrors} task(s) hit a spawn/scheduling error. Dispatch only the unstarted tasks with a smaller concurrency.`); -} - -return { - wave: args.wave, - concurrency: CONCURRENCY, - total: results.length, - done: results.filter((r) => r && r.status === "done").length, - partial: results.filter((r) => r && r.status === "partial").length, - blocked: results.filter((r) => r && r.status === "blocked").length, - failed: results.filter((r) => !r || r.status === "failed").length, - spawn_errors: spawnErrors, - results -}; diff --git a/agent-swarm/references/orchestration.md b/agent-swarm/references/orchestration.md deleted file mode 100644 index b78501c..0000000 --- a/agent-swarm/references/orchestration.md +++ /dev/null @@ -1,211 +0,0 @@ -# Workflow orchestration - -The `workflow` tool runs one JavaScript body with top-level `await` and returns a JSON value. It is the only way to fan out dozens of agents without flooding the lead's context. - -## Call shape - -```json -{ - "meta": {"name": "swarm-wave-1", "description": "Build wave", "phases": [{"title": "wave 1"}]}, - "script": "