agent_error_processing

A rule set for handling errors in a chain of AI model providers. It separates temporary failures, which can be retried with increasing delays, from permanent failures, which stop the chain.

In plain words
What is it for?
Use it to handle timeouts, rate limits, server failures, unavailable providers, invalid requests or keys, safety blocks, and the case where every model in the chain fails.
Why use it?
Without error categories, a system may waste time retrying invalid requests or stop too quickly when a provider is temporarily unavailable. The rules also define when to try the next fallback model.

Agent

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.

agentmods
npx agentmods add agents/the-teacher/active_harness/agent_error_processing
Clone the repo
git clone --depth 1 https://github.com/the-teacher/active_harness
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 950 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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 $0.00000 $0.00950
Opus 5 $0.00000 $0.00475
Sonnet 5 $0.00000 $0.00190
Haiku 4.5 $0.00000 $0.00095

Measured 2d ago against content hash 6a9b0793a835, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

agent_error_processing scanned grade A with 0 findings 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 2d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/agent_error_processing.md · 132 lines

How it starts

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

Agent Error Processing

ActiveHarness divides errors into two categories: retryable and non-retryable. Retryable errors trigger automatic retries with exponential backoff, then move to the next fallback model. Non-retryable errors abort the entire chain immediately.


Error Hierarchy

ActiveHarness::Errors::Error (base)
  ├── AllModelsFailed           # raised when every model in the chain fails
  └── ProviderError             # base for all provider-level failures
        ├── TimeoutError
        ├── RateLimitError
        ├── ServerError
        ├── ProviderUnavailableError
        ├── InvalidRequestError
        ├── InvalidApiKeyError
        └── SafetyBlockedError

ProviderError carries optional metadata:

error.error_code   # => "model_not_found" (provider-specific code, or nil)
error.metadata     # => Hash with raw provider response fields, or nil

Retryable vs Non-Retryable

Error Retryable Behaviour
TimeoutError Retry same model, then next fallback
RateLimitError Retry same model, then next fallback
ServerError Retry same model, then next fallback
ProviderUnavailableError Retry same model, then next fallback
InvalidRequestError Treated as retryable — next fallback will be tried
InvalidApiKeyError Stops the entire chain immediately
SafetyBlockedError Stops the entire chain immediately

Handling AllModelsFailed

Raised when every model in the fallback chain has been exhausted. Use a standard rescue block around call:

begin
  agent = SupportAgent.call(input: "Hello")
  puts agent.result.output
rescue ActiveHarness::Errors::AllModelsFailed => e
  puts "All models failed: #{e.message}"
  # e.message contains the full list of attempted models and their errors
end

Read the full file on GitHub · 132 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. 2d ago First seen · 132 lines · 0 tokens per session scan A 6a9b0793a835

Subscribe to this mod's changes

agent_error_processing is an agent published in the GitHub repository the-teacher/active_harness (89 stars, last pushed 23d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 950 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.