Cost Model

Fix the task and window before summing costs

Record task ID, customer, workflow, start time, acceptance criteria, and deadline. Associate retries, model upgrades, compaction, and human takeover with the original task. Success uses the time the result is confirmed usable; label human fallback separately. Report tasks with incomplete observation windows separately.

Actual ledgers record incurred expenses; forecasts record expected expenses. Do not add probability-weighted fallback costs to the same actual fallback expense. Keep costs incurred on failed, canceled, and budget-terminated tasks.

Count each expense once

Normalize provider usage into mutually exclusive billing categories. Here uncached_input_tokens excludes cache writes and reads; all rates are per million tokens. Convert provider fields according to their documented inclusion rules.

call_cost = (
  uncached_input_tokens × input_price_per_million
  + cache_write_tokens × write_price_per_million
  + cache_read_tokens × read_price_per_million
  + output_tokens × output_price_per_million
) / 1,000,000

task_resource_cost = sum(all_call_costs)
                   + tool_and_runtime_cost + external_api_cost

task_delivery_cost = task_resource_cost
                   + actual_review_and_fallback_labor_cost
                   + allocated_service_cost

all_call_costs includes initial attempts, retries, upgrades, and compaction, so do not add retry_cost again. Report retry spending as a subset of the total. Define tool and external API boundaries so bundled resources are not charged twice.

Value actual human minutes at loaded hourly cost divided by 60. Classify review, correction, takeover, and service time without overlap. Separate acquisition and one-time onboarding, as in growth. Document shared-resource allocations and retain visibility into unallocated fixed investment.

Use a reproducible synthetic bill

Assume triaging 20 emails in 12 model calls. Teaching rates, not a vendor quote, are $3 for uncached input, $3.75 for cache writes, $0.30 for cache reads, and $15 for output, all per million tokens. Assume one prefix write, 11 reads, no retries, and $0.001 in runtime charges.

AttributionUsageCost (USD)
Static system and tool definitions3,700 write; 40,700 read0.026085
Non-tool dynamic input and history26,400 uncached input0.079200
Tool-result input, including replays14,400 uncached input0.043200
Model output3,000 output0.045000
RuntimeSeparately charged0.001000
TotalResources only0.194485

Attribute each input occurrence by source. Replayed tool results remain tool-result input, never also non-tool history. Generated output incurs output charges; replaying it later incurs a separate input charge for another processing event.

Resource cost compositionSynthetic example · total $0.194485. Lengths show cost; shares rounded. Excludes labor, not total delivery cost.Resource cost compositionSynthetic example · total $0.194485Static prefix$0.026085 · 13.4%Non-tool input and history$0.079200 · 40.7%Tool-result input (incl. replays)$0.043200 · 22.2%Model output$0.045000 · 23.1%Runtime$0.001000 · 0.5%Lengths show cost; shares rounded.Excludes labor, not total delivery cost. Resource cost compositionSynthetic example · total $0.194485. Lengths show cost; shares rounded. Excludes labor, not total delivery cost.Resource cost compositionSynthetic example · total $0.194485Static prefix$0.026085 · 13.4%Non-tool input and history$0.079200 · 40.7%Tool-result input (incl. replays)$0.043200 · 22.2%Model output$0.045000 · 23.1%Runtime$0.001000 · 0.5%Lengths show cost; shares rounded.Excludes labor, not total delivery cost.

Chart shares use unrounded amounts; displayed percentages are rounded. This bill excludes labor and is not total delivery cost. Store actual prices, cache durations, discounts, and regional settings in a dated rate version. See the official pricing explanation for billing categories.

Cost per success includes failed attempts

cost_per_started_task = cohort_delivery_cost / started_tasks
cost_per_successful_task = cohort_delivery_cost / accepted_agent_tasks

The numerator includes all delivery costs for the same completed task cohort, including human fallback after failure. The denominator counts distinct tasks meeting predefined agent-delivery criteria. Report human-completed tasks separately. If using eventual delivery success as another denominator, label it separately from agent success.

For example, all 100 started tasks have ended. Resources cost CNY 200, review and service cost 300, and fallback labor costs 100. Eighty tasks meet agent acceptance criteria. Cost per start is 6; cost per agent success is 7.5. Even if humans finish the other 20, agent success remains 80. With zero successes, report unit cost as not applicable and still show total spending.

Replayed history increases cumulative input

In a multi-step agent, each step often needs some history: the user’s goal, previous actions, tool results, errors, and current state. If the full history is replayed, step N carries the content of steps 1 through N-1.

That makes accumulated input grow quickly:

history_tokens ≈ per_step_history × (1 + 2 + ... + n)

Real systems do not have to be strictly O(n²), because they can trim, compact, externalize state, or retrieve only relevant events. The trend still matters: the longer the task, the more important history management becomes.

That is why compaction, memory-system, progress files, structured state, and recoverable sessions are part of the economics, not just user experience.

Caching needs stable prefixes and reuse opportunities

Prompt caching works when identical content is read repeatedly. System prompts, tool descriptions, policy blocks, and fixed output formats should stay as stable as possible.

Common ways to break caching:

  • Put per-request user data into the system prompt.
  • Reorder tool descriptions dynamically on every turn.
  • Place timestamps, random IDs, or temporary state inside the static prefix.
  • Constantly rewrite a long prompt to tweak a few words.

Also check cache lifetime, request spacing, minimum length, and provider rules. Caching saves money only when reuse savings exceed write and maintenance overhead. Verify actual usage rather than assuming stable prefixes always hit.

Output optimization must preserve necessary verification

For many models, output tokens cost more than input tokens. This encourages fewer long explanations, less unnecessary planning prose, and more direct tool use.

But “shorter output” should not become silence. Useful plans, checkpoints, and error explanations can prevent retries. The better target is:

  • Reduce long reasoning text that is invisible, unverifiable, or not reusable.
  • Make tools return structured results instead of large raw blobs for the model to paraphrase.
  • Emit concise state at key points so users and later agents can resume.

Model rates directly change only call charges

Call rates and task resource costHypothetical options · equal token usage. Runtime stays at $0.001. Lengths show total cost, excluding labor.Call rates and task resource costHypothetical options · equal token usageOption A: call rates × 1/3$0.065495Option B: call rates × 1$0.194485Option C: call rates × 5/3$0.323475Runtime stays at $0.001.Lengths show total cost, excluding labor. Call rates and task resource costHypothetical options · equal token usage. Runtime stays at $0.001. Lengths show total cost, excluding labor.Call rates and task resource costHypothetical options · equal token usageOption A: call rates × 1/3$0.065495Option B: call rates × 1$0.194485Option C: call rates × 5/3$0.323475Runtime stays at $0.001.Lengths show total cost, excluding labor.

The chart uses hypothetical options A, B, and C with model-call rates at 1/3, 1, and 5/3 of the example baseline. Token usage is identical and runtime stays at $0.001. Resource costs are $0.065495, $0.194485, and $0.323475. Bar lengths are proportional to cost. These are not model recommendations and exclude labor. Actual models may differ in usage, retries, and quality; compare total delivery cost on the same evaluation cohort.

Model tierGood fitCost intuition
Low-cost modelClassification, extraction, formatting, low-risk routine actionsCheap per step, but may need more fallback
Mid-tier modelMost default product agent tasksBalanced cost and reliability
High-capability modelLong-horizon planning, complex code, subjective quality judgment, high-risk decision supportMore expensive per step, but may avoid wrong paths

Model routing is not about always choosing the cheapest model or defaulting to the strongest one. It is about matching task risk, failure cost, and model capability.

Fields To Measure

These are recommended records, not claims about current implementation. Also capture task_id, attempt_id, customer and workflow, acceptance status and time, delivery mode, rate version, currency, actual charges, and allocation basis to reconstruct cohort ledgers:

FieldWhy it matters
uncached_input_tokens / output_tokensShows whether cost comes from input growth or verbose output
cache_write_tokens / cache_read_tokensShows whether static prefixes actually hit cache
tool_result_tokensShows whether tools return too much context
steps / retriesShows wrong paths or loops
model / route_reasonShows whether routing decisions are justified
runtime_secondsShows whether sandbox, browser, or external services matter
human_review_minutesShows whether automation is shifting cost to people
failure_reasonShows whether runaway cost comes from model, tool, permission, data, or product design

These fields feed the budgets, monitoring, and value model in Controls and ROI.

Agent Economics separates perspectives; Controls and ROI explains how to use these records in decisions.

Sources

Was this page helpful?