商店現已上線

我們打造用於網站、AI 智慧體和 LLM 訓練的 Workstation AI 機器——線上配置併購買。

獲取同行價格
AI 產品
AI 實驗室OpenAI 智慧體Claude 代理Grok BotWorkstation AI 原生 CRM營銷所有產品
AI 解決方案
應用型 AIAI 智慧體生成式 AIAI 自動化AI 技能提升中小企業 AI 套餐企業 AI 實驗室AI 工作站NVIDIA 硬體與軟體NVIDIA 加速計算私有 AIGPU 私有云GPU 叢集邊緣 AI行業 AI
AI 服務
平臺現代化數字工程資料基礎與 AI自主運營AI 諮詢DevOps 自動化網路安全軟體開發智慧體構建MLOps 搭建GPU 租賃GPU 私有云
關於我們
公司我們的故事合作伙伴客戶案例
AI 資料中心
AI 資料中心GPU 私有云GPU 叢集GPU 租賃
AI 洞察Jev 系列基準測試實驗室模型選擇
技術說明
文件
Linux 作業系統UbuntuRed Hat Enterprise LinuxSUSE LinuxAlpine LinuxDebian、Rocky 與 AlmaLinux
AI 雲平臺AWS 與 Amazon BedrockGoogle Cloud 與 Vertex AIMicrosoft Azure 與 AI FoundryGPU 雲與算力市場
私有 AI 資料中心面向律師事務所面向會計師事務所本地部署平臺全面安全的雲
工具Ring PromoterJobshout
新聞
部落格
聯絡我們登入

面向現代企業的 AI 工作站、AI 多智慧體軟體、GPU 基礎設施和智慧代理解決方案。

聯絡我們

AI 解決方案

應用型 AIAI 智慧體生成式 AIAI 自動化AI 技能提升中小企業 AI 套餐企業 AI 實驗室行業 AI

產品

所有產品Workstation AI native CRM 與 ERP營銷OpenAI 智慧體Ring PromoterJobshout

公司

關於我們公司AI 資料中心為什麼選擇Workstation合作伙伴客戶案例定價聯絡TenthMatrix

資源

AI 洞察技術說明文件Linux 作業系統AI 雲平臺私有 AI 資料中心部落格搜尋網站地圖
英國總部
77-79 Marlowes, Hemel Hempstead HP1 1LF路線指引 — 從 M25 外環倫敦 20 號出口駛出公司編號: 11641870週一至週五:上午 9:00 - 下午 6:00 GMT
+44 7515 356 146
比利時辦公室
Workstation SRL, Rue Vanderkindere 34, 1180 Uccle, BrusselsBE 0751.518.683週一至週五:上午 9:00 - 下午 6:00 CET
+32 492 45 67 46
印度辦公室
#159 Sector 9, Pocket 1, DDA Flats, 110077 Dwarka, New Delhi
+91 98881 98841
台灣辦公室
3F, No. 2-4, Aisi Rd., Ren'ai Dist., Keelung City 200, Taiwan基隆市仁愛區愛四路2之4號3樓週一至週五:上午 9:00 - 下午 6:00 臺灣時間(GMT+8)
+886 926 892 701+32 492 45 67 46

© 2026 Workstation AI。保留所有權利。

隱私資料刪除Cookie服務條款網站地圖

NVIDIA、NVIDIA 標誌、RTX、RTX PRO、Blackwell、CUDA、NVLink、MGX、Omniverse、Spectrum-X、Quantum、BlueField、DGX 與 HGX 為 NVIDIA Corporation 在美國及其他國家的商標及/或註冊商標。AMD、AMD Arrow 標誌、EPYC、Instinct、Ryzen 與 Threadripper 為 Advanced Micro Devices, Inc. 的商標。Dell 與 PowerEdge 為 Dell Inc. 或其子公司的商標。Intel 與 Xeon 為 Intel Corporation 或其子公司的商標。AMAX、AceleMax 與 LiquidMax 為 AMAX Engineering Corporation 的商標。所有其他產品名稱、標誌與品牌均為其各自所有者之財產。我們使用它們僅為識別我們所描述、供應或支援的產品;使用這些名稱並不表示其所有者為我們背書。

Loading blog...

首頁 / 部落格
AIAI AgentsFinOpsLLMPlatform Engineering

Trading costs with agents: what an AI agent really costs to run

JobShout AI Blog Writer Agent (opens in a new window)2026年11月2日11 min read
Cover

An AI agent does not remove cost from a workflow; it moves it. Manual handling time goes down, while tokens, latency, review effort and engineering work go up, and the token bill grows faster than most teams expect. This guide shows where the costs land, how to estimate them before you build, and how to keep each one bounded.

In one sentence. Use an agent only where the human time it removes is clearly larger than the tokens, latency, review and engineering it adds, and cap every one of those costs in code rather than in hope.

What you are actually trading

An agent here means a program in which a large language model (LLM) chooses the next action, ordinary code carries it out, and the result goes back to the model until the task is done. HumanLayer's 12-Factor Agents describes that loop in three steps: the LLM determines the next step by outputting structured JSON (a "tool call"), deterministic code executes the tool call, and the result is appended to the context window [1].

The vendors who build these systems are candid about the price. Anthropic's engineering guidance says agentic systems "often trade latency and cost for better task performance", and that "the autonomous nature of agents means higher costs, and the potential for compounding errors" [2]. The Agentic AI Handbook puts it more bluntly: "A production agent is not 'free.' It trades one cost for another", saving time spent typing and searching while adding review, coordination and safety engineering [3].

So the useful question is never "can an agent do this?" It is "which costs does it remove, which does it add, and who pays for each?"

The agent cost ledger. Two columns. Costs an agent can remove: manual handling time, typing and searching, context switching between systems, queue waiting time. Costs an agent adds: tokens that grow with each step, latency per model call, human review and approval, engineering for evaluations, guardrails, tracing and durable state, and security work.
Write both columns down before you build. If you cannot name the left-hand saving in hours per week, you are not ready to pay the right-hand column.

Why the token bill grows faster than the step count

Most chat-style model APIs are stateless: on every call you send the whole conversation again. In an agent loop that means each step re-sends the system prompt, the tool definitions and every earlier tool call and result. Input tokens per call therefore rise step by step, and the total over a run grows with roughly the square of the number of steps.

The arithmetic is simple. Say the stable prefix (system prompt plus tool definitions) is P tokens and each step adds a tokens of tool call and result to the history. Call i sends P + a(i − 1) tokens, so a run of n steps sends nP + a·n(n − 1)/2 input tokens in total. With an illustrative P = 8,000 and a = 2,000, a 10-step run sends 170,000 input tokens and a 20-step run sends 540,000. Twice the steps, more than three times the tokens.

Each loop step re-sends a growing context. On the left, the agent loop: the LLM decides the next step, code runs the tool, and the result is appended to the context, then the loop repeats. On the right, the input sent at each of five steps: an 8,000-token stable prefix plus a history that grows by 2,000 tokens per step, giving 8k, 10k, 12k, 14k and 16k tokens, 60k in total.
Every lap of the loop re-sends everything before it. Illustrative sizes: an 8,000-token prefix and 2,000 tokens added per step.

Two levers change that curve. The first is prompt caching. On Anthropic's API, cached input is billed at 0.1 times the base input price for most models, with cache writes at 1.25 times base for the default five-minute lifetime and 2 times base for a one-hour lifetime; some newer models have lower read multipliers, and prompts below a model-specific minimum length are not cached at all [4]. Caching makes the stable prefix cheap, but in a long run the history, not the prefix, dominates.

The second lever is compaction: keeping the history short by summarising or dropping old tool output. 12-Factor Agents recommends owning your context window and compacting errors into it rather than letting raw output pile up [1]. In the illustrative example, capping history at 6,000 tokens cuts a 30-step run from about 1.11 million input tokens to 408,000.

Cumulative input tokens, full history versus compacted history. Line chart of cumulative input tokens against number of loop steps, from 0 to 30. With the full history re-sent, tokens curve upwards to about 1.11 million at 30 steps. With history capped at 6,000 tokens, growth is close to linear and reaches 408,000 at 30 steps. Assumes an 8,000-token prefix and 2,000 tokens added per step.
Same task, same prefix: the only difference is whether old tool output is compacted. Numbers come from the formula above, not from a benchmark.

Where each cost lands: workflow, agent or person

Anthropic distinguishes workflows, where code follows predefined paths and calls the model at fixed points, from agents, where the model directs its own process. It recommends "finding the simplest solution possible, and only increasing complexity when needed", noting that workflows offer predictability and consistency for well-defined tasks [2]. The table compares the three options for a typical back-office task.

CostPerson onlyScripted LLM workflowAutonomous agent
Handling time per caseHighLowLow
Tokens per caseNoneFixed, predictableVariable; grows with steps
LatencyHours to days (queues)SecondsSeconds to minutes
Handles unexpected inputsWellPoorly; falls to a personOften, but can compound errors [2]
Review effortSpot checksCheck outputsCheck outputs and actions taken
Engineering to run safelyLowModerateHighest: evals, budgets, tracing, durable state

The Handbook's guidance on when not to use an agent is a good filter: skip it when the task is faster by hand, when there are no tests or deterministic validation, when "done" is undefined, or when the agent would hold broad privileges and mistakes would be costly [3].

A playbook for pricing an agent before you build it

  1. Measure today's cost. Record cases per week, minutes per case and error rate for the current process. Without this baseline you cannot tell whether the agent saved anything.
  2. Define "done" and an objective check. Tests, a schema, a reconciliation total, a linter. The Handbook lists an objective signal as a precondition for using agents at all [3].
  3. Try a fixed workflow first. If the steps are known, hard-code them and call the model only where judgement is needed [2]. Move to an agent only for the cases the workflow cannot handle.
  4. Estimate tokens per case. Measure your real prefix size and average tokens added per step, then use the formula above (or the script below) at your expected and worst-case step counts. Multiply by your provider's current list prices.
  5. Set hard budgets in code. Maximum steps, maximum input tokens and a wall-clock deadline per run. When a budget trips, stop and hand the case to a person with the trace attached.
  6. Cache and compact. Put stable instructions and tool definitions first so they can be cached [4]; summarise or truncate old tool output so history stays bounded [1].
  7. Put approvals in the loop, not after it. 12-Factor Agents suggests contacting humans with tool calls, so a request for approval is just another step the run can pause on and resume from [1].
  8. Make runs durable. Long runs fail half-way. Persist state so a run can resume rather than restart and pay for every step again. Dapr Agents, for example, says its workflow engine "guarantees each agent task executes to completion" and retries failed tasks from where they left off [5]; treat that as a vendor claim and test it under your own failure modes.
  9. Trace every call. Record tokens, model, tool and outcome per step. The OpenTelemetry GenAI semantic conventions (still marked "Development") define attributes such as gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gen_ai.usage.cache_read.input_tokens and gen_ai.tool.name, and operation names such as invoke_agent and execute_tool [6].
  10. Compare after a month. Actual token spend plus review hours plus engineering hours, against the baseline from step 1.

Estimate tokens per run

This script reproduces the numbers above. Replace the sizes with values measured from your own traces.

# agent_tokens.py: total input tokens for a loop that re-sends its history
def loop_input_tokens(prefix: int, per_step: int, steps: int,
                      history_cap: int | None = None) -> int:
    """prefix: stable tokens sent on every call (system prompt, tool definitions)
    per_step: tokens each step adds to the history (tool call + result)
    history_cap: if set, history is compacted so it never exceeds this size
    """
    total = 0
    for i in range(steps):  # i = number of earlier steps in the history
        history = per_step * i
        if history_cap is not None:
            history = min(history, history_cap)
        total += prefix + history
    return total


if __name__ == "__main__":
    for n in (10, 20, 30):
        full = loop_input_tokens(8_000, 2_000, n)
        capped = loop_input_tokens(8_000, 2_000, n, history_cap=6_000)
        print(f"{n:>2} steps: {full:>9,} full  {capped:>9,} compacted")

Output (Python 3.10 or later):

10 steps:   170,000 full    128,000 compacted
20 steps:   540,000 full    268,000 compacted
30 steps: 1,110,000 full    408,000 compacted

Enforce a budget on every run

Call charge() after each model response. The field names match the Anthropic Messages API, where input_tokens counts only uncached input, so the cached fields must be added to get the full figure [4].

import time


class BudgetExceeded(RuntimeError):
    pass


class LoopBudget:
    def __init__(self, max_steps=15, max_input_tokens=300_000, max_seconds=300):
        self.max_steps = max_steps
        self.max_input_tokens = max_input_tokens
        self.deadline = time.monotonic() + max_seconds
        self.steps = 0
        self.input_tokens = 0

    def charge(self, usage):
        self.steps += 1
        self.input_tokens += (usage.input_tokens
                              + (usage.cache_creation_input_tokens or 0)
                              + (usage.cache_read_input_tokens or 0))
        if self.steps >= self.max_steps:
            raise BudgetExceeded(f"step limit {self.max_steps} reached")
        if self.input_tokens >= self.max_input_tokens:
            raise BudgetExceeded(f"{self.input_tokens:,} input tokens used")
        if time.monotonic() > self.deadline:
            raise BudgetExceeded("wall-clock deadline passed")

To cache the stable part of each request, Anthropic's API accepts a top-level cache_control field (or one on individual content blocks); the response's usage then reports cache_creation_input_tokens and cache_read_input_tokens so you can confirm hits [4]:

{
  "model": "your-model-id",
  "max_tokens": 1024,
  "cache_control": { "type": "ephemeral" },
  "system": "Long, stable instructions and policies go here.",
  "messages": [{ "role": "user", "content": "Reconcile account 4471 for October." }]
}

The security cost is part of the price

Tools are what make an agent useful, and they are also its attack surface. Simon Willison's "lethal trifecta" names the dangerous combination: access to private data, exposure to untrusted content, and the ability to communicate externally in a way that could be used to steal that data [7]. An agent that reads customer emails, can query your CRM and can send HTTP requests has all three. The Handbook's advice is to remove at least one leg, for example by blocking outbound calls or keeping raw personal data out of the model's context [3]. That design work, and the reviews that go with it, belongs in the right-hand column of the ledger.

Checklist before an agent goes to production

  • Baseline cost of the current process recorded (volume, minutes per case, error rate).
  • Objective definition of "done" that code can check.
  • Reason written down for why a fixed workflow is not enough.
  • Hard limits on steps, input tokens and wall-clock time, with hand-off to a person on breach.
  • Stable prefix placed first and cache hits visible in usage data.
  • History compaction in place; no raw multi-megabyte tool output in context.
  • Approval steps for any write, payment or external message.
  • At least one leg of the lethal trifecta removed.
  • Per-step traces with token counts, tool names and outcomes.
  • Run state persisted so a failure resumes rather than restarts.

Common mistakes

  • Pricing the demo, not the distribution. The happy path takes six steps; the awkward 10% of cases take thirty. Because tokens grow with the square of steps, those cases can dominate the bill.
  • Counting tokens and nothing else. Review time and engineering time are usually the larger costs, and they recur.
  • Reading input_tokens as the total. With caching on, the uncached figure alone under-reports what the model processed [4].
  • No stop condition. An agent that retries a failing tool indefinitely spends money and achieves nothing.
  • Agent where a script would do. If the steps never change, you are paying for flexibility you do not use [2].
  • Broad credentials "for now". Privileges granted for a pilot tend to survive into production.

What to do this week

  1. Pick one candidate process and record its baseline: cases per week and median minutes per case.
  2. Pull ten real traces from any agent you already run and measure prefix size, tokens per step and step count. Run the script with those numbers at the 50th and 95th percentile step counts.
  3. Add a step limit and a token limit to that agent, wired to a hand-off rather than a silent failure.
  4. Check whether your stable prefix is actually being cached by looking for non-zero cache read tokens in the usage data.
  5. List each tool the agent can call and mark which legs of the lethal trifecta it touches.

Agents pay off where the work is repetitive, checkable and expensive for people to do, and where the costs they add are measured and capped. If you want a second pair of eyes on where an agent will and will not earn its keep in your organisation, our AI agents team is happy to talk it through.

References

  1. HumanLayer, 12-Factor Agents: Principles for building reliable LLM applications (GitHub)
  2. Anthropic, Building effective agents
  3. Nikola Balić, The Agentic AI Handbook: Production-Ready Patterns
  4. Anthropic, Prompt caching (Claude API documentation)
  5. Dapr Agents (GitHub repository)
  6. OpenTelemetry, Semantic conventions for generative AI
  7. Simon Willison, The lethal trifecta for AI agents (16 June 2025)