cleandataengineering.aiAgent Harness, drawn simply
You are here: Cost › Keeping it low

Agent Harness Tutorial · Cost

How we keep it low

Cost is calls × tokens per call × price per token, plus waste. Each lever below pulls one of those down, and most of them are not about cost at all: they are the same harness parts that keep the agent safe.

COST = calls × tokens per call × price per token + wasteVolumehow many callsrouter answers without the modelstep budget + no-progress checkbounded retriesSizetokens per callone context budget, 24,000 charsonly the tools this user may useoutput capped at 4,096Rateprice per tokencheapest model that passes (planned)cache-friendly prompt orderpinned model versionsWastepaying for nothingno retry of unreadable outputcut answers never sentblocked before the model: $0Marginis someone paying?every call tagged to agent and customercost per resolved claim(attribution: to build)
A rising total with a flat cost per turn is growth. Flat users with a rising cost per turn is a problem.
LeverWhat it savesStatus
Deterministic first: the direct paththe whole model call: 104 ms and $0 instead of 7 sbuilt
Cache-friendly orderthe system prompt and tool list stay byte-identical, so the provider can reuse thembuilt (no cached price in PRICES yet)
One context budgetdrops old exchanges instead of re-sending everythingbuilt (a target, not a ceiling: F-128)
Step and no-progress limitsa stuck loop can't keep payingbuilt
ModelSelectorthe golden set picks the cheapest model that passes, per jobdesigned (Tier 14)
Token limits per agent and customer at APIMone noisy customer can't eat the quotanot on the Consumption tier (F-39)

36 cost anti-patterns are catalogued in the Series, such as LLM-15 "agent loop: same tool, same arguments", LLM-09 "full history sent every turn" and LLM-05 "a big model for a small job". The harness concerns prevent most of them by design: the loop prevents 15, context assembly prevents 09–12 and 28, the gateway prevents 05, 08, 24, 01 and 02.