Microsoft Agent Framework: when one agent becomes many

Microsoft Agent Framework: when one agent becomes many

Leia em português: Microsoft Agent Framework: quando um agente vira muitos

Picture an agent that summarizes production incidents. The team splits it into three specialists, research, analysis and writing, and then into six. Each one rereads what the previous ones wrote; a coordinator, if there is one, reads everything every round; and, without a limit, nothing says when the conversation ends. The case is illustrative, but the pattern is real: splitting one agent into several trades one call for a conversation. In the example run locally in this article, three agents in sequence make 3 calls and read 393 input tokens; the same three under a Magentic manager make 10 calls and read 5,871.

Coordination is not free

What is agent orchestration in the Agent Framework?

It is the layer that decides how several agents work on the same task. The framework ships five ready-made patterns, each one a builder: sequential, in a queue; concurrent, in parallel; handoff, where one agent passes the conversation to another; group chat, a circle with an orchestrator in the middle; and Magentic, with a manager that plans. Each pattern multiplies a different part of the bill, and that is what the article measures.

The article on A2A covers agents that cross a trust boundary. Here the focus is coordination between agents in the same process and the same team, not communication across trust boundaries, which is the subject of A2A.

Piece State on October 23, 2026 What it changes
Version 1.0, .NET and Python Production-ready since April 3, 2026; Go in public preview The blog speaks of stable APIs and long-term support
The five orchestrations Stable support, according to the blog The API is stable; the cost depends on the pattern and on your use
Magentic The sources disagree The blog and the package (Production/Stable) say stable; Learn says that outside the original four-agent design it is untested
Autonomous handoff Experimental Without it, the handoff waits for a person
Default brakes Group chat: none; Magentic: 3 stalls, no cap on rounds or resets; workflow: 100 iterations Without a limit of yours, only the workflow ceiling ends an endless loop
Versions measured Core 1.23.0 and orchestrations 1.4.0, from the October 22, 2026 tag The orchestration code changes between versions, as the October 15, 2026 release shows

Sources checked on October 23, 2026. The table summarizes the documentation and code read on that date. The example in the hands-on section was run locally; nothing here was measured with a real model, in a Foundry project or in a tenant.

The problem it solves

There are good reasons to split an agent. The agents-as-tools page says that tool selection gets worse when an agent accumulates tools, and that each agent can use a different model, a larger one for reasoning and a smaller one for simple work. The same page records the cost: each delegation is a full agent invocation, and nested invocations add up. The map below avoids three mistakes: budgeting per agent instead of per pattern, relying on a brake the builder does not bring and reading the round limit as a cost limit.

Board with five rows and three columns, one row per orchestration pattern: what it multiplies, the brake the framework offers and what the example measured with three agents. Green marks what ends when the agents end; amber, what stops when an agent or a person decides; pink, what has no ceiling by default and asks for a limit of your own.
Five patterns, three questions, with the numbers for three agents in the local example. Green ends with the agents, amber stops when an agent or a person decides, pink has no ceiling by default. Click to enlarge.

How it works — step by step

  1. Start with one agent. The overview says to use a function when it solves the task, and the workflows journey recommends trying the simplest pattern first.
  2. Measure the baseline: calls and input tokens of the single agent on your task. In the example, 1 call and 31 tokens.
  3. Choose by what the pattern multiplies, not by the shape of the team: rereading (sequential and group chat), width (concurrent), tool definitions (handoff) or planning (Magentic).
  4. Set the brake at creation: max_rounds or termination_condition in group chat; max_round_count, max_stall_count and max_reset_count in Magentic; termination_condition and, in autonomous mode, turn_limits in handoff.
  5. Count calls and tokens in your code, with a ceiling that kills the run. The example does this with CALL_BUDGET.
  6. Decide the state: if a failure midway should resume from the last checkpoint, the workflow receives a CheckpointStorage at creation.
  7. Test the stop with a fake chat client before the real model: no network and no bill.

A use case: an incident summary

The agent receives an incident and returns a summary with a containment action. In the example, the task is the sentence Summarize the checkout latency incident and propose a containment action., and each agent returns the same fixed answer, 400 characters long, about 100 tokens. Whoever budgets the design asks four questions, and each has a field in the JSON:

Question for whoever budgets JSON field Note
How many times is the model called? calls Each call of the fake client, including the coordinator’s
How much does the model read? input_tokens chars // 4 estimate over instructions, messages and tools; no output tokens
How much of that is the coordinator’s? coordinator_tokens Sum of the aggregator, orchestrator or manager calls
How did the run end? ended answer, waiting for a person, the framework’s stop sentence or the exception

In practice: the same job, nine arrangements

The example runs the same task in nine arrangements, with three and with six agents, plus four limit scenarios. It did not run with a real model, in a Foundry project or in a tenant: a fake chat client returns fixed answers and records every call. It shows the shape of the bill, not the cost, the latency or the quality of a real model. The code stays in English in both languages.

I measured with agent-framework-core 1.23.0 and agent-framework-orchestrations 1.4.0, on Python 3.12.10. The package mirror in my environment only had up to 1.22.0, so I installed both from the python-1.23.0 tag. Input tokens are an estimate (chars // 4), not a tokenizer count, over instructions, messages and tool definitions; there are no output tokens. The fake manager and orchestrator never make mistakes, so the Magentic numbers are a floor. The three blocks form a single program: save them in one file, in order, and run it with python.

The first block defines the task, the fixed answer and the fake client. CALLS gets one row per call, and CALL_BUDGET kills a run that goes over 300 calls.

import asyncio
import inspect
import json
import re
from collections.abc import Mapping, Sequence
from typing import Any

from agent_framework import (
    Agent,
    BaseChatClient,
    ChatMiddlewareLayer,
    ChatResponse,
    Content,
    FunctionInvocationLayer,
    Message,
)
from agent_framework.orchestrations import (
    ConcurrentBuilder,
    GroupChatBuilder,
    HandoffBuilder,
    MagenticBuilder,
    SequentialBuilder,
)

TASK = "Summarize the checkout latency incident and propose a containment action."
ANSWER = "finding " * 50
ROLES = ("research", "analysis", "writing", "review", "risk", "summary")
COORDINATORS = {"aggregator", "orchestrator", "manager"}
CALLS: list[dict] = []
CALL_BUDGET = 300


class BudgetExceeded(Exception):
    pass


class FakeModel(FunctionInvocationLayer, ChatMiddlewareLayer, BaseChatClient):
    def __init__(self, kind: str = "agent", rounds: int = 3, stalls: bool = False, **kwargs: Any) -> None:
        super().__init__(**kwargs)
        self.kind, self.rounds, self.stalls = kind, rounds, stalls
        self.turn = self.ledgers = 0

    def _inner_get_response(self, *, messages: Sequence[Message], stream: bool,
                            options: Mapping[str, Any], **kwargs: Any):
        if len(CALLS) >= CALL_BUDGET:
            raise BudgetExceeded(f"more than {CALL_BUDGET} model calls")
        tools = options.get("tools") or []
        texts = [m.text or "" for m in messages]
        chars = len(options.get("instructions") or "") + sum(map(len, texts)) + sum(
            len(json.dumps(t.to_json_schema_spec())) for t in tools)
        CALLS.append({"kind": self.kind, "tokens": chars // 4})
        self.turn += 1
        response = ChatResponse(messages=[Message(role="assistant", contents=self.move(messages, texts[-1], tools))],
                                model="fake-1")

        async def reply() -> ChatResponse:
            return response

        return reply()

    def move(self, messages: Sequence[Message], last: str, tools: list) -> list[Content]:
        if self.kind == "triage" and not any(m.role == "assistant" for m in messages):
            target = next(t.name for t in tools if t.name.endswith(ROLES[1]))
            return [Content.from_function_call(call_id="handoff", name=target, arguments={})]
        if self.kind == "orchestrator":
            done = self.turn > self.rounds
            decision = {"terminate": done, "reason": "enough", "final_message": "done" if done else None,
                        "next_speaker": None if done else ROLES[(self.turn - 1) % self.rounds]}
            return [Content.from_text(json.dumps(decision))]
        if self.kind == "manager" and "pure JSON format" in last:
            self.ledgers += 1
            finished = not self.stalls and self.ledgers > self.rounds
            ledger = {
                "is_request_satisfied": finished,
                "is_in_loop": False,
                "is_progress_being_made": not self.stalls,
                "next_speaker": ROLES[(self.ledgers - 1) % self.rounds],
                "instruction_or_question": "Continue.",
            }
            return [Content.from_text(json.dumps({key: {"reason": "n/a", "answer": value}
                                                 for key, value in ledger.items()}))]
        return [Content.from_text(ANSWER)]

The second block builds the five patterns. Handoff requires require_per_service_call_history_persistence=True on the agents; led_by_agent and magentic use an agent as the coordinator, and led_by_agent sets max_rounds=20 as a safety net.

def team(n: int, first: str = "agent", **options: Any) -> list[Agent]:
    return [Agent(client=FakeModel(first if index == 0 else "agent"), name=role, id=role,
                  description=f"The {role} specialist.",
                  instructions=f"You are the {role} specialist. Answer in 80 words.", **options)
            for index, role in enumerate(ROLES[:n])]


def coordinator(kind: str, **options: Any) -> Agent:
    return Agent(client=FakeModel(kind, **options), name=kind, id=kind, description=f"The {kind}.",
                 instructions=f"You are the {kind} of the team.")


def sequential(n: int, **options: Any):
    return SequentialBuilder(participants=team(n), **options).build()


def concurrent(n: int):
    return ConcurrentBuilder(participants=team(n)).build()


def concurrent_with_agent(n: int):
    summarizer = coordinator("aggregator")

    async def combine(results: list) -> str:
        return (await summarizer.run("\n".join(r.agent_response.text for r in results))).text

    return ConcurrentBuilder(participants=team(n)).with_aggregator(combine).build()


def handoff(n: int):
    agents = team(n, first="triage", require_per_service_call_history_persistence=True)
    return HandoffBuilder(participants=agents).with_start_agent(agents[0]).build()


def round_robin(n: int, **limits: Any):
    def next_speaker(state: Any) -> str:
        names = list(state.participants)
        return names[state.current_round % len(names)]

    return GroupChatBuilder(participants=team(n), selection_func=next_speaker, **limits).build()


def led_by_agent(n: int):
    return GroupChatBuilder(participants=team(n), orchestrator_agent=coordinator("orchestrator", rounds=n),
                            max_rounds=20).build()


def magentic(n: int, stalls: bool = False, **limits: Any):
    manager = coordinator("manager", rounds=n, stalls=stalls)
    return MagenticBuilder(participants=team(n), manager_agent=manager, **limits).build()

The third block measures and prints: measure runs one arrangement and returns calls, input tokens, the coordinator’s share and the ending; parameters lists, by inspection, the stop and cost parameters of each builder; main runs everything.

def text_of(output: Any) -> str:
    return (getattr(output[-1] if isinstance(output, list) else output, "text", "") or "").strip()


async def measure(label: str, n: int, workflow: Any = None) -> dict:
    CALLS.clear()
    ended = "answer"
    try:
        if workflow is None:
            await team(1)[0].run(TASK)
        else:
            result = await workflow.run(TASK)
            outputs = result.get_outputs()
            last = text_of(outputs[-1]) if outputs else ""
            if result.get_request_info_events():
                ended = "waiting for a person"
            elif last and not set(last.split()) <= {"finding", "done"}:
                ended = last
    except Exception as error:
        ended = type(error).__name__
    return {"arrangement": label, "agents": n, "calls": len(CALLS),
            "input_tokens": sum(call["tokens"] for call in CALLS),
            "coordinator_tokens": sum(call["tokens"] for call in CALLS if call["kind"] in COORDINATORS),
            "ended": ended}


def parameters() -> list[dict]:
    rows = []
    for builder in (SequentialBuilder, ConcurrentBuilder, HandoffBuilder, GroupChatBuilder, MagenticBuilder):
        methods = [builder.__init__] + [getattr(builder, name) for name in dir(builder) if name.startswith("with_")]
        names = {name for method in methods for name in inspect.signature(method).parameters}
        rows.append({"builder": builder.__name__,
                     "limits": sorted(n for n in names if re.search(r"max_|limit|stall|reset|termination", n)),
                     "cost": sorted(n for n in names if re.search(r"token|budget|cost|spend|price", n))})
    return rows


async def main() -> None:
    rows = [await measure("single agent", 1)]
    builders = [
        ("sequential", sequential),
        ("sequential, previous reply only", lambda n: sequential(n, chain_only_agent_responses=True)),
        ("concurrent", concurrent),
        ("concurrent, agent aggregator", concurrent_with_agent),
        ("handoff", handoff),
        ("group chat, round robin", lambda n: round_robin(n, termination_condition=lambda chat: len(chat) > n)),
        ("group chat, orchestrator agent", led_by_agent),
        ("Magentic", lambda n: magentic(n, max_round_count=10)),
    ]
    for label, build in builders:
        for n in (3, 6):
            rows.append(await measure(label, n, build(n)))
    limits = [
        await measure("group chat, no limit", 3, round_robin(3)),
        await measure("group chat, max_rounds=6", 3, round_robin(3, max_rounds=6)),
        await measure("Magentic, stalled, limits 10/3/2", 3,
                      magentic(3, stalls=True, max_round_count=10, max_stall_count=3, max_reset_count=2)),
        await measure("Magentic, stalled, default limits", 3, magentic(3, stalls=True)),
    ]
    report = {"arrangements": rows, "limits": limits, "parameters": parameters()}
    body = [f"  {json.dumps(key)}: [\n" + ",\n".join(f"    {json.dumps(row)}" for row in items) + "\n  ]"
            for key, items in report.items()]
    print("{\n" + ",\n".join(body) + "\n}")


asyncio.run(main())

The output, copied from the run:

{
  "arrangements": [
    {"arrangement": "single agent", "agents": 1, "calls": 1, "input_tokens": 31, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "sequential", "agents": 3, "calls": 3, "input_tokens": 393, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "sequential", "agents": 6, "calls": 6, "input_tokens": 1684, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "sequential, previous reply only", "agents": 3, "calls": 3, "input_tokens": 256, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "sequential, previous reply only", "agents": 6, "calls": 6, "input_tokens": 592, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "concurrent", "agents": 3, "calls": 3, "input_tokens": 93, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "concurrent", "agents": 6, "calls": 6, "input_tokens": 184, "coordinator_tokens": 0, "ended": "answer"},
    {"arrangement": "concurrent, agent aggregator", "agents": 3, "calls": 4, "input_tokens": 402, "coordinator_tokens": 309, "ended": "answer"},
    {"arrangement": "concurrent, agent aggregator", "agents": 6, "calls": 7, "input_tokens": 794, "coordinator_tokens": 610, "ended": "answer"},
    {"arrangement": "handoff", "agents": 3, "calls": 2, "input_tokens": 258, "coordinator_tokens": 0, "ended": "waiting for a person"},
    {"arrangement": "handoff", "agents": 6, "calls": 2, "input_tokens": 544, "coordinator_tokens": 0, "ended": "waiting for a person"},
    {"arrangement": "group chat, round robin", "agents": 3, "calls": 3, "input_tokens": 393, "coordinator_tokens": 0, "ended": "The group chat has reached its termination condition."},
    {"arrangement": "group chat, round robin", "agents": 6, "calls": 6, "input_tokens": 1684, "coordinator_tokens": 0, "ended": "The group chat has reached its termination condition."},
    {"arrangement": "group chat, orchestrator agent", "agents": 3, "calls": 7, "input_tokens": 2483, "coordinator_tokens": 2090, "ended": "answer"},
    {"arrangement": "group chat, orchestrator agent", "agents": 6, "calls": 13, "input_tokens": 8569, "coordinator_tokens": 6885, "ended": "answer"},
    {"arrangement": "Magentic", "agents": 3, "calls": 10, "input_tokens": 5871, "coordinator_tokens": 5526, "ended": "answer"},
    {"arrangement": "Magentic", "agents": 6, "calls": 16, "input_tokens": 11878, "coordinator_tokens": 10290, "ended": "answer"}
  ],
  "limits": [
    {"arrangement": "group chat, no limit", "agents": 3, "calls": 50, "input_tokens": 25050, "coordinator_tokens": 0, "ended": "WorkflowConvergenceException"},
    {"arrangement": "group chat, max_rounds=6", "agents": 3, "calls": 6, "input_tokens": 1686, "coordinator_tokens": 0, "ended": "The group chat has reached the maximum number of rounds."},
    {"arrangement": "Magentic, stalled, limits 10/3/2", "agents": 3, "calls": 20, "input_tokens": 10948, "coordinator_tokens": 10258, "ended": "Workflow terminated due to reaching maximum reset count."},
    {"arrangement": "Magentic, stalled, default limits", "agents": 3, "calls": 150, "input_tokens": 82514, "coordinator_tokens": 76864, "ended": "WorkflowConvergenceException"}
  ],
  "parameters": [
    {"builder": "SequentialBuilder", "limits": [], "cost": []},
    {"builder": "ConcurrentBuilder", "limits": [], "cost": []},
    {"builder": "HandoffBuilder", "limits": ["termination_condition", "turn_limits"], "cost": []},
    {"builder": "GroupChatBuilder", "limits": ["max_rounds", "termination_condition"], "cost": []},
    {"builder": "MagenticBuilder", "limits": ["max_reset_count", "max_round_count", "max_stall_count"], "cost": []}
  ]
}

In reading order: arrangements holds the nine arrangements; limits, four stop scenarios; parameters, the parameters the inspection found in each builder. Two tables summarize arrangements. With three agents:

Arrangement Calls Input tokens Coordinator share End
One agent 1 31 — Answer
Sequential 3 393 — Answer
Sequential, previous reply only 3 256 — Answer
Concurrent 3 93 — Answer
Concurrent, agent aggregator 4 402 77% Answer
Handoff 2 258 — Waits for a person
Group chat, round robin 3 393 — Stop condition
Group chat, orchestrator agent 7 2,483 84% Answer
Magentic 10 5,871 94% Answer

From the team of three to the team of six agents:

Arrangement Calls Input tokens Growth
Sequential 3 → 6 393 → 1,684 4.3×
Sequential, previous reply only 3 → 6 256 → 592 2.3×
Concurrent 3 → 6 93 → 184 2.0×
Concurrent, agent aggregator 4 → 7 402 → 794 2.0×
Handoff 2 → 2 258 → 544 2.1×
Group chat, round robin 3 → 6 393 → 1,684 4.3×
Group chat, orchestrator agent 7 → 13 2,483 → 8,569 3.5×
Magentic 10 → 16 5,871 → 11,878 2.0×

With three agents, the cheapest arrangement, concurrent, reads 93 tokens, three times the single agent (31); the most expensive, Magentic, reads 5,871, about 15 times the sequential run (393), 94% of it in the manager. The pattern weighs more than the number of agents: doubling the team multiplied the reading by at most 4.3. The fake answers are about 100 tokens; larger real answers increase the rereading, so the growth factors belong to the example, not to a law.

What each pattern multiplies

  • Sequential multiplies the rereading. By default, each agent consumes the full conversation from the previous one, so the last one reads everything that came before: 393 tokens with three agents, 1,684 with six. With chain_only_agent_responses=True, each one reads only the previous answer: 256 and 592. The price, which a separate test confirmed, is that only the first agent receives the task text.
  • Concurrent multiplies the width. Each agent reads only the task and its own instructions: 93 tokens with three, 184 with six. The default aggregator returns one message per participant, without calling the model; an agent that synthesizes, as in the page’s example, enters as an extra call that reads everything the others produced: 4 calls and 402 tokens with three agents, 77% of it the aggregator’s.
  • Handoff multiplies the tool definitions. The mesh connects the agents directly, with no orchestrator, and the framework registers the handoff tools in each agent. With the example’s full mesh, each call carries the definitions of the other n − 1 agents: 258 tokens with three, 544 with six, in the same two calls. And the handoff ends waiting for a person: if the agent does not pass the conversation on, the page says human input is required.
  • Group chat multiplies the rounds by the history. All agents see the full history, so round robin costs the same as the sequence: 393 and 1,684 tokens. With an orchestrator agent that chooses who speaks, a selection call enters each round, plus one to finish, each reading the history: 7 calls and 2,483 tokens with three agents, 84% of it the orchestrator’s; with six, 13 and 8,569.
  • Magentic multiplies the planning. In the example, the manager makes n + 4 calls for n agents: facts, plan, n + 1 progress ledgers and the final answer, and each ledger resends the full history. With three agents it was 10 calls and 5,871 tokens; with six, 16 and 11,878, 87% of it the manager’s. It is a floor: a real manager repeats the ledger, by default up to three attempts, when the JSON is invalid or names an agent that does not exist.

Who stops the conversation: the limits

Sequential and concurrent end when the agents end. Handoff stops and waits for a person; in autonomous mode, which the page describes as experimental, each agent runs up to 50 turns by default, and the code exposes the limit as turn_limits, in with_autonomous_mode. What the page describes was not executed.

Group chat and Magentic call for attention. GroupChatBuilder accepts max_rounds and termination_condition, neither with a default value, and the code warns that, without both, the conversation continues indefinitely; with an orchestrator of your own, the page says the builder’s two parameters are ignored. Magentic tolerates up to 3 stalls in a row before replanning, with no cap on rounds or resets by default. The four scenarios below test these stops; in the two Magentic ones, the fake manager never sees progress:

Scenario Calls Input tokens End
Group chat, no limit 50 25,050 WorkflowConvergenceException
Group chat, max_rounds=6 6 1,686 Round limit
Magentic stalled, limits 10/3/2 20 10,948 Reset limit
Magentic stalled, default limits 150 82,514 WorkflowConvergenceException

What stopped the two scenarios without a brake was the workflow’s own ceiling: 100 iterations per run. The runner raises WorkflowConvergenceException when the ceiling arrives with messages still to process, and group chat spends two iterations per round, so 100 iterations are 50 calls. A search for max_iterations in the orchestrations package found nothing: the builders keep the ceiling of 100. The ceiling is a safety net, not a budget: the stalled Magentic spent 150 calls and 82,514 tokens with the default limits, 7.5 times the 10,948 of the limits 10/3/2 scenario, and group chat with max_rounds=6 spent 1,686 tokens against 25,050 without a limit, about 15 times less.

Inspecting the builders shows where each brake lives, and that none has a token or cost parameter:

Builder Stop parameters Token or cost parameters
SequentialBuilder — —
ConcurrentBuilder — —
HandoffBuilder termination_condition, turn_limits —
GroupChatBuilder max_rounds, termination_condition —
MagenticBuilder max_reset_count, max_round_count, max_stall_count —

My reading: the round limit is not a cost limit; the token budget lives in your code.

State, checkpoint and resume

A failure midway through a long run should resume from the last checkpoint, not start over; the workflows journey cites this case, and the checkpoints page describes how: they are created at the end of each superstep and capture the state of all executors, the messages pending for the next superstep and the shared states. In Python, the workflow receives a CheckpointStorage at creation, and the resume runs the workflow with the checkpoint_id. There are three storages: in memory, for tests and short runs; in a file; and in Azure Cosmos DB, recommended for production and distributed workflows. What the page describes was not executed; a separate test checked only that the five builders accept checkpoint_storage at creation.

Two cautions the page records: with files, protecting the directory is the developer’s responsibility; and whoever cannot accept pickle serialization uses the in-memory storage or writes a CheckpointStorage of their own. My reading: a checkpoint does not lower the cost of a run that succeeds, it only avoids repeating what was already done after a failure; and, since it stores the executors’ state and the pending messages, retention and access call for the same decision that the article on tracing in Foundry asks for the recorded content.

To see what the workflow did, the framework emits spans: workflow.run, one per run; executor.process, one per executor that processes a message; and message.send, one per message sent from one executor to another. What the page describes was not executed.

How to choose the pattern

The table below is my reading, based on the pages and the measurements; it is not a framework rule.

Pattern When it fits What to watch
Sequential Steps that depend on the previous one, in fixed order The rereading: the last agent reads everything that came before
Concurrent Independent points of view on the same task The aggregator: if it is an agent, it is one call that reads everything
Handoff Triage where the owner of the conversation changes and a person steps in The tool definitions per call and autonomous mode, which is experimental
Group chat Refinement where everyone needs the history max_rounds or termination_condition, always
Magentic Open task that needs a plan The manager’s three limits and the cost of the manager itself

If no row fits, go back to step 1: maybe your case is a function, or an agent with the right tools.

Production best practices

  • Start with one agent and split only with a reason, such as tool selection getting worse with many tools.
  • Budget per pattern, not per agent. With three agents, the input ranged from 93 to 5,871 tokens depending on the pattern. After counting the calls, the number that matters is the cost per approved task, the subject of the article on AI FinOps.
  • Put a limit on every loop and count in your code. max_rounds or termination_condition in group chat, the manager’s three limits in Magentic and a call ceiling that kills the run, like the example’s CALL_BUDGET; the 100-iteration ceiling is only a safety net.
  • Cut the rereading where the step does not need it. chain_only_agent_responses=True took the sequential run from 393 to 256 tokens; the price is that only the first agent receives the task.
  • Treat the coordinator’s model as a cost decision. Each agent can use a different model, according to the agents-as-tools page, and the coordinator read 77% to 94% of the tokens in the three-agent arrangements. My reading: it is where a smaller model or a shorter prompt weighs most on the bill.
  • Decide the state before the incident. If resuming matters, choose the CheckpointStorage, who protects the directory and for how long the content stays stored.
  • Pin the version and redo the count. The 1.22.0 release touched Magentic’s replanning, the handoff’s zeroed limits and the ledger retry. My reading: running the example on every update is the regression test of the bill.

What has to be in place

The order below is causal, not chronological: each stage exists because the previous one is in place.

Foundation — the pattern’s cost is known. There is a one-agent baseline, and each candidate pattern was measured on the same task, with your number of agents.

It is in place when someone answers, for your case, how many calls and tokens each pattern makes and how much of that is the coordinator’s.

Production with context — every stop has an owner. Every group chat and every Magentic created has max_rounds, termination_condition or the manager’s three limits; a test with a fake client kills the run that goes over a call ceiling; state and resume are decided.

It is in place when an unbraked loop becomes a failing test, not a bill.

Scale and efficiency — the bill is reviewed at every change. The framework version is pinned, the example’s count runs on every update, and the coordinator’s model and prompt are reviewed, since it reads most of the tokens.

It is in place when an update that changes a count shows up in a test, not in the monthly bill.

Frequently asked questions (FAQ)

Does splitting one agent into several always cost more?

In the example, yes: no three-agent arrangement read fewer than 93 tokens, and the single agent read 31. The question is whether the split fixes a problem of the single agent, such as tool selection getting worse with many tools; if it does not, the documentation says to stay with the simplest one.

Does group chat stop by itself?

Only if you ask it to. Without max_rounds and without termination_condition, the code warns that the conversation continues indefinitely; in the example, what stopped the group chat with no limit was the workflow’s 100-iteration ceiling, at 50 calls.

Is the round limit a cost limit?

No. It limits the rounds, and each round rereads the history; the inspection of the builders found no token or cost parameter.

What does Magentic do when there is no progress?

It counts the rounds without progress and, past max_stall_count (3 by default), resets and replans. Without max_reset_count, this repeats until the workflow’s 100-iteration ceiling: in the example, 150 calls and 82,514 input tokens.

Is Magentic ready for production?

The sources disagree, as in the table at the start: the blog and the package say stable; the Magentic page says it is untested outside the original four-agent design, and its C# example turns off the experimental types warning. My reading: even with a stable API, the behavior of your design is only shown by your own measurement.

What if the agents are in other processes?

Then the subject is A2A: each call is an HTTP request, with more latency than a call in the same process. The article on A2A covers that boundary and trust in delegation.

Does handoff work without a person?

Only with autonomous mode, experimental according to the page, with 50 turns per agent by default; in the code, the limit is the turn_limits of with_autonomous_mode. Without it, the handoff ends waiting for a person, as in the example.

Conclusion

Splitting one agent trades one call for a conversation, and each conversation has a bill and a time to stop that the framework only defines in part. Measure the single agent, choose the pattern by what it multiplies, put a limit on every loop and count calls and tokens in your code. Before going to production, test whether the worst case of each pattern ends by a limit of yours, and not by the 100-iteration ceiling, and whether the call count runs as a test on every framework update. For the cost per approved task, the path is AI FinOps.

Official references

👉 If you have a system with more than one agent, or are about to split yours, run this article’s example with your number of agents and see what each pattern multiplies, before you turn on the first real model. Want to talk about agent orchestration? Reach out on LinkedIn.

Leave a Reply