Cutting LLM Agent Costs and Shipping 3D Spatial Capability
Model gains now show up less as higher scores and more as much lower cost to finish the same long agent task. This article explains why end-to-end cost is multiplicative, how to measure cost per successful task, four practical cost controls, how to turn 3D understanding into a structured scene graph a simulator can consume, and how to choose models with a small regression set instead of a single leaderboard.
The Real Issue Is Not “Smarter,” but “Cheaper to Finish”
Recent model updates show two trends at once. Scores on evaluations of long, multi-step agent tasks continue to rise slightly. At the same time, the cost of completing the same task drops sharply—sometimes to less than one-third of the previous generation. For engineering teams, the second trend is often undervalued.
The reason is simple: an agent’s cost is not one forward pass. It is a chain. Planning, tool calls, result checks, and retries each multiply tokens and call counts. When per-step price falls, failure rate falls, and context reuse rises, end-to-end cost changes by multiplication, not addition.
Scoreboards alone are not enough. At least three quantities should be tracked together:
- Capability: task pass rate and long-horizon completion rate
- Cost: cost per successful task, not unit price
- Stability: retry rate, timeout rate, and output-format compliance rate
Make Cost per Successful Task Observable
Many cost-cutting efforts fail because they watch only the unit price. The right approach is to attribute cost at task granularity.
# Illustrative accounting with successful tasks as the denominatorrecord = {"task_id": task_id,"prompt_tokens": 0,"completion_tokens": 0,"tool_calls": 0,"retries": 0,"success": False,}def on_usage(resp, rec):rec["prompt_tokens"] += resp.usage.prompt_tokensrec["completion_tokens"] += resp.usage.completion_tokensrec["tool_calls"] += 1# Key metricscost_per_task = total_cost / max(success_tasks, 1)retry_ratio = total_retries / max(total_tasks, 1)
With this record, the next optimization usually becomes obvious. If prompt tokens dominate, prioritize context trimming and caching. If retries are high, fix tool contracts and output validation first. If completion tokens are high, tighten the thinking budget or output constraints.
Four Practical Cost Controls
- Prefix caching and context reuse. Keep the system prompt, tool definitions, and domain knowledge in a stable prefix, and put the changing part after it. That raises cache hit rate and cuts repeated billing and time to first token.
- Tiered routing. Send simple requests to a smaller model or to rules, and escalate only complex requests to a high-capability model. Route on computable signals—input length, whether tools are required, confidence—not on intuition.
- Batching and asynchrony. Merge offline extraction and bulk labeling into batches, trading throughput for cost. On the online path, use streaming output to improve perceived latency.
- Structured output constraints. A strict schema reduces parse failures that force the whole chain to rerun. This is one of the easiest hidden costs to miss.
{"type": "object","required": ["action", "params", "confidence"],"properties": {"action": {"type": "string", "enum": ["pick", "place", "simulate", "abort"]},"params": {"type": "object"},"confidence": {"type": "number", "minimum": 0, "maximum": 1}}}
In the cloud, these needs are usually covered by general-purpose categories: object storage for corpora and artifacts, a message queue to decouple tasks, a container platform for elastic inference, and logging plus monitoring and alerting for cost attribution and anomaly detection. Baidu AI Cloud offers product categories for these general capabilities; they can be combined as needed without binding to a proprietary interface.
3D Spatial Understanding: From Captioning to Something You Can Simulate
The breakthrough in 3D is not a nicer picture. It is a structured representation that downstream systems can consume. In practice this usually has four layers:
- Perception: multi-view images or point clouds in; instance segmentation and pose estimation out
- Representation: a scene graph (object nodes plus spatial-relation edges) plus parametric geometry (size, axis-aligned boxes, joint degrees of freedom)
- Reasoning: assembly order, reachability, interference checks, and grasp-pose planning
- Simulation: send the parametric model to a physics engine for rigid-body dynamics, collision, and friction checks
A minimal usable scene graph looks like this:
{"nodes": [{"id": "base", "type": "rigid", "size": [0.4, 0.4, 0.1]},{"id": "arm", "type": "revolute", "parent": "base", "axis": [0, 0, 1],"limits": [-3.14, 3.14]}],"relations": [{"from": "arm", "to": "base", "kind": "attached_to"},{"from": "gripper", "to": "obj_1", "kind": "contact", "force": 12.0}]}
With that intermediate representation, model output changes from a description into an executable plan. The simulator verifies it. On failure, the error is fed back so the model can replan. That loop is what actually makes embodied and engineering-design applications work, and it is the precondition for 3D capability to create business value.
Evaluation and Selection: Do Not Let One Leaderboard Decide
Leaderboard scores are a necessary reference, but the definitions differ: whether a fallback model is allowed, whether some tasks are excluded, and whether the thinking budget is the same. For selection, build a small regression set of your own:
- Sample 100 to 300 tasks from real workloads, covering both frequent and long-tail cases.
- Fix the judging script and use pass rate, not human impression.
- Record cost, P95 latency, and format compliance at the same time.
- Rerun the set on every model or prompt change and keep a trend curve.
Conclusion
A slight rise in capability plus a large drop in cost pays off for teams that make cost an observable metric, turn 3D output into a structured intermediate layer, and run evaluation as a regression pipeline. The model is only one variable. The engineering loop is what converts that variable into return.
