Agent Hosting Billing Gets More Granular: Breaking Down the Three-Part Cost Structure

    This article explains how hosted AI agent billing is shifting from a single token-based model to a three-part cost structure covering sandbox runtime, model inference, and plugin invocations. It breaks down why each cost layer is measured separately, why long-running tasks make idle environments expensive, how growing context drives inference costs, and how wide plugin price ranges require per-task budgeting. It also describes the role of a harness in long-running task reliability and provides a reproducible cost estimation and optimization checklist for engineering teams.

    1. From Token-Only Billing to a Three-Part Cost Structure

    Until recently, developers paid for large model capabilities with a bill determined almost entirely by the number of input and output tokens. The model was simple but coarse: it treated “model thinking” and “task execution” as the same thing. Once agents evolved from single-turn question answering into long-running tasks that can run for hours or even days, this billing approach no longer reflected actual resource consumption.

    A cloud provider recently disclosed pricing for hosted agents that splits the cost into three independently observable dimensions: the duration of the runtime environment, the usage of model inference, and the number of external capability invocations. It can be expressed abstractly as:

    1. Total cost = sandbox hours × sandbox hourly rate
    2. + model inference cost (measured in tokens)
    3. + Σ(plugin invocations of a given type × that type's unit rate)

    The key significance of this change is not whether prices are higher or lower, but that cost is now attributed to specific resource layers. For the first time, the runtime environment is an independent billing object, which means engineering teams can manage agent costs the same way they manage server costs.

    2. Runtime Duration: Why the Sandbox Is Billed Separately

    The sandbox is the isolated environment where an agent executes code, reads and writes files, operates a browser, and runs commands. It requires continuous CPU, memory, disk, and network resources. Even when the model is not generating any tokens at a given moment, resources are still consumed as long as the environment is ready.

    Based on the order of magnitude of the published pricing, a single sandbox running continuously for 30 days at 0.072 yuan per hour costs about 51.84 yuan in runtime fees, not including inference or plugin overhead. The number itself is small, but it reveals a counterintuitive conclusion: for long-running tasks, the fixed cost comes mainly from the environment staying resident, not from model thinking.

    This leads to three engineering constraints:

    • Idle time is waste. While a task waits for human confirmation or an external callback, the environment is still being billed.
    • Concurrency amplifies cost. When each session is assigned its own sandbox, cost grows linearly with concurrency.
    • Lifecycle management is the core optimization point. The timing of creation, reuse, suspension, and destruction directly determines the shape of the bill.

    3. Model Inference Cost: The Most Volatile and Hardest to Predict

    Inference is still measured in tokens, but in agent scenarios its distribution differs significantly from chat scenarios. A single task may involve dozens of model calls, each carrying a growing context: system prompts, tool definitions, historical messages, and tool return results.

    Context grows monotonically with each turn, and this is the main source of runaway costs. Without trimming, the input size of a single call at turn 20 may be several times that of turn 1. Practical controls include: structurally truncating tool return results, converting long documents into retrieval-based on-demand loading, summarizing and compressing completed subtasks, and keeping stable, unchanging prefixes fixed to take advantage of caching mechanisms.

    4. Plugin Invocations: Wide Unit-Price Range, Match by Task

    External capabilities are integrated as plugins, with published unit prices ranging from about 0.001 yuan to 0.45 yuan per call. Among them, web search is about 0.03 yuan per call, image search about 0.045 yuan per call, and some financial data plugins reach 0.35 or 0.45 yuan per call.

    A range of more than 400x means plugin costs must be accounted for by task profile rather than by average. An agent that repeatedly triggers high-priced data plugins in a loop may spend far more on plugins than on runtime and inference combined. In practice, teams should maintain a plugin inventory with budget caps, set invocation quotas and cache reuse for high-priced plugins, and prefer a single structured query over multiple fragmented calls.

    5. Harness: The Support Layer for Long-Running Task Reliability

    A harness is the runtime and orchestration system built around a large model. It organizes model calls, tool execution, session management, and task scheduling, and can integrate capabilities such as exception recovery and access control. The model itself is stateless and does not remember execution progress, so the continuity of a long-running task depends entirely on this layer.

    A minimal viable harness typically includes the following elements:

    1. # Illustrative pseudocode: expresses orchestration responsibilities only, not a specific product API
    2. run = harness.create_session(sandbox_spec=cpu, memory, disk)
    3. try:
    4. for step in plan:
    5. result = model.invoke(context=run.context, tools=toolset)
    6. run.append(result)
    7. tool_output = sandbox.exec(result.tool_call)
    8. run.append(tool_output)
    9. except TimeoutError:
    10. run.retry(step, max_attempts=3, backoff="exponential")
    11. except Exception:
    12. run.checkpoint() # Persist session state to disk
    13. run.resume(from_step=last_ok)
    14. finally:
    15. if run.is_idle():
    16. sandbox.suspend() # Stop runtime billing

    The value of the hosted form is that it packages session history, sandbox lifecycle, failure recovery, timeout retries, and multi-agent orchestration as out-of-the-box capabilities, so developers do not need to build their own scheduling and state storage. Accordingly, the cost boundary expands from “invocation volume” to “hosted resources and orchestration behavior.”

    6. Cost Estimation and Optimization Checklist

    Before launch, it is recommended to do a reproducible budget estimate:

    1. Estimate the average and maximum duration of a single task, multiply by the sandbox unit price to get the runtime baseline;
    2. Count the average number of turns and average context size, estimate the inference cost, and leave a 3x to 5x buffer;
    3. List the plugins and trim them to the “minimum set required for task success,” noting unit prices and expected invocation counts;
    4. Set daily budget caps per task and per tenant, and trigger degradation or handoff to a human when a threshold is reached;
    5. Instrument runtime, tokens, and plugin invocation counts separately with monitoring alerts and logging services to form an attributable bill.

    If an enterprise already uses general capabilities such as a container platform, object storage, logging service, and monitoring alerts on Baidu AI Cloud to run self-built agents, it can apply the same three-part attribution method to account for costs, allowing comparison with the hosted option under the same terms.

    7. Conclusion

    The change in the billing formula is essentially the industry’s renewed understanding of the resource structure of agents: resident environments, model inference, and external tools are three types of costs with different natures and must be measured and governed separately. For developers, real competitiveness lies not in driving down a single unit price, but in turning the spending of long-running tasks into predictable, optimizable engineering metrics through sandbox lifecycle management, context compression, plugin quotas, and attributable monitoring.