Generative AI & Agentic AIAgent workflows and state

Tool errors: distinguish retryable and permanent failures

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 2 min read
Technically reviewed by Ishaan Sharma
In this article (5 sections)

Retrying every exception wastes time and can repeat writes. Error contracts should distinguish transient availability from invalid requests, denied authority and business rejection.

Route stable reason codes

The agent controls lab defines four authored errors.

python
from agent_cases import error_taxonomy_case

result = error_taxonomy_case()
assert result["retryable"] == ["rate_limit", "timeout"]
assert result["permanent"] == ["invalid_arguments", "permission_denied"]
assert result["blind_retry"] is False

Rate limit and timeout can retry within budget. Invalid arguments require a repaired proposal; permission denial stops and reports. The table does not describe every provider.

Design a typed tool result

Return success/failure, stable code, retryable flag, safe message, operation receipt and optional retry-after. Keep stack traces and secrets out of model-visible content. The orchestrator—not model prose—applies retry policy.

For write timeouts, outcome may be unknown. Query by idempotency key before retrying. Business errors such as duplicate request or closed account may be successful tool execution with a non-approved outcome.

Test each policy

Inject every code, exhaust retries, cancel during backoff and verify total budget. Check that a permanent failure cannot be transformed into a retryable one by a retrieved instruction.

The Generative & Agentic AI course connects typed errors to termination, runbooks and user-facing recovery.

Exercise

Define ten codes for one integration. Simulate each and assert attempts, final state, user message and side-effect count.

Continue learning

This article is part of the Agent workflows and state sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

Reference: Google API error model.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Generative & Agentic AI programme — 3 months. Add practical GenAI, retrieval and agent-building skills to your existing toolkit.

Explore Generative & Agentic AI
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.