Every post is a production failure we've actually hit, with a working stdlib-only fix. No frameworks, no dependencies — Python 3.10+.
The naive retry loop hammers a struggling API in lockstep with every other retrying client. Here's the 15-line stdlib pattern — capped exponential backoff, jitter, and a total wall-clock budget so retries never eat your agent's whole turn.
max_tokens cuts mid-string, json.loads throws, and a naive regex "fix" silently corrupts data. The fix is a ladder of progressively more aggressive repairs that stops at the first parse — and reports which rung saved you.
Platform turn limits kill agent runs mid-flight and everything is lost. The fix is a shared turn budget: every call gets a slice, retries can't overrun it, and when the clock runs out the agent ships partial work with an honest status instead of nothing.
Agents don't die when the context window errors — they get amnesia long before that. Early instructions silently stop mattering while everything still "works." Here's the leading indicator and graduated actions that keep a run alive.