How Uber Scaled AI Agents 9.4x While Keeping Costs Flat: A Cost Equation Breakdown

Uber's engineering blog reveals how they scaled AI agent usage 9.4x while keeping costs flat by decomposing total spend into six measurable variables, optimizing model selection via benchmarks, reducing token consumption through CLI-based MCP calls and Code-Mode, leveraging a 24M-node context graph, and implementing real-time cost visibility for engineers.

TonyBai
TonyBai
TonyBai
How Uber Scaled AI Agents 9.4x While Keeping Costs Flat: A Cost Equation Breakdown

Introduction: Massive Usage Growth with Flat Costs

Uber's distinguished engineer Uday Kiran Medisetty disclosed that from February to August 2026, weekly active users across all agent products grew 7× , weekly agent requests grew 9.4× , and over 70% of pull requests are now driven by local or cloud agents. Meanwhile, total AI spend has remained flat since April; per‑thousand‑request cost fell ~34% from its peak, and per‑session cost dropped 52% from the June peak. To isolate engineering optimizations from model upgrades, Uber fixed model versions and measured cost changes from February to July — confirming the gains came from system‑level improvements, not model substitutions.

Four‑Layer Architecture: Control Increases with Layer

Uber categorizes AI workloads into four layers, from most specialized to most general. Higher layers give the team stronger control over cost, quality, and model selection, and receive the bulk of investment:

Managed Agents — fully autonomous, task‑specific (code review, CI self‑heal, PR visualization, on‑call triage, debugging).

Autonomous Agents — self‑directed but with broader scope.

Interactive Harness — human‑in‑the‑loop coding assistants.

General‑Purpose Chat — ad‑hoc queries.

Because managed and autonomous agents have well‑defined, measurable tasks, Uber can build dedicated benchmarks and pick the most cost‑effective model for each, rather than forcing a single flagship model to handle every interactive scenario.

Cost Equation: Six Independently Optimizable Variables

Total Spend = Users × Sessions/User × Turns/Session × Requests/Turn × Tokens/Request × Price/Token.

Users, Sessions/User — adoption & engagement (numerator Uber wants to grow).

Turns/Session, Requests/Turn, Tokens/Request — agent‑internal overhead (where waste hides; primary optimization target).

Uber built a weekly/monthly monitoring dashboard covering five dimensions: Portfolio, Unit Economics per tool, Model Economics, Driver Decomposition, and Managed Agent Outcomes — ensuring every cost fluctuation is attributable.

Lever 1: Price/Token — Benchmark‑Driven Model Selection

Uber standardizes a four‑step model‑selection loop for every managed agent:

Define target outcome metrics.

Build a benchmark from real work (e.g., historical PRs with known bugs).

Run evaluation on a model‑agnostic framework.

Pick the Pareto‑optimal configuration (best quality per dollar).

Example: uReview code‑review agent. Using a graded set of real PRs, Uber measured Precision, Recall, F1, cost, latency, timeout rate, and noise. Switching models improved F1 while drastically cutting per‑review cost ; the new configuration sits on the Pareto frontier. Uber also maintains an internal Uber SWE Benchmark spanning thousands of PRs across multiple monorepos for all SDLC agents.

For interactive sessions, two defaults are set: Initial Session Model and Subagent Model . Subagents handle narrow, well‑scoped subtasks and are routed to cheaper models (with manual override), while the primary model handles planning and evaluation.

Lever 2: Tokens/Request — Slimming Every Request

Default Config: 400K Context Cap + Medium Reasoning

Even for 1M‑token models, auto‑compaction triggers at 400K tokens — a sweet spot balancing model performance, cache hit rate, and repeat‑input cost.

Reasoning Effort defaults to "medium" — output tokens (including internal reasoning) are billed at multiples of input tokens; this single switch cuts the most expensive token category.

Prompt Cache TTL: An Economic Decision

Caching prefix context avoids re‑paying full price; cached reads cost 0.1× standard input price. But cache writes carry a premium: 5‑min TTL = 1.25× , 1‑hr TTL = 2× . Uber analyzed engineers' actual pause distributions between turns. Because interactive sessions often pause >5 minutes, the default 5‑min TTL caused frequent cache misses and full‑price rebuilds. They switched the main session TTL to 1 hour ; subagents (short‑lived, single‑task) keep 5‑min TTL.

MCP Tools: From Preload to CLI‑fied On‑Demand Calls

Uber routes all MCP (Model Context Protocol) traffic through a unified gateway covering 1,000+ internal and third‑party MCP servers . Standard MCP preloads every tool's full schema into context — 50K–70K tokens per session, repeated every turn. Uber eliminated this with two complementary mechanisms:

CLI‑fied calls: Model executes a shell command; the CLI dynamically resolves and forwards to the gateway at call time. Zero MCP schema appears in context. All 1,000+ tools are mapped to CLI commands.

Tool Search: Model first searches a tool directory, loading only the definitions needed for the current task. Keeps token usage low even as the tool library grows.

Code‑Mode: Compressing Multi‑Turn Loops into One Script

With tools exposed as shell commands, the model can batch multiple operations in a single script — especially valuable for "chatty" protocols requiring polling. In standard MCP, each poll writes intermediate state into context. Code‑Mode runs the entire loop (submit → poll → fetch) in a subprocess; only the final summary returns to the model.

Uber tested 5 identical SQL queries in the same session: SELECT 1 (1 row): 903 → 402 tokens ( 55% saved) COUNT(*) (1 row): 954 → 403 tokens ( 58% saved) GROUP BY LIMIT 20 (20 rows): 1,600 → 457 tokens ( 71% saved) SHOW COLUMNS (175 rows): 2,200 → 900 tokens ( 59% saved) SELECT * wide table (50 rows): 1,431,594 → 900 tokens ( ~100% saved)

Even tiny result sets save >50% because schema initialization, polling, and stepwise reasoning overhead vanish. Batch workflows exceed 90% savings. Uber has deployed 25+ prebuilt Code‑Mode skills for the highest‑traffic MCP servers.

SaaS MCP: Same Gateway, Per‑Vendor Code‑Mode Plugins

Third‑party SaaS MCP servers often expose dozens of tools (e.g., 49 tools ≈ 22K tokens). Uber onboards them through the same gateway, maps to CLI, and writes vendor‑specific Code‑Mode plugins that encapsulate common workflows — achieving high‑efficiency agent flows across diverse SaaS products.

Lever 3: Requests/Turn — Giving Agents a Map (AI Context Graph)

An agent without context doesn't fail fast; it fails slowly, repeatedly searching with ever‑longer contexts. Uber built an AI Context Graph with 24M nodes, 80M edges, 86 node types, 117 edge types , integrating data from 30+ internal systems (services, teams, incidents, PRs, design docs, deployments, datasets, historical query logs). Any agent can query it in natural language.

Concrete example: A "find the core fact table for business metric X" task. With the graph, the agent retrieved historical usage records, confirmed the table was used by 50+ analysts, and answered correctly in 38 seconds . Without the graph, the agent spent 20 minutes crawling service code, spawned 2 subagents, hit 3 errors, and incorrectly concluded the dataset was unqueryable.

Lever 4: Visibility & Culture — Engineers and Agents Learn to Save Together

Real‑Time Cost Counter in Status Bar

Every interactive harness shows a live session cost and the user's cumulative spend across all harnesses.

Tiered Budgets with Slack Alerts (Not Hard Caps)

Shared harness pool budget (not per‑tool limits).

Managed agents have separate tiered budgets.

Slack notifications at 50%, 80%, 100% of budget.

Fast manager approval for budget increases.

Cost self‑audit skill for on‑demand breakdowns.

This lets engineers self‑regulate ("is this task worth the spend?") without hard quotas that cause frustration.

Session Analysis Dashboard: 16 Automated Waste Patterns

The dashboard ingests raw session traces (zero config) and flags 16 anti‑patterns with estimated waste and concrete fixes. Examples:

Model misrouting — simple multi‑turn chat running on flagship model.

Bloated context window — large MCP responses (e.g., 40KB) lingering and re‑billed every turn.

Cache expiry waste — long pauses invalidate prompt cache, forcing full‑price rebuild.

Excessive prompt initialization — 100K+ tokens of system instructions and tool defs loaded before user input.

Results & Strategic Conclusion

Stacking these levers delivered 7× usage growth with across‑the‑board unit‑cost reductions and stable or improved output quality . Uber concludes that AI coding cost overruns are an engineering‑solvable problem — the key is systematically eliminating zero‑value token consumption, not chasing lower unit prices or cutting tools. Strategically, they are shifting human‑driven interactive flows to fully managed agents, because a fleet of "dedicated benchmark + Pareto‑optimal model" agents is inherently cheaper and more scalable than optimizing thousands of individual engineer sessions.

Next Steps for Uber

Expand managed agent fleet using the same rigorous benchmark‑first process.

Dynamic model routing — broaden benchmark coverage across languages, repos, agent types.

Deeper context graph integration for more autonomous agents.

Move session analysis from batch post‑processing to real‑time trace monitoring with personalized efficiency nudges.

Automated skill self‑improvement — collect "papercuts" from execution traces and generate skill updates.

Takeaways for Other Teams

Measure first, optimize later. Without granular metrics (cost per 1K requests, per session, per managed agent), optimization is guesswork.

MCP integration method is a major cost lever. If you've onboarded many MCP servers, audit the hidden schema‑preload tax — CLI‑fication + on‑demand search may be the highest‑ROI refactor.

Prompt Cache TTL isn't "set and forget". Tune it to your team's actual pause rhythms.

Knowledge‑graph‑style context engineering can yield outsized returns, especially in large codebases where agents frequently get lost.

Cost visibility is a governance tool. Transparent, real‑time feedback beats blunt quotas.

References: Uber Engineering Blog. Running a Software Factory Efficiently at Uber Scale . 2026‑08‑27. https://www.uber.com/br/en/blog/efficient-software-factory/ Uber. AI Engineer 2026 talk: Uber Software Factory Vision. https://youtu.be/17-YSUHo6Lk
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AI agentsMCPCost Optimizationmodel selectionUberprompt cachingCode-Modecontext graph
TonyBai
Written by

TonyBai

Tony Bai's tech world (tonybai.com). Not satisfied with just "knowing how", we strive for mastery. Focused on Go language internals, high-quality engineering practices, and cloud‑native architecture, exploring cutting‑edge intersections of Go and AI. Gophers who pursue technology are welcome—follow me and evolve with Go.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.