Troubleshooting & Reliability Best Practices
These are the practices that separate a team that treats every Claude API failure as a one-off mystery from one that recognizes patterns, fixes root causes, and gets faster at incident response over time.
Search across all documentation pages
These are the practices that separate a team that treats every Claude API failure as a one-off mystery from one that recognizes patterns, fixes root causes, and gets faster at incident response over time.
input_tokens/output_tokens logging is your earliest signal of context growth or a cache miss storm, long before the monthly invoice tells you.anthropic-ratelimit-requests-remaining, -input-tokens-remaining, and -output-tokens-remaining tell you exactly which ceiling triggered a 429, which changes the fix.RateLimitError, connection/timeout errors, and 5xx responses are retryable; a malformed-request 4xx will fail identically every time, retrying it just adds noise.input_schema; validate even for tools that "always" get simple arguments in practice.is_error tool results instead of silently swallowing validation failures. A silently caught error looks like a successful turn to the rest of the agent loop, and the real failure surfaces later, disconnected from its cause.tool_use block from its tool_result, which the API will reject outright.dict or set can silently reorder the serialized prefix between deploys, breaking the cache hash without any code change to the tools themselves.Passing every item in categories A-C is the baseline for a production Claude integration that fails gracefully under normal conditions. Categories D-F matter most for agentic, multi-turn, or high-volume workloads, where lifecycle and cost failures compound in ways a simple chatbot integration rarely sees.
Category A, observability foundations. Structured logging, failure classification, and token tracking cost little to set up and make every other category, retries, validation, cache monitoring, dramatically easier to reason about once you actually have incidents to diagnose.
No. Only retry genuinely transient exceptions (rate limits, connection/timeout errors, 5xx). Retrying a malformed-request 4xx or a schema validation failure will fail identically every time and just adds latency and noise.
Because a cache miss never produces an error, the request still succeeds normally, it's just billed and timed at full cost. Without a dedicated hit-rate metric, a miss storm is invisible until a cost or latency dashboard eventually reveals it.
Treating a failure as resolved once the symptom stops, without capturing enough detail (a request ID, a header breakdown, a serialized prefix diff) to actually confirm the root cause. That gap is what turns a one-time incident into a recurring one.
Yes. Nothing structurally guarantees a model's tool call matches your schema, it's a strong prompt-level convention, not an enforced contract. A tool that "always" gets simple arguments in testing can still receive a malformed call in production.
At minimum, after every incident, checking which rule would have caught it earlier or faster. Many teams also do a lighter periodic pass (quarterly is common) independent of incidents, since new tools or workflows can introduce gaps this list didn't originally cover.
Not if you follow the persistence practice in category D: keep the full conversation history in your own storage and only trim the working window sent to the API. Trimming should only ever affect what the model sees, never what you retain.
The cache hashes the exact serialized prefix, including tool definitions. If tool lists are built from an unordered collection, the serialized order can shift between deploys or process restarts, changing the hash and breaking the cache even though nothing about the tools themselves changed.
An explicit owner, a target date, and a concrete verification step (a test that now passes, a metric that recovered and stayed recovered). Action items missing any of these three tend to quietly stall.
It matters most for high-volume or agentic workloads where a sustained outage would otherwise mean every in-flight request keeps retrying into a known-bad dependency. Low-volume integrations can often get by with capped retries and good alerting alone.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5 - and the official
anthropicPython SDK (latest 0.x release). Model names, pricing, and SDK versions move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 19, 2026