exception-handling

exception-handling is a skill for Claude Code, Codex from hajekim/agentic-design-patterns-extension. It costs 383 tokens per session (3,670 once invoked), scanned A, a copy of exception-handling, MIT.

A guide to handling errors in AI agents, including failures from external services, invalid inputs, and unexpected responses. It covers recovery, retries, fallbacks, and deciding when to stop or ask for help.

In plain words
What is it for?
Use it when agents call APIs or databases, run long workflows, face rate limits, or need to recover from partial failures.
Why use it?
It prevents an agent from crashing or continuing with incorrect data when a tool, service, or model response fails.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when agents call APIs or databases, run long workflows, face rate limits, or need to recover from partial failures.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hajekim/agentic-design-patterns-extension/exception-handling
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add hajekim/agentic-design-patterns-extension --skill exception-handling
Clone the repo
git clone --depth 1 https://github.com/hajekim/agentic-design-patterns-extension

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for exception-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/hajekim/agentic-design-patterns-extension/exception-handling/github.svg)](https://agentmods.dev/skills/hajekim/agentic-design-patterns-extension/exception-handling)
Your own site
<a href="https://agentmods.dev/skills/hajekim/agentic-design-patterns-extension/exception-handling"><img src="https://agentmods.dev/badge/skills/hajekim/agentic-design-patterns-extension/exception-handling/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for exception-handling

Your own site · 80×15
<a href="https://agentmods.dev/skills/hajekim/agentic-design-patterns-extension/exception-handling"><img src="https://agentmods.dev/badge/skills/hajekim/agentic-design-patterns-extension/exception-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 383 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,670 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00383 $0.03670
Opus 5 $0.00192 $0.01835
Sonnet 5 $0.00077 $0.00734
Haiku 4.5 $0.00038 $0.00367

Measured 8d ago against content hash b2434ea82a42, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

exception-handling scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

response = requests.get(url, timeout=10)
Origin

This is a copy

100% identical to exception-handling — 3 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/exception-handling/SKILL.md · 429 lines

How it starts

The opening of the file, as written. The whole thing — 429 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Exception Handling Pattern

Overview

The Exception Handling Pattern enables agents to detect, respond to, and recover from errors, failures, and unexpected conditions without crashing or producing incorrect outputs. Robust agents treat exceptions as information — they classify the failure, choose an appropriate recovery strategy, and continue operating or escalate gracefully.

Core Principle: Expect failure as a first-class event — design recovery paths before you need them.

When This Skill Applies

Activate this pattern when:

  • Agents call external APIs, databases, or services that can fail or time out
  • Tool calls may return malformed, unexpected, or empty responses
  • Agent reasoning can produce invalid actions (bad parameters, out-of-scope requests)
  • Long-running tasks must survive transient failures without full restart
  • Resource exhaustion (token limits, rate limits, quotas) is possible
  • Partial failures in multi-step pipelines must not silently corrupt outputs

Rule of thumb: If an agent can fail (and it can), it needs exception handling — every external call, every tool invocation, every LLM response that requires a specific format.

Exception Classification

By Cause

Exception Type Examples Recovery
Transient Network timeout, rate limit Retry with backoff
Input Error Invalid parameters, bad format Validate, re-prompt
Tool Failure API down, auth expired Fallback tool or skip
Logic Error Contradictory goals, impossible task Escalate or abort
Resource Exhaustion Token limit, quota exceeded Summarize, paginate, escalate

By Severity

  • Recoverable: Agent can self-correct and continue
  • Degradable: Agent continues with reduced capability
  • Fatal: Agent must stop and notify the user/operator

DEFINE → PLAN → ACTION Workflow

DEFINE

Map the failure landscape:

  1. What external dependencies does the agent have? (APIs, tools, LLMs)
  2. What can go wrong at each dependency? (Network, auth, rate limit, format)
  3. What is the acceptable degraded behavior for each failure?
  4. When should the agent retry vs. escalate vs. abort?

Read the full file on GitHub · 429 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 429 lines · 383 tokens per session scan A b2434ea82a42

Subscribe to this mod's changes

exception-handling is a skill published in the GitHub repository hajekim/agentic-design-patterns-extension (1 stars, last pushed 5mo ago), licensed MIT. It adds 383 tokens to every session and 3,670 once invoked, about $0.0019 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to exception-handling, differing in 3 lines, and is treated as a copy.

Related

Other skills, from other repositories