AI Wiki中文/EN

Agent orchestration: who decides what runs next, and when to stop

智能体编排

Treat orchestration as control over a task graph: compute critical paths, derive what checking and retrying buy, and expose correlated failures and runaway conversations in a scripted simulator.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A report with six steps and three possible owners

Suppose a team wants an automated system to write a short market report. Someone must plan the outline, three searches can run independently, a merge step combines them, and a final check looks for unsupported claims. The individual steps could be done by language-model calls, ordinary programs, or people. Agent orchestration is the layer that decides which step runs next, who runs it, what it receives, whether its output is accepted, and when the whole job stops.

The first baseline is not an agent at all. A fixed script that calls six functions in a predetermined order is easy to test, cheap and predictable. Anthropic’s engineering guide draws the line this way: in a workflow, models and tools are coordinated through predefined code paths; in an agent, the model itself directs its process and tool use. Its orchestrator–workers pattern sits in between: a central model decomposes the input and delegates subtasks that were not fixed in advance. The guide recommends starting with the simplest arrangement that works and adding complexity only when it demonstrably improves outcomes. Workflows versus agents

This article asks a narrower engineering question than “which framework is best”: given a task graph, unreliable steps, a checker and a budget, what does an orchestrator actually buy, and what can it not fix? Message formats belong to agent communication; fixed patterns such as chaining or routing belong to agent workflows. Here the subject is the control decisions themselves. All numbers below come from an original scripted simulation; no model, tool or network is called, and the success probabilities are invented parameters.

Control over a task graph

Write the job as a directed acyclic graph G=(V,E). Each node v is a subtask with duration d_v, and an edge u→v means v needs u’s output. A single agent that performs every step itself takes the sum of durations. An orchestrator that can dispatch independent nodes concurrently is limited by the longest dependency path:

Tseq=∑v∈Vdv,Tpar=max⁡π∈P∑v∈πdvT_{\mathrm{seq}}=\sum_{v\in V} d_v,\qquad T_{\mathrm{par}}=\max_{\pi\in\mathcal P}\sum_{v\in\pi} d_v

Here 𝒫 is the set of source-to-sink paths. In our report graph the durations are plan 1, three searches 3, 2 and 4, merge 2 and check 1. The sequential time is 13 units; the critical path plan→search_c→merge→check takes 1+4+2+1=8. Parallel dispatch cannot beat 8 no matter how many workers exist, which is the same bound as in ordinary parallel scheduling. It also ignores the time an orchestrator spends deciding, which is not free when the orchestrator is itself a model call.

Speed is rarely the main problem. Suppose every subtask succeeds independently with probability p_v and nothing checks the results. The job is correct only if all steps are:

Pchain=∏v∈VpvP_{\mathrm{chain}}=\prod_{v\in V} p_v

With six steps at p=0.8, the product is 0.8⁶≈0.2621. Long pipelines of individually decent steps are fragile. This is the mechanism behind the guide’s warning that autonomous agents can compound errors. Cost and compounding errors

An orchestrator can add a checker and a retry budget. Let a checker flag a wrong result with probability δ, never reject a correct one, and allow r retries. Attempt j+1 happens only if the previous j attempts were all wrong and all caught, which has probability ((1−p)δ)ʲ. Summing the chance that such an attempt is correct, and the chance that it happens at all, gives

sv=pv∑j=0r((1−pv) δ)j,E[Av]=∑j=0r((1−pv) δ)js_v=p_v\sum_{j=0}^{r}\big((1-p_v)\,\delta\big)^j,\qquad \mathbb E[A_v]=\sum_{j=0}^{r}\big((1-p_v)\,\delta\big)^j

where s_v is the probability that the accepted output is correct and A_v counts worker attempts. With δ=1 the first expression reduces to 1−(1−p)^(r+1): p=0.8 and r=2 give 0.992 per step and 0.992⁶≈0.9529 for the job. With δ=0.9 the step value is 0.8×(1+0.18+0.0324)=0.96992 and the job value is about 0.8326. Letting r grow without bound gives p/(1−(1−p)δ), which is 0.9756 per step for δ=0.9. Retries cannot push reliability above the ceiling set by the checker: an undetected error is accepted on the first try and never retried.

The same derivation shows the cost. If the checker is a separate call after each attempt, a step uses 2𝔼[A_v] calls. For δ=1 that is 2×1.24=2.48 calls per step, or 14.88 for the job instead of 6. The orchestrator turns a reliability problem into a budget problem, so the budget must be stated before results are compared.

The formula also hides its key assumption: attempts fail independently. If one worker fails every time on a particular kind of input—because it lacks a tool, misreads a format or always takes the same wrong path—then retrying the same worker gives p=0 on every attempt and s_v=0 for any r. Useful retry policies therefore change something: the worker, the prompt, the tool, the input split, or a human checkpoint.

Who makes these decisions? AutoGen’s paper describes two styles. In the first, every conversable agent has send, receive and generate-reply interfaces, and once an agent receives a message it automatically replies unless a termination condition is met; the authors describe this auto-reply mechanism as decentralized, with no separate control plane. In the second, a GroupChatManager repeatedly selects a speaker, collects that speaker’s response and broadcasts it to the group; the paper’s pilot study on 12 hand-written tasks used a role-play prompt for speaker selection. Control can be expressed in natural language, such as a system message telling an assistant to reply with a termination word, or in code, such as a maximum number of automatic replies or a human-input mode. Conversation programming and the group-chat manager

Both styles need explicit stopping rules. CAMEL’s role-playing framework, in which an AI user gives instructions and an AI assistant answers, introduced an end-of-task token because without it the two agents could fall into a loop of thanking each other; its appendix also lists role flipping, an assistant repeating instructions and “flake” replies that promise action without doing it. Termination token and failure examples A turn cap is the last line of defence, but a cap reached is a failure signal to record, not a successful completion.

A scripted orchestrator with checkers, retries and caps

The program below encodes the six-node graph, simulates each attempt as a seeded Bernoulli draw and lets a checker catch a wrong result with probability δ. Attempt time is charged to the node, so retries lengthen the makespan. A “hard” setting makes one search fail every time for its primary worker, with an optional fallback worker on the final retry. A final function runs two scripted chat agents with and without honouring a stop token. Python’s standard library only; it finishes in well under a second.

"""Original orchestration simulator with scripted workers; no LLM, tool or network is called.
Success probabilities are invented parameters, not measurements of any model."""
import random
import statistics

DURATION = {'plan': 1, 'search_a': 3, 'search_b': 2, 'search_c': 4, 'merge': 2, 'check': 1}
DEPENDS = {'plan': [], 'search_a': ['plan'], 'search_b': ['plan'], 'search_c': ['plan'],
           'merge': ['search_a', 'search_b', 'search_c'], 'check': ['merge']}
ORDER = ['plan', 'search_a', 'search_b', 'search_c', 'merge', 'check']


def makespan(time_of):
    finish = {}
    for task in ORDER:  # ORDER is a topological order of the DAG
        finish[task] = max((finish[d] for d in DEPENDS[task]), default=0) + time_of[task]
    return finish['check']


def run_step(rng, p, retries, detect, fallback_p=None):
    """Attempt one subtask; a checker catches a wrong result with probability detect.
    Returns (correct, worker attempts, checker calls)."""
    attempts = checks = 0
    for k in range(retries + 1):
        prob = fallback_p if (fallback_p is not None and k == retries) else p
        attempts += 1
        ok = rng.random() < prob
        if detect is None:
            return ok, attempts, checks
        checks += 1
        if ok or rng.random() >= detect:
            return ok, attempts, checks
    return False, attempts, checks


def simulate(trials, seed, p, retries, detect, hard=None, fallback_p=None):
    rng = random.Random(seed)
    wins, calls, spans = 0, [], []
    for _ in range(trials):
        good, used, time_of = True, 0, {}
        for task in ORDER:
            prob = 0.0 if task == hard else p
            ok, attempts, checks = run_step(rng, prob, retries, detect, fallback_p if task == hard else None)
            good &= ok
            used += attempts + checks
            time_of[task] = DURATION[task] * attempts
        wins += good
        calls.append(used)
        spans.append(makespan(time_of))
    return wins / trials, statistics.mean(calls), statistics.mean(spans)


def formula(p, retries, detect):
    if detect is None:
        return p ** len(ORDER)
    step = p * sum(((1 - p) * detect) ** j for j in range(retries + 1))
    return step ** len(ORDER)


def chat(max_turns, honour_stop_token):
    """Two scripted agents that keep thanking each other unless a stop token is honoured."""
    script = ['answer', 'TERMINATE', 'thanks', 'you are welcome']
    for turn in range(max_turns):
        message = script[min(turn, 1)] if honour_stop_token else script[2 + turn % 2]
        if honour_stop_token and message == 'TERMINATE':
            return turn + 1, 'stop_token'
    return max_turns, 'turn_cap'


if __name__ == '__main__':
    print('sequential time', sum(DURATION.values()), 'critical path', makespan(DURATION))
    settings = [('no check', 0.8, 0, None), ('perfect check, 2 retries', 0.8, 2, 1.0),
                ('90% check, 2 retries', 0.8, 2, 0.9)]
    for name, p, r, d in settings:
        rate, calls, span = simulate(20000, 11, p, r, d)
        print(f'{name}: formula {formula(p, r, d):.4f}, simulated {rate:.4f}, mean calls {calls:.3f}, '
              f'mean makespan {span:.3f}')
    for name, fb in (('same worker retries', None), ('fallback worker on last retry', 0.7)):
        rate, calls, span = simulate(20000, 12, 0.8, 2, 1.0, hard='search_c', fallback_p=fb)
        print(f'hard search_c, {name}: simulated {rate:.4f}, mean calls {calls:.3f}, mean makespan {span:.3f}')
    print('chat without stop token', chat(12, False), 'with stop token', chat(12, True))
Recorded output
sequential time 13 critical path 8
no check: formula 0.2621, simulated 0.2661, mean calls 6.000, mean makespan 8.000
perfect check, 2 retries: formula 0.9529, simulated 0.9529, mean calls 14.862, mean makespan 10.387
90% check, 2 retries: formula 0.8326, simulated 0.8294, mean calls 14.523, mean makespan 10.118
hard search_c, same worker retries: simulated 0.0000, mean calls 18.421, mean makespan 16.980
hard search_c, fallback worker on last retry: simulated 0.6715, mean calls 18.422, mean makespan 16.976
chat without stop token (12, 'turn_cap') with stop token (2, 'stop_token')

Each row uses 20,000 synthetic jobs. Without a checker, 26.61% of jobs are fully correct against a formula value of 26.21%, using exactly six calls and the critical-path makespan of 8. A perfect checker with two retries raises the rate to 95.29%, matching the formula, but the mean number of calls rises to 14.862 (formula 14.88) and the mean makespan to 10.387 because retries on the critical path delay everything behind them. With a 90% checker the simulated rate is 82.94% against 83.26% from the formula; the remaining gap is Monte Carlo noise of roughly ±0.26 percentage points (one standard error), not a modelling difference.

The correlated-failure rows are the point of the experiment. When search_c always fails for its worker, two retries (three attempts) with a perfect checker give 0 successful jobs while spending 18.42 calls per job: the checker correctly rejects every attempt, and the orchestrator correctly gives up, but nothing changed between attempts. Switching to a fallback worker with success probability 0.7 on the final attempt gives 0.6715, close to the hand value 0.7×0.992⁵≈0.6724. The two scripted chatters never stop on their own; with no stop token they hit the 12-turn cap, and with one they stop after 2 turns.

Complexity is modest: each simulated job visits |V| nodes with at most r+1 attempts, so the simulation costs O(N|V|(r+1)) for N trials, and the makespan computation is a single pass over a topological order, O(|V|+|E|).

What the model leaves out

Real attempts are not independent coin flips. Language-model errors correlate across retries with the same prompt and context, so the formula’s s_v is an optimistic upper bound unless something changes between attempts. Real checkers also reject correct work (false alarms), which this model sets to zero; adding them would increase calls and could lower success when the retry budget runs out on good outputs.

The simulator charges zero time for orchestration decisions and checking, and treats every call as equal cost. In practice the planner or group-chat speaker selector is itself a model call with latency, token cost and its own failure modes, such as picking the wrong speaker or decomposing the task badly. AutoGen’s own discussion lists agent topology and the balance between automation and human control among open questions, notes that adding agents and other degrees of freedom may bring new safety challenges, and its ethics statement flags letting agents execute code or install packages as risky. Discussion and ethics statement

Orchestration also moves accountability. When several agents share a transcript, a reviewer must be able to reconstruct who produced which claim, what was checked and why the run stopped. A system whose only evidence is a final answer and a turn count is hard to audit. The numbers here describe a toy with invented parameters; they say nothing about any model’s real success rate.

Exercises

  1. In the report graph, why does adding a fourth parallel search worker not reduce the 8-unit makespan?

    Answer: The makespan is set by the longest dependency path plan→search_c→merge→check, which is 1+4+2+1=8. Extra workers only help nodes that are waiting for a free worker; none are. Shortening search_c or splitting it into independent parts would change the critical path.

  2. A step succeeds with p=0.6. A perfect checker is used with r=1 retry. Compute the step’s success probability and its expected number of worker attempts.

    Answer: With δ=1, s=0.6×(1+0.4)=0.84, equivalently 1−0.4²=0.84. 𝔼[A]=1+0.4=1.4 attempts. If the checker is a separate call, the step uses 2.8 calls on average.

  3. A colleague says: “With enough retries, a 90% checker gives near-perfect reliability.” Give the limit for p=0.8 and explain the counterexample.

    Answer: As r→∞, s→p/(1−(1−p)δ)=0.8/(1−0.18)≈0.9756. Every wrong output that slips past the checker is accepted at once, so 2.4% of steps end wrong however large r is. Raising δ, or adding a different kind of verification, moves the ceiling; retries alone do not.

  4. A support team has a fixed triage sequence that has worked for a year, and someone proposes replacing it with a dynamic group chat of four agents. What evidence should decide the change?

    Answer: Compare both on the same held-out tickets with success defined in advance, measuring correctness, calls or tokens, latency, how often runs hit caps, and how failures can be traced. The fixed workflow is the baseline. Dynamic speaker selection is worth its cost only if it improves outcomes on cases the fixed path handles badly, and its stop conditions, budgets and human checkpoints must be specified before deployment.

Reading the sources

The AutoGen paper (arXiv v2, October 2023) is best read for its two abstractions—conversable agents and conversation programming—and for how it separates computation from control flow. Its application results come from the authors’ own experiments, and the group-chat result is a pilot on 12 tasks; they are not independent benchmarks. AutoGen Anthropic’s December 2024 guide is a practitioner taxonomy rather than an experiment; it is useful for naming the options and for its advice to prefer simple, transparent arrangements. Building effective agents CAMEL documents concrete conversation failures and a termination convention for two-agent role-play. CAMEL

Open questions remain: how to choose decomposition granularity, how to make retries change something meaningful, how to budget orchestrator calls, and how to evaluate orchestration separately from the quality of the underlying workers. A careful report states the task graph, the checker’s measured miss and false-alarm rates, the retry and turn limits, and the full distribution of costs.

Make a prediction, then check

A checker misses 10% of wrong outputs and each step succeeds with probability 0.8. What happens to per-step reliability as retries grow without bound?

Choose one answer

Learning objectives

  • Express orchestration as dispatch, checking, retry and stopping decisions over a task graph, and compute critical paths, chain success and call budgets.
  • Distinguish decentralized auto-reply from central speaker selection, and recognize correlated failures, checker ceilings and runaway conversations.

Prerequisites & connections

Explore related knowledge →

References

  1. AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation — scoped arXiv v2
    Qingyun Wu; Gagan Bansal; Jieyu Zhang; Yiran Wu; Beibin Li; Erkang Zhu; Li Jiang; Xiaoyun Zhang; Shaokun Zhang; Jiale Liu; Ahmed Awadallah; Ryen W. White; Doug Burger; Chi Wang · 2023
  2. Building effective agents — scoped engineering guide
    Erik Schluntz; Barry Zhang (Anthropic) · 2024
  3. CAMEL: Communicative Agents for “Mind” Exploration of Large Language Model Society — scoped arXiv v2
    Guohao Li; Hasan Abed Al Kader Hammoud; Hani Itani; Dmitrii Khizbullin; Bernard Ghanem · 2023

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Claude · 2026-12-02 · Independent AI check (Claude subagent, not the author; not a human or expert review). Ran example.py with python3 (0.3 s) and diffed it against example.stdout.txt (identical); confirmed the python block in en.mdx and zh.mdx is byte-identical to example.py and that the display equations match across languages. Re-derived by hand 0.8^6=0.2621, 1-0.2^3=0.992 and 0.992^6=0.9529, 0.8×1.2124=0.96992 and its sixth power 0.8326, the retry limit p/(1-(1-p)δ)=0.8/0.82=0.97561, 2E[A]=2.48 calls per step and 14.88 per job, the fallback value 0.7×0.992^5=0.6724, the critical path 1+4+2+1=8, the Monte Carlo standard error (0.26 pp) and all four exercise answers. Re-read the sources myself: the Anthropic page by downloading its HTML with curl and reading the full stripped text (noting the live copy contains post-publication edits), and the AutoGen v2 PDF (pp. 1, 3–5, 9–10) and CAMEL v2 PDF (pp. 1–2, 7–9) via pdftotext. Compared zh and en section by section and checked data.json IDs against src/data/catalogue.txt. Did not read AutoGen's results sections or appendices, did not verify the December 2024 original wording of the Anthropic page, and did not render the MDX.

  • Code output matches the recording; both code blocks are byte-identical to example.py; prose numbers match the output.
  • Hand-verified the 0.9756 retry ceiling (0.8/0.82=0.97561) and all other formulas and exercise answers; one standard error is 0.26 pp.
  • Downloaded and read the full Anthropic page text; all four cited points are present in the copy read, but the live page contains post-publication edits.
  • AutoGen and CAMEL attributions match the pages read; zh and en correspond section by section.

Source locations checked:

  • AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation — scoped arXiv v2 · arXiv v2 PDF via pdftotext: p.1 (title, authors, abstract, v2 date 3 Oct 2023), pp.3–5 (Sec. 2.1 conversable agents, LLM/human/tool backends, AssistantAgent/UserProxyAgent; Sec. 2.2 conversation programming, computation vs control flow, auto-reply 'without any extra control plane', NL and programming-language control incl. TERMINATE and max auto replies; GroupChatManager selects speaker and broadcasts), p.9 (A5 dynamic group chat: select/collect/broadcast, role-play speaker prompt, 12-task pilot; A6 board-agent ablation; Sec. 4 Discussion), p.10 (future work: topology, automation vs human control, safety; ethics statement incl. code-execution risk). NOT read: Sec. 3 A1–A4 results, appendices B–D, figures visually, library code. Checker re-read the same pages via pdftotext on 2026-12-02 and confirmed the auto-reply/no-control-plane passage, TERMINATE and max-auto-reply controls, the GroupChatManager select/collect/broadcast loop, the 12-task pilot, the Discussion (topology, automation vs human control, new safety challenges as agents increase) and the ethics bullet on code execution/package installation; the article's limitations sentence was reworded to keep these two points separate.
  • Building effective agents — scoped engineering guide · Writer: read only via WebFetch's model-generated summary. Checker (2026-12-02): fetched https://www.anthropic.com/engineering/building-effective-agents with curl, stripped HTML to plain text (~19 KB) and read all of it: 'What are agents?' (workflows = predefined code paths; agents = LLMs dynamically direct their own processes and tool usage), 'When (and when not) to use agents' (find the simplest solution, increase complexity only when needed), 'Workflow: Orchestrator-workers' (central LLM dynamically breaks down tasks; key difference from parallelization is that subtasks are not pre-defined), 'Agents' (higher costs and potential for compounding errors; stopping conditions such as maximum iterations; human checkpoints), 'Combining and customizing' (add complexity only when it demonstrably improves outcomes), Summary, Appendices 1–2. The live page carries post-publication edits (header note on changed tooling; later framework/model examples), so the December 2024 original wording was not verified. Figures/diagrams not inspected. Article wording adjusted to 'complexity ... demonstrably improves outcomes' to match the page.
  • CAMEL: Communicative Agents for “Mind” Exploration of Large Language Model Society — scoped arXiv v2 · arXiv v2 PDF via pdftotext: p.1 (abstract, v2 date 2 Nov 2023, NeurIPS 2023 footer), p.2 (challenges: role flipping, assistant repeating instructions, flake replies, infinite loop; contributions), p.5 (AI user/assistant roles, Eq. 1–4 message set M_t, critic-in-the-loop, inception prompting P_T/P_A/P_U), p.7 (flake responses, 'Next request', <CAMEL_TASK_DONE> end token and the thank-you loop), p.9 (Table 1: AI Society human eval 13.3% draw / 10.4% gpt-3.5 / 76.3% CAMEL from 453 responses; GPT-4 eval 4.0/23.0/73.0; Code GPT-4 eval 0/24/76), p.28 (Appendix G challenge examples). NOT read: other appendices, Misalignment dataset, HumanEval results, code.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.