Skip to course content
Free CrewAI course

CrewAI for Multi-Agent Automation

Unit 07.02: Token spend per agent, per task

Attributing cost per agent is what turns "the crew is expensive" into a specific thing to change.

Where the money actually goes

Tokens per agent per task, as a share of the run, priced over a realistic volume.

The code breaks down a five-agent run.

RUNS = 500
RATE = 0.003 / 1000
SPEND = [
    ("Triage analyst",  "classify",    1_240),
    ("Billing analyst", "decide",      2_050),
    ("Support writer",  "draft",       3_980),
    ("Policy reviewer", "check",       2_110),
    ("Manager",         "delegation",  4_800),
]

total = sum(t for _, _, t in SPEND)
print(f"{'agent':17} {'task':12} {'tokens':>7} {'share':>7} {'$/500 runs':>11}")
for agent, task, tokens in sorted(SPEND, key=lambda r: -r[2]):
    print(f"{agent:17} {task:12} {tokens:>7,} {tokens / total:>6.0%} "
          f"{'$' + format(tokens * RATE * RUNS, '.2f'):>11}")

print(f"\ntotal {total:,} tokens/run, ${total * RATE * RUNS:.2f} per {RUNS} runs")

# The manager is the single largest line and produces no output a user sees.
# That is the number that justifies replacing it with a flow -- and you cannot
# make that argument without per-agent attribution.

The manager is the single largest line and produces nothing a user sees. That is the number that justifies replacing it with a flow, and it is invisible without per-agent attribution - in a run total it just looks like the crew being costly.

The share column matters more than the dollar column, because rates change and proportions do not. An agent taking a quarter of the budget for routing is worth examining whatever the rate.

The mistake this prevents

The mistake is optimising the largest visible output. The drafting agent produces the most text and is not the largest cost here; the manager produces no text and is. Attribution, not intuition.

Takeaway

Attribute tokens per agent per task and read the shares. Routing overhead and other invisible costs only become arguable once they have a number.