| 1 | /** |
| 2 | * Operate starter — parallel scout with partial-failure synthesis. |
| 3 | * |
| 4 | * Dogfood source: docs/examples/dogfood-automatic/wf_a3_partial_failure_synthesis.workflow.js |
| 5 | * Run: /workflow run workflows/operate_parallel_scout.workflow.js |
| 6 | */ |
| 7 | export default async function () { |
| 8 | phase("Parallel scouts"); |
| 9 | const slots = await parallel([ |
| 10 | () => |
| 11 | task({ |
| 12 | description: "Healthy scout A", |
| 13 | label: "scout-a", |
| 14 | type: "explore", |
| 15 | prompt: "Return the string READY_A. Read-only.", |
| 16 | }), |
| 17 | // Give this child an intentionally tiny budget so it starts, then fails |
| 18 | // deterministically at the runtime boundary. A model refusal is still a |
| 19 | // successful transport-level completion, while response-schema failures |
| 20 | // intentionally abort the whole workflow so they remain loud. |
| 21 | () => |
| 22 | task({ |
| 23 | description: "Deliberately failing scout B", |
| 24 | label: "scout-b-fail", |
| 25 | type: "explore", |
| 26 | tokenBudget: 1, |
| 27 | prompt: |
| 28 | "Inspect Cargo.toml and return a detailed workspace summary. This child intentionally has a one-token budget so parallel() exercises a failed null slot.", |
| 29 | }), |
| 30 | () => |
| 31 | task({ |
| 32 | description: "Healthy scout C", |
| 33 | label: "scout-c", |
| 34 | type: "explore", |
| 35 | prompt: "Return the string READY_C. Read-only.", |
| 36 | }), |
| 37 | ]); |
| 38 | |
| 39 | phase("Synthesize"); |
| 40 | const surviving = (slots || []).filter((s) => s != null); |
| 41 | const summary = await task({ |
| 42 | description: "Synthesize from surviving parallel slots", |
| 43 | label: "synthesizer", |
| 44 | // Read-only synthesizer — "general" is write-capable and fails closed without |
| 45 | // write scope (same class as operate_read_audit; dogfood 2026-07-24). |
| 46 | type: "review", |
| 47 | prompt: [ |
| 48 | "Build one operator-facing summary from the surviving scout results.", |
| 49 | "Explicitly note which parallel slot failed or returned null.", |
| 50 | `slot_count=${(slots || []).length} surviving=${surviving.length}`, |
| 51 | "slots_json:", |
| 52 | JSON.stringify(slots), |
| 53 | ].join("\n"), |
| 54 | }); |
| 55 | |
| 56 | return { |
| 57 | scenario: "WF-A3", |
| 58 | slots, |
| 59 | surviving_count: surviving.length, |
| 60 | summary, |
| 61 | }; |
| 62 | } |
| 63 |