DEV Community

Cover image for The ROI Math Every Engineer Should Run Before Building an AI Agent
Michael
Michael

Posted on Originally published at getmichaelai.com

The ROI Math Every Engineer Should Run Before Building an AI Agent

Most AI agent projects fail before a single line of code ships. Not because the tech is weak, but because nobody ran the numbers. Someone got excited, wired up an LLM to a Slack webhook, and six weeks later the demo impressed a VP and quietly died.

If you're the engineer being asked to build the thing, the ROI calculation is your best defense against building something nobody needed. Here's the framework I use.

Start With the Task, Not the Technology

An AI agent is only worth building if it replaces or accelerates a task that costs real money today. So the first number you need is the current cost of the work.

Break it down:

  • Volume: How many times per month does this task run?
  • Time per task: How long does a human spend on it?
  • Loaded hourly cost: Salary plus overhead, usually 1.3x base pay.

A support triage task that runs 4,000 times a month at 6 minutes each, handled by staff costing $45/hour loaded, burns roughly $18,000/month. That's your baseline. If the agent can't meaningfully dent that number, stop here.

Model the True Cost of the Agent

This is where engineers usually underestimate. The cost of an AI agent isn't just token spend. It's four buckets:

  1. Build cost — engineering hours to design, integrate, and test.
  2. Inference cost — LLM API calls, embeddings, vector DB queries.
  3. Maintenance cost — prompt updates, model migrations, monitoring. Budget 15-25% of build cost annually.
  4. Human-in-the-loop cost — the reviews and corrections the agent still needs.

Inference is the sneaky one. Multi-step agents call the model multiple times per task. Let's model it properly.

def monthly_inference_cost(
    tasks_per_month,
    llm_calls_per_task,
    avg_input_tokens,
    avg_output_tokens,
    input_price_per_1k=0.0025,   # $/1k input tokens
    output_price_per_1k=0.01,    # $/1k output tokens
):
    total_calls = tasks_per_month * llm_calls_per_task
    input_cost = (total_calls * avg_input_tokens / 1000) * input_price_per_1k
    output_cost = (total_calls * avg_output_tokens / 1000) * output_price_per_1k
    return round(input_cost + output_cost, 2)

# Support triage: 4000 tasks, 3 model calls each
cost = monthly_inference_cost(
    tasks_per_month=4000,
    llm_calls_per_task=3,
    avg_input_tokens=1200,
    avg_output_tokens=350,
)
print(f"Estimated inference: ${cost}/month")  # ~$78/month
Enter fullscreen mode Exit fullscreen mode

Inference is often trivial next to labor. The real cost centers are build and maintenance, so weight your estimate there.

Calculate the Payback Period

Once you have monthly savings and total costs, payback period is simple:

def payback_period(build_cost, monthly_savings, monthly_run_cost):
    net_monthly_gain = monthly_savings - monthly_run_cost
    if net_monthly_gain <= 0:
        return None  # never pays back
    return round(build_cost / net_monthly_gain, 1)

months = payback_period(
    build_cost=40000,       # ~2 engineers for a month
    monthly_savings=13000,  # 70% of the $18k baseline
    monthly_run_cost=1500,  # inference + review + monitoring
)
print(f"Payback in {months} months")  # ~3.5 months
Enter fullscreen mode Exit fullscreen mode

A payback under 6 months is easy to defend. Under 12 is reasonable. Beyond 18 months, you're gambling that requirements won't change — and they always do.

Discount for Reality

Here's the part that separates a defensible business case from a spreadsheet fantasy.

Automation rate is never 100%

Agents handle the happy path and escalate edge cases. If your agent fully resolves 70% of tasks and assists on another 20%, don't claim you eliminated the role. Model partial savings honestly.

Accuracy has a cost

A wrong answer in support isn't neutral — it can cost a customer. Factor in an error rate and the downstream cost of mistakes. An agent that's 95% accurate at scale still produces hundreds of errors a month.

Ramp time is real

No agent works well on day one. Assume 2-3 months of tuning before you hit projected performance. That pushes your effective payback out, so bake it in.

The Build vs. Buy Fork

Before you commit engineering hours, ask whether an existing tool already does 80% of this. Sometimes a $500/month SaaS agent beats a $40,000 custom build with ongoing maintenance. Custom only wins when the task is core to your business, deeply integrated with proprietary systems, or high enough volume that per-seat pricing gets absurd.

A One-Page Business Case

When you present, keep it to five numbers:

  • Current monthly cost of the task
  • Realistic automation rate
  • Total build cost
  • Monthly run cost
  • Payback period

That's the whole story. If those numbers work at conservative assumptions, build it. If they only work when you assume 100% automation and zero maintenance, you've found a demo, not a product.

The teams that win with AI agents aren't the ones with the fanciest prompts. They're the ones who picked the right task, ran the math first, and shipped something that paid for itself before anyone asked if it was worth it.


Originally published at getmichaelai.com

Top comments (0)