Context window sizing for fine-tuning: how long should your training examples be?

Fine-tuning example length is a design decision, not a byproduct of your data. Pad too short and you teach a distribution you’ll never see at inference; let examples sprawl and you pay quadratic training cost to memorize context you should be retrieving. How to size training sequences to the context you’ll actually serve.

July 18, 2026 · 6 min · 1113 words · Loop & Retry

Your timeout is a bet: pricing the tradeoff before you pick a number

Every per-step timeout is a number someone typed in without a model behind it — too short and you kill real work in flight, too long and you pay to sit idle waiting on a hang. Both mistakes are failure modes with a price tag. A small cost model finds the number that actually minimizes total cost instead of the one that felt safe.

July 18, 2026 · 6 min · 1235 words · Loop & Retry

Retry budgets by language: Python, Go, and JavaScript

A retry budget is a language-agnostic idea, but the place you enforce it is not. Python’s tenacity decorators, Go’s context-plus-backoff, and JavaScript’s promise chains each make a different mistake easy and a different guarantee hard. Where the shared budget lives, and the per-language trap that leaks it.

July 15, 2026 · 6 min · 1227 words · Loop & Retry

Debugging a failed agent run costs more than the run itself

The cheap part of a failed agent run is running it again. The expensive part is that you can’t — the failure was non-deterministic, so the run that broke is gone, and you pay to summon it back. A cost model shows why reproduction, not repair, dominates your debugging bill, and why always-on tracing is almost always cheaper than the alternative it replaces.

July 14, 2026 · 7 min · 1305 words · Loop & Retry

Your token bill is the cheap part: dimensioning the real cost of an agent

Everyone budgets the token bill because the provider hands you an invoice for it. But an agent in production spends across five other axes that never show up on that invoice — wall-clock latency, orchestration, tool-call fees, human review, and idle polling — and for a lot of workloads the tokens are the smallest line. A model that sums all six so you can see which one you’re actually paying.

July 14, 2026 · 8 min · 1534 words · Loop & Retry

Cheap first, smart later: model routing that cuts cost without cutting quality

Most requests to your agent are easy, and you’re paying frontier-model prices for all of them anyway. A routing cascade — try the cheap model, escalate on a measurable confidence signal — cuts spend without touching output quality, if you get the escalation trigger right. Here’s the pattern, where it breaks, and the arithmetic on when it’s worth building.

July 13, 2026 · 7 min · 1429 words · Loop & Retry

Distributed retry patterns: bounding blast radius across a fleet

A per-step retry cap bounds a step. It never bounds a run, and it never bounds a fleet — twelve workers each retrying ‘reasonably’ is how you turn one bad deploy into a bill. The four patterns that actually put a ceiling on what a fleet of agents can spend recovering from a failure: shared retry budgets, circuit breakers, decorrelated backoff, and poison quarantine.

July 13, 2026 · 6 min · 1229 words · Loop & Retry

Why a long agent run costs O(N²) tokens — and how to flatten it

A naive agent’s token bill doesn’t grow with the number of steps — it grows with the square of them, because every step re-reads the whole transcript that every previous step appended to. A small cost model shows the curve, and four structural moves turn the quadratic back into something close to linear without dropping information the agent actually needs.

July 13, 2026 · 6 min · 1145 words · Loop & Retry

Postmortem: the agent that spent $200 retrying a 400

An agent burned ~$200 overnight retrying an HTTP 400 — a request that was defined to fail. No component was buggy; each layer retried “reasonably.” The teardown: why retryability is a property of the error and not a default, how three nested retry caps multiply into 75 doomed attempts per item, and why per-step caps never bound a bill. With the two-line fix and a circuit breaker.

July 12, 2026 · 11 min · 2140 words · Loop & Retry

When not to build an agent

An agent is an LLM that controls its own control flow — and that autonomy has a price you pay on every run: quadratic token cost, serial latency, and a failure surface you can’t unit-test. Most tasks people reach for an agent on are a fixed pipeline wearing a costume. Here’s the decision checklist I use, the arithmetic on what the agent tax actually costs, and the same task built both ways so you can see the difference.

July 8, 2026 · 10 min · 1945 words · Loop & Retry