Establish a measurable single-agent baseline before splitting into independent reasoning loops. Compute parallel limits from dependencies, define inputs, artifacts and commit ownership, and handle late results and recovery. Judge the change by complete-task quality, latency and cost.
From Workflows to Multi-Agent
A single Agent can also call independent tools in parallel; therefore, "needing to read multiple files simultaneously" does not necessarily require multiple reasoning loops. Multi-Agent is better suited for sub-tasks that require longer individual analysis, different information scopes, or independent workflows. Once each Worker forms its own context, returning compressed results and evidence locations to the Coordinator can reduce the amount of raw material the main context has to bear.
Multiple model calls do not automatically equal Multi-Agent. Fixed extraction, validation, and formatting pipelines can be implemented by standard workflows; dynamically decomposing tasks and allowing branches to proceed independently based on tool feedback is closer to the collaborative Agents discussed here. Building effective agents
Organization Method
Who Decides Steps
Main Benefits and Costs
Chaining and Routing
Pre-defined program paths or classification rules
Easy to reproduce, but requires process expansion for unknown branches
Parallel Sharding
Pre-defined independent scopes
Shortens overlapping work, still requires merging
Dynamic Coordinator and Workers
Model proposes decomposition, scheduler executes
Adapts to unknown tasks, coordination and verification are more complex
Generation and Review Loop
Fixed process plus model feedback
Improves candidates, constrained by review quality and iteration limits
Multi-Agent dialogue frameworks demonstrate the ability to combine roles, tools, and communication patterns, but providing a dialogue mechanism does not automatically ensure task correctness. When deciding which structure to adopt, refer to the AutoGen paper. First, identify the specific limitations of the current single-Agent approach, then verify whether adding collaboration improves it.
Map Dependencies First, Then Calculate Benefits
Assume a task consists of Preparation A, Implementation B, Independent Compatibility Check C, and Summary D. Both B and C require A's interface contract; D must receive results from both. If B and C can indeed proceed independently, the following parallel structure holds:
Serial time is 2+4+6+3=15 minutes; ideal parallel time is 2+max(4,6)+3=11 minutes, saving 4 minutes. If delegation, queuing, and merging conflicts take an additional 5 minutes, the total time becomes 16 minutes. Launching two Workers does not mean the task is twice as fast.
If C checks patches that B has not yet produced, C depends on B, and this diagram needs to be changed to serial; alternatively, C can first independently organize the check standards, and then verify after the patches are completed. Changing the task definition can create some parallel space, but you cannot use model guesses to eliminate real data dependencies.
duration={"A":2,"B":4,"C":6,"D":3}deps={"A":[],"B":["A"],"C":["A"],"D":["B","C"]}finish={}# This dictionary lists nodes in topological order of dependencies, not a general scheduler.
fornode,minutesinduration.items():finish[node]=max((finish[x]forxindeps[node]),default=0)+minutesassertfinish["D"]==11assertsum(duration.values())==15print("Ideal parallel minutes:",finish["D"])print("Plus 5 minutes coordination overhead:",finish["D"]+5)
Costs must also include the main Agent, all Workers, repeated reads, tool calls, and failed attempts. Using cheaper models for suitable sub-tasks may save money, but multiple independent windows will also redundantly load constraints and materials; whether prefix caching hits depends on the service, model, and input. It is not guaranteed that "opening sub-Agents is always cheaper than switching models in the main loop."
Engineering reports from actual Multi-Agent research systems discuss context isolation, independent research, and higher token consumption, while also pointing out coordination limitations for tightly dependent tasks. The benefits of such systems should be understood as specific cases, not as a universal acceleration factor for all tasks. Anthropic Multi-Agent Research System
Why does parallelism not scale by headcount?
Draw dependencies before estimating parallel benefits. Dependencies determine start times and merge consumes time too. Total work is 15 while the default critical path is 9: resource use and completion latency are different quantities.
Tparallel=p∈pathsmaxi∈p∑ti+Tcoordination
Preparing the visual
Why does parallelism not scale by headcount?
Parallel latency follows the longest dependency path plus coordination overhead, not total work divided by workers.
{"id":"ai-critical-path","title":"Why does parallelism not scale by headcount?","summary":"Parallel latency follows the longest dependency path plus coordination overhead, not total work divided by workers.","height":1000,"html":"<h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p><label class=\"check\"><input type=\"checkbox\" id=\"dependency\"><span data-i18n=\"dependency\"></span></label><div class=\"control\"><label for=\"overhead\" data-i18n=\"overhead\"></label><output for=\"overhead\" id=\"overhead-value\"></output><input id=\"overhead\" type=\"range\" min=\"0\" max=\"6\" value=\"0\" step=\"1\"></div><section class=\"panel\"><h3 data-i18n=\"timeline\"></h3><div id=\"timeline\"></div></section><div class=\"metrics\"><div><span data-i18n=\"parallel\"></span><strong id=\"parallel\"></strong></div><div><span data-i18n=\"speedup\"></span><strong id=\"speedup\"></strong></div></div><div class=\"copy\"><p id=\"explanation\" role=\"status\"></p><p class=\"reserve\" aria-hidden=\"true\" data-i18n=\"explain\"></p></div><details class=\"scope\"><summary data-i18n=\"scopeLabel\"></summary><p data-i18n=\"scope\"></p></details>","css":".intro{margin:8px 0 18px;color:var(--muted);font-size:14px}.control{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 12px;align-items:center;margin:14px 0;font-size:13px}.control output{color:var(--accent);text-align:right;font-variant-numeric:tabular-nums;min-width:4em}.control input{grid-column:1/-1;width:100%;margin:0}.presets{display:flex;gap:4px;align-items:stretch}.presets button{flex:1;min-width:0;overflow-wrap:anywhere;font-size:13px;min-height:44px}.actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:16px 0}.actions button{min-width:0;min-height:44px;font-size:13px;overflow-wrap:anywhere}.copy{display:grid;font-size:14px;margin:16px 0}.copy>*{grid-area:1/1;margin:0;overflow-wrap:anywhere}.reserve{visibility:hidden}.scope{margin-top:14px;color:var(--muted);font-size:12px}.scope summary{padding:8px 0;cursor:pointer}.scope p{margin-top:10px;overflow-wrap:anywhere}.metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:18px 0}.metrics>div{border-left:2px solid var(--accent);padding:0 6px 0 10px;min-width:0}.metrics span{display:block;min-height:3.6em;color:var(--muted);font-size:12px;overflow-wrap:anywhere}.metrics strong{font-size:21px;display:block;min-height:2em;font-weight:550;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.check{display:flex;align-items:center;gap:9px;font-size:13px;margin:14px 0}.check input{width:18px;height:18px;flex-shrink:0;accent-color:var(--accent)}select,input[type=text],input[type=number]{background:var(--paper);color:var(--ink);font:inherit;font-size:14px;padding:10px;border:1px solid var(--rule);border-radius:7px;max-width:100%;min-width:0}select{width:100%;min-height:44px}.panel{padding:14px;border:1px solid var(--rule);border-radius:9px;margin:16px 0;min-width:0}.panel>header{font-size:13px;font-weight:600;margin-bottom:12px;color:var(--muted)}.panel>div{overflow-wrap:anywhere}.track-row{margin:16px 0}.track-row>span{display:block;font-size:12px;color:var(--muted);margin-bottom:8px}.track{display:flex;gap:5px;min-width:0}.cell{flex:1;min-width:0;min-height:56px;border:1px solid var(--rule);border-radius:5px;background:var(--surface);display:flex;align-items:center;justify-content:center;text-align:center;padding:6px 3px;font-size:12px;overflow-wrap:anywhere}.cell.on{background:var(--accent-soft);border-color:var(--accent)}.cell.gold{background:var(--second-soft);border-color:var(--second)}.cell.empty{border-style:dashed;color:var(--muted)}.cell.error{border-color:var(--second);text-decoration:line-through}.table{display:grid;gap:5px;font-size:12px}.tr{display:grid;gap:5px}.tr>div{background:var(--surface);border-radius:4px;padding:9px 6px;min-width:0;min-height:5em;overflow-wrap:anywhere;display:flex;align-items:center}.tr>.gold{background:var(--second-soft)}.tr>.on{background:var(--accent-soft)}.formula,.source{font:13px/1.8 ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:16px 0}.formula{border-top:1px solid var(--rule);padding-top:12px;min-height:7.2em}.source{min-height:8em;background:var(--surface);padding:12px;border-radius:8px}.intervals{margin:16px 0}.interval{position:relative;height:38px;background:var(--surface);margin:6px 0;border-radius:4px;overflow:hidden}.interval i{position:absolute;height:100%;background:var(--accent-soft);border-left:2px solid var(--accent)}.interval i.gold{background:var(--second-soft);border-color:var(--second)}.interval span{position:relative;z-index:1;font:12px/38px ui-monospace,monospace;padding-left:7px}.bars{display:grid;gap:10px;margin:16px 0}.bar-row{display:grid;grid-template-columns:44px minmax(0,1fr) 62px;gap:8px;align-items:center;font:12px ui-monospace,monospace}.bar-track{height:24px;background:var(--surface);border-radius:4px;overflow:hidden}.bar-track i{display:block;height:100%;background:var(--accent);transition:width .2s}.bar-track i.gold{background:var(--second)}.bar-track i.empty{opacity:.2}.bar-row output{text-align:right}.diagram{display:block;width:100%;height:auto;margin:18px 0}.diagram text{font:13px ui-monospace,monospace;fill:var(--ink)}.node{fill:var(--surface);stroke:var(--rule)}.node.on{fill:var(--accent-soft);stroke:var(--accent)}.node.gold{fill:var(--second-soft);stroke:var(--second)}.edge{stroke:var(--rule);stroke-width:2;fill:none}.edge.on{stroke:var(--accent)}.matrix{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:16px 0}.matrix button{min-width:0;min-height:44px;font:13px ui-monospace,monospace}.matrix button[aria-pressed=true]{background:var(--accent-soft);border-color:var(--accent)}.matrix button.masked{opacity:.35}.legend{font-size:12px;color:var(--muted);min-height:3.6em;overflow-wrap:anywhere}.numeric{font-variant-numeric:tabular-nums}.scope p{line-break:strict}@media(max-width:480px){.presets button,.actions button{font-size:12px}.panel{padding:12px}.metrics{gap:10px}.metrics strong{font-size:19px}.bar-row{grid-template-columns:34px minmax(0,1fr) 58px;gap:6px}}@media(prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important}}\n\n.panel>h3{font-size:13px;font-weight:600;margin:0 0 12px;color:var(--muted)}\n\n.bar-row{grid-template-columns:44px minmax(0,1fr) 82px}.bar-row output{white-space:nowrap}@media(max-width:480px){.bar-row{grid-template-columns:34px minmax(0,1fr) 76px}}\n\n","js":"const $=s=>document.querySelector(s);const set=(id,v)=>$('#'+id).textContent=v;const t=k=>viz.t(k);function cells(id,values){$('#'+id).replaceChildren(...values.map(v=>{const e=document.createElement('div');e.className='cell '+(v.cls||'');e.textContent=v.text;e.title=v.title||v.text;return e;}));}function pressed(mode){document.querySelectorAll('[data-mode]').forEach(e=>e.setAttribute('aria-pressed',String(e.dataset.mode===mode)));}const esc=s=>String(s).replace(/[&<>\"']/g,c=>({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));const fmt=s=>'{'+[...s].sort().join(', ')+'}';function graph(id,nodes,edges){const el=$('#'+id);el.setAttribute('viewBox','0 0 360 200');el.innerHTML='<defs><marker id=\"arrow-'+id+'\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"5\" markerHeight=\"5\" orient=\"auto-start-reverse\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"var(--muted)\"/></marker></defs>'+edges.map(e=>{const a=nodes[e[0]],b=nodes[e[1]],dx=b.x-a.x,dy=b.y-a.y,d=Math.hypot(dx,dy)||1;if(edges.some(r=>r[0]===e[1]&&r[1]===e[0])){const nx=-dy/d,ny=dx/d;return '<path class=\"edge '+(e[2]?'on':'')+'\" d=\"M '+(a.x+dx/d*22+nx*12)+' '+(a.y+dy/d*22+ny*12)+' Q '+((a.x+b.x)/2+nx*38)+' '+((a.y+b.y)/2+ny*38)+' '+(b.x-dx/d*25+nx*12)+' '+(b.y-dy/d*25+ny*12)+'\" marker-end=\"url(#arrow-'+id+')\"/>';}return '<line class=\"edge '+(e[2]?'on':'')+'\" x1=\"'+(a.x+dx/d*25)+'\" y1=\"'+(a.y+dy/d*25)+'\" x2=\"'+(b.x-dx/d*28)+'\" y2=\"'+(b.y-dy/d*28)+'\" marker-end=\"url(#arrow-'+id+')\"/>';}).join('')+nodes.map(n=>'<g><circle class=\"node '+(n.cls||'')+'\" cx=\"'+n.x+'\" cy=\"'+n.y+'\" r=\"25\"/><text x=\"'+n.x+'\" y=\"'+(n.y+4)+'\" text-anchor=\"middle\">'+esc(n.name)+'</text>'+(n.sub?'<text x=\"'+n.x+'\" y=\"'+(n.y+43)+'\" text-anchor=\"middle\">'+esc(n.sub)+'</text>':'')+'</g>').join('');}function table(id,rows){$('#'+id).classList.add('table');$('#'+id).replaceChildren(...rows.map(r=>{const row=document.createElement('div');row.className='tr';row.style.gridTemplateColumns='repeat('+r.length+',minmax(0,1fr))';r.forEach(x=>{const c=document.createElement('div');if(typeof x==='object'){c.textContent=x.text;c.className=x.cls||'';}else c.textContent=x;row.append(c)});return row;}));}function band(id,parts,total){$('#'+id).replaceChildren(...parts.map((p,i)=>{const e=document.createElement('i');e.style.width=(100*p.value/total)+'%';e.className=i%2?'gold':'on';e.title=p.name+': '+p.value;return e}));}function intervals(id,items,total){$('#'+id).replaceChildren(...items.map(p=>{const row=document.createElement('div');row.className='interval';const bar=document.createElement('i');bar.style.left=(100*p.start/total)+'%';bar.style.width=(100*(p.end-p.start)/total)+'%';bar.className=p.cls||'';const label=document.createElement('span');label.textContent=p.label;row.append(bar,label);return row;}));}function plot(id,series,xr,yr,opts={}){const e=$('#'+id),X=x=>42+(x-xr[0])/(xr[1]-xr[0])*298,Y=y=>175-(y-yr[0])/(yr[1]-yr[0])*148;let out='<defs><clipPath id=\"clip-'+id+'\"><rect x=\"42\" y=\"27\" width=\"298\" height=\"148\"/></clipPath></defs>';for(let i=0;i<3;i++){let x=xr[0]+i*(xr[1]-xr[0])/2,y=yr[0]+i*(yr[1]-yr[0])/2;out+='<path class=\"gridline\" d=\"M '+X(x)+' 27V175M42 '+Y(y)+'H340\"/><text x=\"'+X(x)+'\" y=\"194\" text-anchor=\"middle\">'+esc(opts.xfmt?opts.xfmt(x):Number(x.toFixed(2)))+'</text><text x=\"36\" y=\"'+(Y(y)+4)+'\" text-anchor=\"end\">'+esc(opts.yfmt?opts.yfmt(y):Number(y.toFixed(2)))+'</text>';}out+='<g clip-path=\"url(#clip-'+id+')\">';for(const s of series){out+='<path fill=\"none\" stroke=\"'+(s.color||'var(--accent)')+'\" stroke-width=\"2.5\" '+(s.dash?'stroke-dasharray=\"5 4\"':'')+' d=\"'+s.pts.map((p,i)=>(i?'L':'M')+X(p[0]).toFixed(2)+','+Y(p[1]).toFixed(2)).join(' ')+'\"/>';}for(const p of opts.points||[])out+='<circle cx=\"'+X(p[0])+'\" cy=\"'+Y(p[1])+'\" r=\"4\" fill=\"var(--second)\" stroke=\"var(--paper)\" stroke-width=\"1.5\"/>';if(opts.cursor!==undefined)out+='<path d=\"M'+X(opts.cursor)+' 27V175\" stroke=\"var(--muted)\" stroke-dasharray=\"3 3\"/>';e.innerHTML=out+'</g>';e.dataset.curves=JSON.stringify(series.map(s=>s.pts));}const curve=(fn,lo,hi,n=120)=>Array.from({length:n+1},(_,i)=>{const x=lo+(hi-lo)*i/n;return[x,fn(x)]});function inputs(draw){document.querySelectorAll('input,select').forEach(e=>{e.addEventListener('input',draw);e.addEventListener('change',draw)});draw()}const n=id=>+$('#'+id).value;const show=(id,v,d=3)=>set(id,Number(v.toFixed(d)));function bars(id,values,max=1){$('#'+id).className='bars';$('#'+id).innerHTML=values.map(v=>'<div class=\"bar-row\"><span>'+esc(v.label)+'</span><div class=\"bar-track\"><i class=\"'+(v.cls||'')+'\" style=\"width:'+Math.max(0,Math.min(100,v.value/max*100))+'%\"></i></div><output>'+esc(v.text??(v.value*100).toFixed(1)+'%')+'</output></div>').join('')}function softmax(z,T=1){let max=Math.max(...z),w=z.map(x=>Math.exp((x-max)/T)),sum=w.reduce((a,b)=>a+b,0);return w.map(x=>x/sum)}function draw(){let c=$('#dependency').checked?4:0,end=c+6,o=n('overhead'),total=end+3+o;intervals('timeline',[{label:'A 0→2',start:0,end:2},{label:'B 0→4',start:0,end:4},{label:'C '+c+'→'+end,start:c,end},{label:'D '+end+'→'+(end+3),start:end,end:end+3,cls:'gold'},{label:'+ '+o,start:end+3,end:total,cls:'gold'}],19);set('overhead-value',o);set('parallel',total);set('speedup',(15/total).toFixed(2)+'×');set('explanation',t('explain'));document.body.dataset.total=total;}inputs(draw);","audio":false,"strings":{"dependency":"C must wait for B","explain":"C takes 6 plus merge 3, finishing at 9. With B→C→D the path takes 13; adding coordination cost 3 makes it slower than serial 15.","heading":"Why does parallelism not scale by headcount?","intro":"Change C’s dependency and coordination overhead; inspect completion time.","overhead":"Extra coordination time","parallel":"Parallel completion","reset":"Reset","scope":"A=2, B=4, C=6, merge D=3; A/B/C each have a worker, D waits for all. No resource contention.","scopeLabel":"Model scope and assumptions","speedup":"Speedup vs serial 15","timeline":"Parallel timeline"}}
Delegation is Delivering a Task Contract
"You are responsible for checking compatibility" is too vague: which version to check, which interfaces, whether modifications are allowed, and what evidence is required are all undefined. The Coordinator should deliver complete information necessary for the Worker to complete the task, while avoiding dumping the entire main session history.
Contract Item
Example
Goal
Check if the migration plan breaks existing import formats
Inputs and Versions
schema-v3, sample set R12, plan draft-4
Scope
Only analyze format compatibility, do not modify implementation
Available Capabilities and Permissions
Read samples, run local validation; do not publish artifacts
Complete the matrix or reach the allocated budget, clearly stating remaining gaps
Merge Interface
Write results to a task-specific directory and return identifiers
Whether tools, history, and file systems are shared depends on the runtime environment. Even with shared directories, Workers may not have read the files; even without shared history, necessary context can be restored through explicit inputs. Delegation messages should specify actually accessible resources, rather than assuming the other party "knows what was discussed earlier."
If the main task requires "only change Chinese first," this constraint must be passed to all Workers that might modify documents. The Main Agent's authorization is also not a reason to arbitrarily expand tool permissions: a read-only check task should receive the capabilities it needs, and out-of-scope findings should be returned to the Coordinator for decision.
Artifact Ownership and Result Acceptance
Define Boundaries for Writes
In a shared workspace, two Agents modifying the same file simultaneously may overwrite content; assigning different files does not necessarily mean independence, as they might jointly change an interface contract. You can choose to divide work by directory or artifact, use independent branches or working copies, and then have a clear Integrator merge them.
Isolated copies reduce direct overwrites but cannot avoid semantic conflicts. For example, if B renames a field to item_id, C's test might still assume the field is called sku; even if the patch texts can be automatically merged, integration will fail. Fixing interface versions in the contract and propagating changes to dependent parties first can reduce such wasted effort.
Summaries for Location, Evidence for Confirmation
A Worker returning "check passed" is insufficient. Results should include the input version targeted, the method used, accessible artifacts, and uncovered items. The Coordinator first checks goal coverage, then verifies versions and evidence, and finally decides to accept, supplement, or re-divide.
Return Situation
Coordinator Action
All conclusions have corresponding samples and check results
Accept and incorporate into overall evidence
Conclusions are correct but only cover part of the format
Mark as partially complete, assign specific gaps
Two Workers have conflicting conclusions
Return to original conditions and versions, do not directly vote by majority
Referenced files exist but have been modified subsequently
Check hash or commit, re-verify related conclusions
Only fluent summaries, no verifiable artifacts
Require additional evidence based on task risk
Independent review helps identify omissions, but another Agent using the same model might share the same bias. "Separating author and reviewer" provides role and context differences, but does not equal statistical independence or proof of correctness. Combining explicit standards, independent testing, actual execution, and necessary human review creates verifiable boundaries.
Why reject a successful worker result?
Archive all attempts, but integrate only results satisfying the current contract. Keep worker completion, result receipt and accepted integration as separate states, rather than overloading one success field.
Preparing the visual
Why reject a successful worker result?
Success is not current validity; integration must check task identity, current attempt, input version and evidence.
{"id":"ai-stale-result","title":"Why reject a successful worker result?","summary":"Success is not current validity; integration must check task identity, current attempt, input version and evidence.","height":1000,"html":"<h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p><div class=\"control\"><label for=\"attempt\" data-i18n=\"attempt\"></label><output for=\"attempt\" id=\"attempt-value\"></output><input id=\"attempt\" type=\"range\" min=\"1\" max=\"2\" value=\"1\" step=\"1\"></div><div class=\"control\"><label for=\"version\" data-i18n=\"version\"></label><output for=\"version\" id=\"version-value\"></output><input id=\"version\" type=\"range\" min=\"3\" max=\"4\" value=\"4\" step=\"1\"></div><label class=\"check\"><input type=\"checkbox\" id=\"evidence\" checked><span data-i18n=\"evidence\"></span></label><section class=\"panel\"><h3 data-i18n=\"checks\"></h3><div id=\"checks\"></div></section><div class=\"copy\"><p id=\"explanation\" role=\"status\"></p><p class=\"reserve\" aria-hidden=\"true\" data-i18n=\"explain\"></p></div><details class=\"scope\"><summary data-i18n=\"scopeLabel\"></summary><p data-i18n=\"scope\"></p></details>","css":".intro{margin:8px 0 18px;color:var(--muted);font-size:14px}.control{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 12px;align-items:center;margin:14px 0;font-size:13px}.control output{color:var(--accent);text-align:right;font-variant-numeric:tabular-nums;min-width:4em}.control input{grid-column:1/-1;width:100%;margin:0}.presets{display:flex;gap:4px;align-items:stretch}.presets button{flex:1;min-width:0;overflow-wrap:anywhere;font-size:13px;min-height:44px}.actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:16px 0}.actions button{min-width:0;min-height:44px;font-size:13px;overflow-wrap:anywhere}.copy{display:grid;font-size:14px;margin:16px 0}.copy>*{grid-area:1/1;margin:0;overflow-wrap:anywhere}.reserve{visibility:hidden}.scope{margin-top:14px;color:var(--muted);font-size:12px}.scope summary{padding:8px 0;cursor:pointer}.scope p{margin-top:10px;overflow-wrap:anywhere}.metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:18px 0}.metrics>div{border-left:2px solid var(--accent);padding:0 6px 0 10px;min-width:0}.metrics span{display:block;min-height:3.6em;color:var(--muted);font-size:12px;overflow-wrap:anywhere}.metrics strong{font-size:21px;display:block;min-height:2em;font-weight:550;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.check{display:flex;align-items:center;gap:9px;font-size:13px;margin:14px 0}.check input{width:18px;height:18px;flex-shrink:0;accent-color:var(--accent)}select,input[type=text],input[type=number]{background:var(--paper);color:var(--ink);font:inherit;font-size:14px;padding:10px;border:1px solid var(--rule);border-radius:7px;max-width:100%;min-width:0}select{width:100%;min-height:44px}.panel{padding:14px;border:1px solid var(--rule);border-radius:9px;margin:16px 0;min-width:0}.panel>header{font-size:13px;font-weight:600;margin-bottom:12px;color:var(--muted)}.panel>div{overflow-wrap:anywhere}.track-row{margin:16px 0}.track-row>span{display:block;font-size:12px;color:var(--muted);margin-bottom:8px}.track{display:flex;gap:5px;min-width:0}.cell{flex:1;min-width:0;min-height:56px;border:1px solid var(--rule);border-radius:5px;background:var(--surface);display:flex;align-items:center;justify-content:center;text-align:center;padding:6px 3px;font-size:12px;overflow-wrap:anywhere}.cell.on{background:var(--accent-soft);border-color:var(--accent)}.cell.gold{background:var(--second-soft);border-color:var(--second)}.cell.empty{border-style:dashed;color:var(--muted)}.cell.error{border-color:var(--second);text-decoration:line-through}.table{display:grid;gap:5px;font-size:12px}.tr{display:grid;gap:5px}.tr>div{background:var(--surface);border-radius:4px;padding:9px 6px;min-width:0;min-height:5em;overflow-wrap:anywhere;display:flex;align-items:center}.tr>.gold{background:var(--second-soft)}.tr>.on{background:var(--accent-soft)}.formula,.source{font:13px/1.8 ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:16px 0}.formula{border-top:1px solid var(--rule);padding-top:12px;min-height:7.2em}.source{min-height:8em;background:var(--surface);padding:12px;border-radius:8px}.intervals{margin:16px 0}.interval{position:relative;height:38px;background:var(--surface);margin:6px 0;border-radius:4px;overflow:hidden}.interval i{position:absolute;height:100%;background:var(--accent-soft);border-left:2px solid var(--accent)}.interval i.gold{background:var(--second-soft);border-color:var(--second)}.interval span{position:relative;z-index:1;font:12px/38px ui-monospace,monospace;padding-left:7px}.bars{display:grid;gap:10px;margin:16px 0}.bar-row{display:grid;grid-template-columns:44px minmax(0,1fr) 62px;gap:8px;align-items:center;font:12px ui-monospace,monospace}.bar-track{height:24px;background:var(--surface);border-radius:4px;overflow:hidden}.bar-track i{display:block;height:100%;background:var(--accent);transition:width .2s}.bar-track i.gold{background:var(--second)}.bar-track i.empty{opacity:.2}.bar-row output{text-align:right}.diagram{display:block;width:100%;height:auto;margin:18px 0}.diagram text{font:13px ui-monospace,monospace;fill:var(--ink)}.node{fill:var(--surface);stroke:var(--rule)}.node.on{fill:var(--accent-soft);stroke:var(--accent)}.node.gold{fill:var(--second-soft);stroke:var(--second)}.edge{stroke:var(--rule);stroke-width:2;fill:none}.edge.on{stroke:var(--accent)}.matrix{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:16px 0}.matrix button{min-width:0;min-height:44px;font:13px ui-monospace,monospace}.matrix button[aria-pressed=true]{background:var(--accent-soft);border-color:var(--accent)}.matrix button.masked{opacity:.35}.legend{font-size:12px;color:var(--muted);min-height:3.6em;overflow-wrap:anywhere}.numeric{font-variant-numeric:tabular-nums}.scope p{line-break:strict}@media(max-width:480px){.presets button,.actions button{font-size:12px}.panel{padding:12px}.metrics{gap:10px}.metrics strong{font-size:19px}.bar-row{grid-template-columns:34px minmax(0,1fr) 58px;gap:6px}}@media(prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important}}\n\n.panel>h3{font-size:13px;font-weight:600;margin:0 0 12px;color:var(--muted)}\n\n.bar-row{grid-template-columns:44px minmax(0,1fr) 82px}.bar-row output{white-space:nowrap}@media(max-width:480px){.bar-row{grid-template-columns:34px minmax(0,1fr) 76px}}\n\n","js":"const $=s=>document.querySelector(s);const set=(id,v)=>$('#'+id).textContent=v;const t=k=>viz.t(k);function cells(id,values){$('#'+id).replaceChildren(...values.map(v=>{const e=document.createElement('div');e.className='cell '+(v.cls||'');e.textContent=v.text;e.title=v.title||v.text;return e;}));}function pressed(mode){document.querySelectorAll('[data-mode]').forEach(e=>e.setAttribute('aria-pressed',String(e.dataset.mode===mode)));}const esc=s=>String(s).replace(/[&<>\"']/g,c=>({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));const fmt=s=>'{'+[...s].sort().join(', ')+'}';function graph(id,nodes,edges){const el=$('#'+id);el.setAttribute('viewBox','0 0 360 200');el.innerHTML='<defs><marker id=\"arrow-'+id+'\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"5\" markerHeight=\"5\" orient=\"auto-start-reverse\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"var(--muted)\"/></marker></defs>'+edges.map(e=>{const a=nodes[e[0]],b=nodes[e[1]],dx=b.x-a.x,dy=b.y-a.y,d=Math.hypot(dx,dy)||1;if(edges.some(r=>r[0]===e[1]&&r[1]===e[0])){const nx=-dy/d,ny=dx/d;return '<path class=\"edge '+(e[2]?'on':'')+'\" d=\"M '+(a.x+dx/d*22+nx*12)+' '+(a.y+dy/d*22+ny*12)+' Q '+((a.x+b.x)/2+nx*38)+' '+((a.y+b.y)/2+ny*38)+' '+(b.x-dx/d*25+nx*12)+' '+(b.y-dy/d*25+ny*12)+'\" marker-end=\"url(#arrow-'+id+')\"/>';}return '<line class=\"edge '+(e[2]?'on':'')+'\" x1=\"'+(a.x+dx/d*25)+'\" y1=\"'+(a.y+dy/d*25)+'\" x2=\"'+(b.x-dx/d*28)+'\" y2=\"'+(b.y-dy/d*28)+'\" marker-end=\"url(#arrow-'+id+')\"/>';}).join('')+nodes.map(n=>'<g><circle class=\"node '+(n.cls||'')+'\" cx=\"'+n.x+'\" cy=\"'+n.y+'\" r=\"25\"/><text x=\"'+n.x+'\" y=\"'+(n.y+4)+'\" text-anchor=\"middle\">'+esc(n.name)+'</text>'+(n.sub?'<text x=\"'+n.x+'\" y=\"'+(n.y+43)+'\" text-anchor=\"middle\">'+esc(n.sub)+'</text>':'')+'</g>').join('');}function table(id,rows){$('#'+id).classList.add('table');$('#'+id).replaceChildren(...rows.map(r=>{const row=document.createElement('div');row.className='tr';row.style.gridTemplateColumns='repeat('+r.length+',minmax(0,1fr))';r.forEach(x=>{const c=document.createElement('div');if(typeof x==='object'){c.textContent=x.text;c.className=x.cls||'';}else c.textContent=x;row.append(c)});return row;}));}function band(id,parts,total){$('#'+id).replaceChildren(...parts.map((p,i)=>{const e=document.createElement('i');e.style.width=(100*p.value/total)+'%';e.className=i%2?'gold':'on';e.title=p.name+': '+p.value;return e}));}function intervals(id,items,total){$('#'+id).replaceChildren(...items.map(p=>{const row=document.createElement('div');row.className='interval';const bar=document.createElement('i');bar.style.left=(100*p.start/total)+'%';bar.style.width=(100*(p.end-p.start)/total)+'%';bar.className=p.cls||'';const label=document.createElement('span');label.textContent=p.label;row.append(bar,label);return row;}));}function plot(id,series,xr,yr,opts={}){const e=$('#'+id),X=x=>42+(x-xr[0])/(xr[1]-xr[0])*298,Y=y=>175-(y-yr[0])/(yr[1]-yr[0])*148;let out='<defs><clipPath id=\"clip-'+id+'\"><rect x=\"42\" y=\"27\" width=\"298\" height=\"148\"/></clipPath></defs>';for(let i=0;i<3;i++){let x=xr[0]+i*(xr[1]-xr[0])/2,y=yr[0]+i*(yr[1]-yr[0])/2;out+='<path class=\"gridline\" d=\"M '+X(x)+' 27V175M42 '+Y(y)+'H340\"/><text x=\"'+X(x)+'\" y=\"194\" text-anchor=\"middle\">'+esc(opts.xfmt?opts.xfmt(x):Number(x.toFixed(2)))+'</text><text x=\"36\" y=\"'+(Y(y)+4)+'\" text-anchor=\"end\">'+esc(opts.yfmt?opts.yfmt(y):Number(y.toFixed(2)))+'</text>';}out+='<g clip-path=\"url(#clip-'+id+')\">';for(const s of series){out+='<path fill=\"none\" stroke=\"'+(s.color||'var(--accent)')+'\" stroke-width=\"2.5\" '+(s.dash?'stroke-dasharray=\"5 4\"':'')+' d=\"'+s.pts.map((p,i)=>(i?'L':'M')+X(p[0]).toFixed(2)+','+Y(p[1]).toFixed(2)).join(' ')+'\"/>';}for(const p of opts.points||[])out+='<circle cx=\"'+X(p[0])+'\" cy=\"'+Y(p[1])+'\" r=\"4\" fill=\"var(--second)\" stroke=\"var(--paper)\" stroke-width=\"1.5\"/>';if(opts.cursor!==undefined)out+='<path d=\"M'+X(opts.cursor)+' 27V175\" stroke=\"var(--muted)\" stroke-dasharray=\"3 3\"/>';e.innerHTML=out+'</g>';e.dataset.curves=JSON.stringify(series.map(s=>s.pts));}const curve=(fn,lo,hi,n=120)=>Array.from({length:n+1},(_,i)=>{const x=lo+(hi-lo)*i/n;return[x,fn(x)]});function inputs(draw){document.querySelectorAll('input,select').forEach(e=>{e.addEventListener('input',draw);e.addEventListener('change',draw)});draw()}const n=id=>+$('#'+id).value;const show=(id,v,d=3)=>set(id,Number(v.toFixed(d)));function bars(id,values,max=1){$('#'+id).className='bars';$('#'+id).innerHTML=values.map(v=>'<div class=\"bar-row\"><span>'+esc(v.label)+'</span><div class=\"bar-track\"><i class=\"'+(v.cls||'')+'\" style=\"width:'+Math.max(0,Math.min(100,v.value/max*100))+'%\"></i></div><output>'+esc(v.text??(v.value*100).toFixed(1)+'%')+'</output></div>').join('')}function softmax(z,T=1){let max=Math.max(...z),w=z.map(x=>Math.exp((x-max)/T)),sum=w.reduce((a,b)=>a+b,0);return w.map(x=>x/sum)}function draw(){let a=n('attempt'),v=n('version'),e=$('#evidence').checked,ok=a===2&&v===4&&e;set('attempt-value',a);set('version-value','v'+v);table('checks',[[t('current'),'T / 2 / v4'],[t('candidate'),'T / '+a+' / v'+v],[t('attempt'),a===2?'✓':'×'],[t('version'),v===4?'✓':'×'],[t('evidence'),e?'✓':'×'],[t('accepted'),ok?'✓':'×']]);set('explanation',t('explain'));document.body.dataset.accepted=ok;}inputs(draw);","audio":false,"strings":{"accepted":"Integration permitted","attempt":"Result attempt","candidate":"Received result","checks":"Integration conditions","current":"Current task","evidence":"Acceptance report passes","explain":"An old attempt may arrive after a new one. Last-arrival-wins can revive stale output; checking attempt and input version separates late success from current success.","heading":"Why reject a successful worker result?","intro":"Choose the result’s attempt and input version; compare with the current task.","reset":"Reset","scope":"Task T is fixed at attempt 2, input v4. Every candidate claims success for T; attempt, version and report vary.","scopeLabel":"Model scope and assumptions","version":"Result input version"}}
Orchestration Requires Recovery Semantics
The Coordinator should save the task ID, attempt number, input version, status, and artifact location for each sub-task. Status should distinguish at least between queued, running, completed, accepted, failed, cancelled: Worker completion only means a result was produced; accepted means the Coordinator has confirmed it is available for overall delivery.
Assume Attempt 1 times out, and the Coordinator launches Attempt 2; later, the stale result from Attempt 1 arrives. If you only accept based on sub-task name, the old content will overwrite the new one. You need to verify late results against attempt numbers and input versions, and if necessary, keep them as references without automatically publishing them.
Cancellation does not guarantee that old Workers stop writing immediately. In shared resource scenarios, control commit permissions, for example, by having the Integrator verify the current valid attempt or version before writing to the authoritative artifact; otherwise, a Worker displayed as cancelled in the interface might still overwrite files in the background. Cross-executor state rules echo the conditional updates in Memory and State.
Failure
Confirm First During Recovery
Worker disconnected
Are there completed artifacts, and is execution still possible?
Coordinator restart
Which tasks are accepted, and which results are unknown?
Sub-task restarted
Will two attempts write to the same resource?
Failure during merge
Which parts are persisted, and can they be recovered or rolled back?
Lost response to external side effects
Was the business operation actually completed? Do not just look at thread status.
How to Judge if Multi-Agent Actually Provides Benefits
Compare single-Agent, single-Agent parallel tools, and Multi-Agent using the same task set, keeping tool permissions, input evidence, and acceptance criteria as consistent as possible. In addition to task success rate and total latency, record the Main Agent's coordination time, proportion of duplicate work, number of conflicts, failure retries, and total costs.
If Workers are fast but the Main Agent spends a long time clarifying and merging, the bottleneck is task decomposition or result contracts; if two Workers always query the same materials, the scopes might overlap; if integration always fails after merging, check shared interfaces and integration tests. If single-Agent batch tools achieve the same effect, there is no need to increase maintenance costs just for the sake of having more roles.
More detailed metrics and per-task tracking are expanded in Evaluation and Observability. The unit of evaluation should be the user's complete task, not just counting how many Agents were started or how many messages were generated.