AI Agent Hosting Billing Splits Sandbox Runtime from Plugins

    As AI agents move from simple question-and-answer interactions to long-running automated tasks, hosted agent billing is shifting from model token usage alone to a three-part model: sandbox runtime hours, model inference, and external plugin calls. This article breaks down the new cost structure, explains why the runtime environment is billed separately, and shows how to model budgets, design stable long-running tasks, govern plugin usage, and handle pre-inference security checks. It also offers configuration guidance for time-sensitive versus call-sensitive scenarios.

    When AI agents move from “one question, one answer” to long-running automated tasks, billing models are changing too. Vendors used to charge mainly for model token usage. Recent hosted agent services split the cost into three parts: runtime for the execution environment, model inference, and calls to external tools (plugins). Total cost can be expressed as: sandbox runtime (hours) × hourly rate + model inference cost + number of plugin calls × corresponding rate.

    For example, based on publicly listed pricing, if an environment is billed continuously for thirty days, the runtime cost alone is about 51.84 yuan, not including inference or tool calls. Rates for different tools range from 0.001 yuan per call to 0.45 yuan per call. Web search costs about 0.03 yuan per call, image search about 0.045 yuan per call, and some financial data tools can reach 0.35 or 0.45 yuan per call.

    The direct implication for developers is that cost is no longer determined only by “how much text was generated.” It is determined jointly by “how long the environment stays running and how many external capabilities are called.” An idle but continuously online agent keeps generating cost. For an investment research task that frequently calls data plugins, tool costs may even exceed inference costs. Cost management must therefore be upgraded from prompt optimization to runtime architecture optimization.

    Why the Runtime Environment Becomes a Separate Billing Item

    To complete long-running tasks, an agent needs a runtime and orchestration layer built around the model, commonly called a harness in the industry. It organizes model calls, tool execution, session state management, and task scheduling, and adds capabilities such as failure recovery, timeout retries, and access control. Without this layer, the model can only output suggestions; with it, the model can keep executing unattended.

    The runtime environment is billed separately for three reasons. First, it represents real resource usage: containers or sandboxes need CPU, memory, disk, and network, and they consume resources even when idle. Second, it is the state carrier: session history, intermediate artifacts, and temporary files must be persisted until the task ends. Third, it is a security boundary: tool outputs and external data need to be processed in a controlled environment. Separating this part from tokens and pricing it independently is essentially accounting for “compute resources” and “intelligence capability” separately. The bill is clearer, but it also requires developers to be aware of resource lifecycles.

    Cost Breakdown and Budget Modeling

    It is recommended to model the budget in three layers:

    1. Fixed layer: environment runtime. Control it by shortening uptime, starting and stopping on demand, and releasing resources as soon as the task ends.
    2. Semi-variable layer: model inference. It correlates positively with input and output length, number of task steps, and retry count.
    3. Variable layer: plugin calls. It is strongly correlated with the rates of business data sources and call frequency, and has the largest fluctuation.

    The following is an illustrative cost estimation code example:

    1. def estimate_cost(hours, sandbox_rate, tokens, token_rate, calls):
    2. sandbox = hours * sandbox_rate # environment runtime cost
    3. inference = tokens * token_rate # inference cost
    4. plugins = sum(c * p for c, p in calls) # cost of each plugin call
    5. return sandbox + inference + plugins
    6. # Example: environment runs for 5 hours, plugins given as "calls × rate"
    7. cost = estimate_cost(
    8. hours=5,
    9. sandbox_rate=0.072,
    10. tokens=1_200_000,
    11. token_rate=0.000004,
    12. calls=[(200, 0.03), (50, 0.35), (20, 0.045)]
    13. )
    14. print(round(cost, 2))

    The value of modeling is to answer a key question: is this task “runtime-sensitive” or “call-sensitive”? If reducing plugin calls to zero lowers cost by less than 20%, the bottleneck is environment uptime. If it lowers cost by more than half, data source call policies should be addressed first.

    Stability Design for Long-Running Tasks

    Hosted environments provide 24/7 online capability and typically support session history, sandboxes, failure recovery, timeout retries, and multi-agent orchestration. Engineering should focus on four points:

    • Idempotency: every tool call must be replayable to avoid duplicate writes or duplicate billing caused by retries.
    • Checkpoints: persist intermediate state so that failures resume from the latest checkpoint instead of rerunning the entire segment.
    • Layered timeouts: distinguish model timeouts, tool timeouts, and overall task timeouts, and set separate retry limits.
    • Orchestration convergence: for multi-agent collaboration, set a maximum number of steps and termination conditions to prevent agents from waiting on each other and leaving the environment idle for a long time.

    Governing Plugins and External Data Sources

    External data plugins have the highest rates and are the easiest to lose control of. Recommended practices include: establishing a plugin whitelist and a rate ledger; caching results for high-frequency queries and setting TTLs; changing “per-call” usage to “batch aggregated calls”; downgrading non-critical tasks to public data sources; and setting a per-task plugin budget cap in code that triggers a circuit breaker when exceeded.

    1. class PluginBudget:
    2. def __init__(self, limit):
    3. self.limit = limit
    4. self.spent = 0
    5. def call(self, price):
    6. if self.spent + price > self.limit:
    7. raise RuntimeError("plugin budget exceeded")
    8. self.spent += price
    9. return True

    Security and Compliance: Content Checks Before Inference

    Some hosted services provide a separate security component that checks task inputs and tool outputs before each model inference, allowing or blocking sensitive data according to enterprise-defined rules. It is typically available only to users who have completed enterprise verification. In practice, it is recommended to maintain sensitive data identification rules separately from business rules; keep audit records for blocked events; and treat external returned content as untrusted input by default to avoid prompt injection.

    Typical Scenarios and Configuration Recommendations

    For scenarios that integrate with internal enterprise systems, such as business monitoring and operations response, tasks are mostly runtime-sensitive. Use a resident but low-spec environment and configure alerts and automatic release. For scenarios embedded in external products, such as investment research assistants and customer service assistants, tasks are mostly call-sensitive. Focus on governing data source calls and cache hit rates. Usage generally includes three methods: a visual console, command-line tools, and an API. It is recommended to use the console for development-time validation, the API during integration, and the command line for batch operations.

    In related practices at Baidu AI Cloud, similar capabilities typically fall under common product categories such as container platforms, object storage, log services, and monitoring and alerting: environments are hosted by containers, state is persisted with object storage, links are traced with log services, and costs are monitored with threshold alerts. Connecting these three billing items to monitoring metrics is what truly enables “attributable cost, recoverable tasks, and auditable calls.”