Business

How to Instrument AI Workflows So ROI Calculations Are Possible

Antonio Evans8 min read

A cutaway of an AI workflow pipeline: a row of boxes labeled with steps such as intake, retrieve, model call, tool call, human review, output.
Key points

Key points

  1. 1Instrument every step of an AI workflow as a structured event with a stable name, a UTC timestamp, a run id, and cost attributes so ROI math has real inputs.
  2. 2Snapshot the pre-automation baseline for the same task before you change anything; without both datasets you can only estimate.
  3. 3Tag every model and tool call with tokens, cache hits, retries, tool calls and human minutes, because the invoice alone cannot tell you cost per completed task.
  4. 4Store events so engineering and finance join on one key (the run id), which makes cost per completed task a shared, checkable number.

Why the cost side, not the value side, usually blocks ROI

Most teams that cannot produce an ROI number for an AI workflow are not missing the outcome. They can point to a ticket deflected, a document drafted, a pull request merged. What they cannot do is say what that outcome cost. Provider invoices arrive at account level, a shared model gateway strips the caller identity, and an agent spawns sub-steps that each bill separately with no link back to the task that triggered them. That is the attribution problem, and it is the one instrumentation has to solve (DoiT).

The stakes are concrete. A survey of finance leaders found that 83 percent expect a return on AI investment within 12 months, but only 15 percent can calculate AI ROI without significant bottlenecks (DoiT). Deloitte found 73 percent of organizations struggle to define the exact impact or metrics of their digital initiatives (Moveworks). Instrumentation is the fix: it turns a finance guess into an arithmetic problem with auditable inputs.

There is a second reason to instrument early. RAND's interviews with 65 experienced data scientists and engineers found the leading root causes of AI project failure include miscommunicating the problem, lacking the data to train or evaluate, and deploying models optimized for the wrong metrics (RAND). A workflow that emits structured events per step gives you the metric layer RAND says most projects lack before they fail.

The event schema: five fields that make joins possible

Every step of an AI workflow should emit one structured event. Keep the schema small and stable. If you change event names between versions, your historical data becomes unjoinable and every ROI query needs a translation table.

FieldTypeExampleWhy ROI work needs it
event_namestring, stableworkflow.step.completedGroup and count steps without parsing payloads
run_idstring, unique per taskrun_8f2c...Join every step, model call and human action to one task
tsISO 8601 UTC2026-02-11T14:03:22ZBucket by period, compute cycle time, reconcile against invoices
propertiesobject{"step": "draft", "actor": "agent"}Slice by step, actor, version of the workflow
costobject{"input_tokens": 1840, "output_tokens": 412}Sum spend per task without re-reading provider bills

The run_id is the most important field. It is the only key that lets you take a provider invoice line, a tool call, and a human's 4 minutes of review and say they belong to the same completed task. Without it you are back to account-level averages, which tell you almost nothing about whether a specific investment paid off.

Name events by what happened, not by what the system did internally. workflow.step.completed and workflow.step.failed age better than llm_call_2 or agent_retry_v3. Treat event names as a public contract with finance: publish the list, and only add to it, never rename.

A minimal emitter in Python looks like this:

import uuid, datetime, json

def emit(event_name, run_id, properties=None, cost=None):
    record = {
        "event_name": event_name,
        "run_id": run_id,
        "ts": datetime.datetime.now(datetime.timezone.utc).isoformat(),
        "properties": properties or {},
        "cost": cost or {},
    }
    # append to your event store; one JSON object per line is enough to start
    print(json.dumps(record))

Tagging cost on every model and tool call

Cost tagging means recording the ingredients of spend at the moment of the call, not reconstructing them later. Mavvrik's guide to AI cost tracking lays out three connected layers: a usage layer (provider, model, input and output tokens, embeddings, retrieval count, tool calls, latency, retry count), an ownership layer (team, product, feature, workflow, agent), and a finance layer (allocation rule, budget, cost-to-serve) (Mavvrik). Instrument the first two at the call site; the third is a finance job built on top.

Capture these attributes on each model call:

  • Provider and model, as separate fields, so you can swap either without rewriting queries.
  • input_tokens and output_tokens, read from the API response, not estimated.
  • cached_tokens or a cache hit flag. Cached input is billed differently from fresh input, and teams that ignore it overstate cost.
  • retry_count and attempt. Retries are real spend with no output. A workflow that retries 30 percent of calls looks twice as expensive per task as one that does not.
  • tool_calls, with the tool name and duration. Retrieval, search, and code execution carry their own cost signals (retrieval queries, embedding volume, vector store storage) that do not appear on a model invoice (Mavvrik).
  • human_minutes, logged when a person edits, approves or rejects an agent output. Use a fully loaded hourly rate (salary plus benefits plus overhead, commonly 1.3 to 1.5 times base salary) rather than base pay (Pickaxe).

The OpenAI-compatible OpenTelemetry GenAI semantic conventions give you a naming baseline for these attributes, so your traces reconcile with standard tooling instead of inventing a schema from scratch (OpenObserve). Even if you do not run a full tracing stack, adopting the attribute names costs nothing and saves a migration later.

One worked example, using illustrative numbers. Suppose one completed support reply runs three model calls at an average of 1,200 input tokens and 300 output tokens each, plus two retries, plus one retrieval lookup, plus four minutes of human review at a $60 fully loaded hourly rate. The model tokens cost whatever your rate card says. The human four minutes costs $4.00. If total model and tool spend per task is $0.06, cost per completed task is $4.06, and almost all of it is human review. That single number reframes the ROI conversation: the automation did not remove the person, it moved them to a review step.

Baseline snapshots: take them before you change anything

A baseline is the pre-automation measurement of the exact task you plan to automate, recorded before rollout. SS&C Blue Prism lists establishing a baseline as step two of eight in measuring AI ROI, right after defining goals (Blue Prism). One practitioner guideline is to set baselines 3 to 6 months before introducing AI, recording total labor cost and time taken for the specific task (Naitiv).

Snapshot at minimum:

  • Volume: how many completed tasks per week, from the system of record, not from memory.
  • Cycle time: elapsed time from task start to task done, measured from timestamps, not surveys.
  • Human minutes per task, from time tracking or ticket logs.
  • Rework: how often the output was corrected, reopened or rejected. Rework time is the part teams most often forget, and it can erase most of the apparent savings (Naitiv).
  • Quality marker: error rate or change failure rate for the same period.

Store the baseline as a versioned dataset with a date range and a named owner, in the same warehouse as your live events. If the baseline lives in a spreadsheet and the live data in a tracing tool, the join never happens and the comparison never gets made. Also snapshot quality, not just speed: faster output that rework erases is not a saving, it is a reshuffle.

For coding workflows, the baseline is specific: cycle time, throughput, change failure rate and rework for each team over the 90 days before rollout (Waydev). For other workflows, pick the same four dimensions (volume, cycle time, human minutes, rework) and hold them constant across the comparison.

Joining events: one table finance and engineering both trust

The join key is run_id. Build one fact table where every row is a completed task, with the run id, start and end timestamps, outcome, and summed cost attributes. Every event table feeds it. Finance queries the fact table; engineering writes to it. Nobody maintains a second copy.

A practical shape:

-- cost per completed task, last full month
SELECT
  COUNT(*)                                   AS completed_tasks,
  SUM(cost_model + cost_tools + cost_human)  AS total_cost,
  SUM(cost_model + cost_tools + cost_human) / COUNT(*) AS cost_per_task
FROM workflow_runs
WHERE status = 'completed'
  AND ended_at >= DATE '2026-01-01'
  AND ended_at <  DATE '2026-02-01';

Three rules keep the table trustworthy. First, reconcile monthly: compare the sum of token costs in your events against the provider invoice and record the variance. A 2 percent gap is normal; a 40 percent gap means your rate card or your token counts are wrong. Second, define "completed" once, in writing, and compute it from the system of record. Third, publish the metric definition alongside the number, because finance and engineering arguing about what counts as done is the most common reason a valid ROI calculation gets rejected.

The output of this table is cost per completed task, which is the building block of ROI: once you know what each outcome costs, ROI is a comparison against the value it delivers (AWS). Two refinements make it defensible. Model the J-curve: a temporary productivity dip during rollout is a real cost. A worked coding example counts a 5 percent dip for 3 months across 200 engineers at a $180,000 loaded cost, which adds $450,000 to first-year investment (Waydev). And report capacity, not cash: time saved becomes money only if you show where the hours went, otherwise it gets absorbed into meetings and busywork (Pickaxe).

Decision rules and pitfalls

Rule one: if a step has no event, it has no cost, and any ROI number that includes it is an estimate. Instrument the smallest set of steps that lets you compute cost per completed task, then expand.

Rule two: prefer cost per completed task over total spend. Total spend rises when usage rises even if unit economics improve. Cost per workflow, cost per inference and cost-to-serve are stronger operating metrics because they connect usage to margin and pricing decisions (Mavvrik).

Rule three: separate hard and soft ROI. Hard ROI is quantifiable money in or out; soft ROI covers satisfaction, skill retention, brand and agility (Techstack). Instrument hard ROI first; soft benefits need their own metrics and should not pad the arithmetic.

Rule four: use a 6 to 12 month window. A 90-day ROI window for an agent deployment is dominated by implementation and learning costs; meaningful measurement typically needs 6 to 12 months, and strategic deployments are modeled to 24 (Pickaxe).

Pitfalls that recur: counting task completions instead of outcomes, which is why some teams have moved to agentic work units that tie activity to value (Pickaxe); leaving out human-in-the-loop and monitoring costs, the "trust tax" of making sure the agent is not confidently wrong; and letting the saved hours vanish without a record of where they went.

Public ROI figures are directionally useful and rarely comparable. A benchmark report assembled 47 public metrics and found credible workflow gains, including 15 percent customer-support productivity gains and 55.8 percent faster coding task completion, while cautioning that many business cases are vendor-published, annualized or gross of implementation cost (Alice Labs). Instrument your own workflow; cite the benchmark only as context.

Getting started this week

  1. Pick one workflow and one completed-task definition. Write both down.
  2. Snapshot the baseline for the last 8 to 12 weeks from existing systems: volume, cycle time, human minutes, rework.
  3. Add the event emitter with the five-field schema and a run_id generated at task start.
  4. Tag model and tool calls at the call site. Read tokens from responses; log retries and cache hits.
  5. Build the fact table and the cost-per-completed-task query. Reconcile against one provider invoice.
  6. Publish the definition and the number to finance in the same place.

If you are wiring several model providers and tools into one workflow, routing them through a single OpenAI-compatible endpoint removes a chunk of instrumentation work, because tokens and costs come back in one format you can log: Quanta Inference puts text, image, video, audio and embedding models behind one API key, prepaid and priced in dollars. Whether you build or buy that layer, the schema above stays the same.

FAQ

FAQ

What is the single most important field to log for ROI?

The run id. It is the only field that links a model call, a tool call and a human review to one specific task, which is what makes cost per completed task computable. Without it, every cost figure is an account-level average.

How do I handle costs from shared infrastructure like a GPU cluster?

Record usage signals at the request level (tokens, requests, compute time, query volume, workflow steps) and apply an allocation rule on top, then reconcile the result against the actual bill each month. Shared infrastructure allocation requires those usage signals, otherwise the denominator in your ROI ratio is an assumption rather than a measurement (Mavvrik).

Can I instrument a workflow retroactively?

Only partly. You can reconstruct volume and cycle time from existing system timestamps, but token counts, cache hits, retries and human minutes usually were not recorded, so cost per task becomes an estimate. A baseline snapshot is far more reliable when taken before the change (Blue Prism).

How long should I measure before claiming ROI?

Long enough to clear implementation costs and the learning curve. A common guideline is a 6 to 12 month window, with 24-month modeling for strategic deployments, and a 90-day window is rarely meaningful (Pickaxe).

What if finance and engineering disagree on cost per task?

Disagreement almost always comes from two definitions of "completed" or two rate cards. Publish one metric definition, one fact table keyed on run id, and a monthly reconciliation against the provider invoice. When both sides query the same table, the argument becomes about inputs, which can be checked, rather than about conclusions.

Sources

Sources

  1. How to Measure AI ROI When You Can't See Where Tokens ...
  2. Enterprise Automation ROI: A Guide To Measuring and Maximizing ROI ...
  3. The Root Causes of Failure for Artificial Intelligence Projects and ...
  4. How to Track AI Costs in 2026: Usage Logs to Cost-to-Serve
  5. How to Measure AI Agent ROI: Metrics & Formulas
  6. OpenTelemetry for LLMs: Complete SRE Guide for 2026
  7. Measuring AI Investment: The ROI for AI | SS&C Blue Prism
  8. AI ROI Metrics: Top 10 KPIs to Track
  9. How to measure the ROI of AI coding tools - Waydev
  10. Calculating the Return on Investment (ROI) of AI
  11. Measuring the ROI of AI: Key Metrics and Strategies - Techstack
  12. AI Automation ROI Benchmark Report 2026 - Alice Labs
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles