Agent Hosting Pricing Models and Engineering Practices: From Token-Based Billing to Runtime-Based Billing
This article breaks down the three-part pricing model of hosted agent services—sandbox runtime, model inference, and plugin invocations—and explains why the agent execution environment has become a standalone billing object. It covers practical cost estimation, sandbox lifecycle controls, per-task success metrics, plugin usage governance, reliability patterns such as checkpointed state machines and tiered retries, security boundaries for agents with real execution permissions, observability metrics, and a vendor evaluation checklist for predicting long-term total cost.
1. From Usage-Based Billing to Runtime-Based Billing
Large model services have historically shared one billing convention: tokens consumed by model inference. That model-centric approach is clear enough for a single question and a single answer. It starts to break down when the application form shifts from one-off conversations to agents that can run continuously for hours or even days. What consumes resources in that mode is not only inference, but the entire execution and orchestration environment that hosts the agent.
The industry commonly calls this layer around the model the Harness. It organizes model calls, schedules tool execution, maintains session state, manages task queues, and takes on exception recovery, timeout retries, and permission checks during long-running tasks. Think of it as the runtime of the agent era: the model is the compute core, while the Harness is the middle layer that turns model capability into business results continuously, reliably, and repeatedly.
A platform recently made a hosted agent service publicly available, exposing exactly this layer as an independent cloud-hosted capability. Its pricing structure splits cost into three parts:
Total cost = sandbox runtime × unit price+ model inference cost+ Σ(plugin invocations × plugin unit price)
The direct consequence of this split is that the agent runtime environment becomes a billing object in its own right for the first time. For developers, the focus of cost optimization expands from “shortening prompts” to “governing the lifecycle of the runtime environment.”
2. What the Three-Part Billing Means for Cost, and How to Estimate It
2.1 Sandbox Runtime: The Easiest Cost to Lose Control Of
A sandbox is the isolated environment where an agent executes code, reads and writes files, and calls external tools. Under time-based billing, one easily overlooked fact matters: as long as a sandbox is alive, it keeps costing money whether it is busy executing tasks or waiting for the next model response.
Estimating from the published pricing scale, a sandbox that stays alive for 30 consecutive days costs roughly on the order of fifty RMB for runtime alone. The number itself is not high, but in real workloads the sandbox count is often in the tens to the thousands, and plenty of zombie instances are simply never released, which amplifies cost significantly.
Engineering countermeasures include:
- Set a maximum lifetime (TTL) and force reclamation when it expires;
- Add idle detection so that sandboxes with no interaction for a long period automatically sleep or are destroyed;
- Create short-lived sandboxes per task granularity and release them as soon as the task ends;
- Tier sandbox resource specifications so lightweight tasks do not occupy high-spec environments.
2.2 Model Inference: Tied to Task Complexity
Model inference remains the main cost component, but the source of its variance has changed. In agent mode, a single user request may sit behind a dozen or even a hundred model calls (planning, reflection, tool selection, result validation), so “cost per request” is no longer a meaningful metric. Use “cost per completed task” together with “task success rate” instead.
If failed tasks are retried repeatedly, inference cost multiplies while business output stays at zero. Improving the first-attempt success rate is therefore the most direct way to cut cost.
2.3 Plugin Invocations: Wide Unit-Price Range, Requires Careful Accounting
In the published pricing, plugin invocation unit prices range from a tenth of a cent to roughly four or five tenths of a yuan per call. Web search and image retrieval fall into the low-price, high-frequency category, while some financial data plugins are clearly more expensive. The pattern this suggests: the higher the data barrier behind an external capability, the more expensive each call.
The corresponding governance strategy is to maintain a plugin invocation ledger, track invocation volume and conversion by “plugin × business scenario,” set invocation quotas and a cache layer for high-unit-price plugins, and avoid repeatedly fetching the same data inside loop logic.
3. Reliability Design: Making Long-Running Tasks Actually Finish
A hosted environment offering 24/7 availability is only the baseline; stability for long-running tasks depends on a more complete set of mechanisms. A reference capability list includes session history persistence, isolated sandboxes, failure recovery, timeout retries, and multi-agent orchestration.
At the implementation level, model the task explicitly as a resumable state machine rather than a one-shot script:
# Skeleton: task with checkpoints and retriesasync def run_task(task, ctx, max_retry=3):for step in task.plan:if ctx.done(step.id): # checkpoint, supports resumecontinuefor attempt in range(max_retry):try:result = await tool_registry.call(step.tool, step.args, ctx=ctx)ctx.save(step.id, result) # persist intermediate resultbreakexcept TimeoutError:await asyncio.sleep(backoff(attempt))except ToolError as e:if not e.retryable:await human_review(step, e) # fall back to human reviewbreakreturn ctx.summary()
Three design principles are key. First, idempotency: repeating any tool call produces no side effects. Second, checkpoints: intermediate results are written to storage to avoid a full rerun. Third, tiered retries: distinguish retryable timeouts from non-retryable business errors.
4. Security Boundaries and Observability
Once an agent holds real execution permissions, its risk model is entirely different from a traditional conversational application: prompt injection may induce it to read sensitive files or call high-privilege tools. This calls for an independent inspection step before and after model inference, allowing or blocking task inputs and tool return content according to enterprise-defined rules. This is an external security component independent of the model and should not be conflated with model capability.
Recommended companions include least-privilege tool authorization, isolation between production and test data, masking sensitive fields before they enter the context, and full-chain operation auditing.
For observability, collect at least four categories of metrics: task success rate, average turns per task, average sandbox lifetime, and plugin invocation distribution. Wiring these into a general logging service and a monitoring and alerting system is what closes the loop across cost, quality, and security.
5. Implementation Recommendations
When evaluating this kind of hosted service, enterprises can start with low-risk internal scenarios (such as operations inspection or report reconciliation) to validate reliability, then expand gradually to customer-facing products. During selection, confirm in particular whether the service supports automatic environment reclamation, whether it supports resuming from checkpoints, whether the plugin ecosystem covers the data sources the business needs, and whether it provides fine-grained permissions and auditing. Writing these capabilities into an acceptance checklist predicts long-term total cost better than comparing unit prices alone.
