agent-reliability-advanced

Agent reliability anti-patterns — retrying non-retryable errors, fixed sleep vs exponential backoff with jitter, single timeout for all call stack levels, aggressive circuit breaker thresholds, using Opus for every call regardless of complexity.

8 stars

Best use case

agent-reliability-advanced is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Agent reliability anti-patterns — retrying non-retryable errors, fixed sleep vs exponential backoff with jitter, single timeout for all call stack levels, aggressive circuit breaker thresholds, using Opus for every call regardless of complexity.

Teams using agent-reliability-advanced should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/agent-reliability-advanced/SKILL.md --create-dirs "https://raw.githubusercontent.com/marvinrichter/clarc/main/skills/agent-reliability-advanced/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/agent-reliability-advanced/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How agent-reliability-advanced Compares

Feature / Agentagent-reliability-advancedStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Agent reliability anti-patterns — retrying non-retryable errors, fixed sleep vs exponential backoff with jitter, single timeout for all call stack levels, aggressive circuit breaker thresholds, using Opus for every call regardless of complexity.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Agent Reliability — Anti-Patterns

This skill extends `agent-reliability` with common mistakes and how to fix them. Load `agent-reliability` first.

## When to Activate

- Retry logic catches authentication or validation errors (not just transient ones)
- All agent calls use the same fixed sleep delay on failure
- A single global timeout governs tool calls, agent calls, and entire workflows
- Circuit breaker opens after every single failure
- Every agent call uses the most expensive model regardless of task complexity

---

## Anti-Patterns

### Retrying Non-Retryable Errors (Auth, Validation)

**Wrong:**

```typescript
async function callAgent(fn: () => Promise<string>): Promise<string> {
  for (let i = 0; i < 3; i++) {
    try { return await fn() }
    catch { await sleep(1000) }  // retries authentication errors — wastes 3 seconds
  }
  throw new Error('failed')
}
```

**Correct:**

```typescript
function isRetryable(err: Error): boolean {
  if (err.message.includes('rate_limit_error')) return true
  if (err.message.includes('overloaded_error')) return true
  // authentication_error, invalid_request_error — do NOT retry
  return false
}

async function callAgent(fn: () => Promise<string>): Promise<string> {
  return withRetry(fn, { retryableErrors: isRetryable })
}
```

**Why:** Retrying authentication or validation errors wastes time, inflates cost, and can trigger account lockouts — only transient infrastructure errors warrant retry.

---

### Fixed Sleep Instead of Exponential Backoff with Jitter

**Wrong:**

```typescript
for (let i = 0; i < 3; i++) {
  try { return await agentCall() }
  catch { await sleep(5000) }  // fixed delay — thundering herd when many clients retry at once
}
```

**Correct:**

```typescript
const exponential = initialDelayMs * Math.pow(backoffFactor, attempt - 1)
const capped = Math.min(exponential, maxDelayMs)
const delay = Math.random() * capped  // full jitter — spreads retry load
await sleep(delay)
```

**Why:** Fixed retry intervals cause synchronized retry storms when many clients fail simultaneously; jitter spreads the load and reduces API overload cascades.

---

### Using the Same Timeout for All Levels of the Call Stack

**Wrong:**

```typescript
const TIMEOUT_MS = 30000

const result = await Promise.race([
  runWorkflow(goal),       // whole workflow — 30s is far too short
  sleep(TIMEOUT_MS).then(() => { throw new Error('timeout') }),
])
```

**Correct:**

```typescript
// Nested timeouts — each level has its own proportional budget
const toolResult = await callToolWithTimeout(tool, 15_000)   // tool: 15s
const agentResult = await runAgentWithTimeout(agent, 60_000) // agent: 60s
const workflowResult = await runAgentWithTimeout(           // workflow: 10min
  () => runWorkflow(goal), 10 * 60 * 1000
)
```

**Why:** A single shared timeout either aborts long workflows prematurely or lets runaway tool calls consume the entire budget — layered timeouts bound each level independently.

---

### Opening a Circuit Breaker Too Aggressively (Low Threshold)

**Wrong:**

```typescript
const breaker = new CircuitBreaker(1, 60_000)  // opens after a single failure
// One transient error now blocks all subsequent calls for 60 seconds
```

**Correct:**

```typescript
const breaker = new CircuitBreaker(5, 60_000)  // opens after 5 consecutive failures
// Transient errors are retried; the circuit opens only on sustained failure
```

**Why:** A threshold of 1 treats every transient error as a sustained outage, causing unnecessary downtime; calibrate the threshold to distinguish spikes from real failures.

---

### Using Opus for Every Agent Call Regardless of Complexity

**Wrong:**

```typescript
async function classifyTaskComplexity(task: string): Promise<TaskComplexity> {
  const response = await client.messages.create({
    model: 'claude-opus-latest',  // ~15x cost of Haiku for a three-word answer
    system: 'Reply with "simple", "medium", or "complex".',
    messages: [{ role: 'user', content: task }],
    max_tokens: 10,
  })
  return response.content[0].text.trim() as TaskComplexity
}
```

**Correct:**

```typescript
async function classifyTaskComplexity(task: string): Promise<TaskComplexity> {
  const response = await client.messages.create({
    model: 'claude-haiku-latest',  // lightweight model for lightweight classification
    system: 'Reply with exactly "simple", "medium", or "complex".',
    messages: [{ role: 'user', content: task }],
    max_tokens: 10,
  })
  return response.content[0].text.trim() as TaskComplexity
}
```

**Why:** Model selection should match task complexity — using Opus for trivial routing wastes budget that should be reserved for tasks requiring deep reasoning.

## Reference

- `agent-reliability` — retry with exponential backoff, timeout hierarchies, fallback chains, circuit breaker, cost control, observability
- `multi-agent-patterns` — orchestration, routing, parallelization, handoffs

Related Skills

typescript-patterns-advanced

8
from marvinrichter/clarc

Advanced TypeScript — mapped types, template literal types, conditional types, infer, type guards, decorators, async patterns, testing with Vitest/Jest, and performance. Extends typescript-patterns.

tdd-workflow-advanced

8
from marvinrichter/clarc

TDD anti-patterns — writing code before tests, testing implementation details instead of behavior, using waitForTimeout as a sync strategy, chaining tests that share state, mocking the system under test instead of its dependencies.

swift-patterns-advanced

8
from marvinrichter/clarc

Advanced Swift patterns — property wrappers, result builders, Combine basics, opaque & existential types, macro system, advanced generics, and performance optimization. Extends swift-patterns.

serverless-patterns-advanced

8
from marvinrichter/clarc

Advanced Serverless patterns — Lambda idempotency (Lambda Powertools + DynamoDB persistence layer), Lambda cost model (pricing formula, break-even vs containers), and CloudWatch Insights observability queries for cold starts, duration, and errors.

security-review-advanced

8
from marvinrichter/clarc

Security anti-patterns — localStorage token storage (XSS risk), trusting client-side authorization checks, reflecting full error details to clients, blacklist vs whitelist input validation, using npm install instead of npm ci in CI pipelines.

rust-testing-advanced

8
from marvinrichter/clarc

Advanced Rust testing anti-patterns and corrections — cfg(test) placement, expect() over unwrap(), mockall expectation ordering, executor mixing (#[tokio::test] vs block_on), PgPool isolation with

rust-patterns-advanced

8
from marvinrichter/clarc

Advanced Rust patterns — zero-cost abstractions, proc macros, unsafe FFI, WASM, Axum web architecture, trait objects vs generics, and performance profiling.

python-testing-advanced

8
from marvinrichter/clarc

Advanced Python testing — async testing with pytest-asyncio, exception/side-effect testing, test organization, common patterns (API, database, class methods), pytest configuration, and CLI reference. Extends python-testing.

python-patterns-advanced

8
from marvinrichter/clarc

Advanced Python patterns — concurrency (threading, multiprocessing, async/await), hexagonal architecture with FastAPI, RFC 7807 error handling, memory optimization, pyproject.toml tooling, and anti-patterns. Extends python-patterns.

multi-agent-patterns-advanced

8
from marvinrichter/clarc

Advanced multi-agent patterns — capability registry, durable state (Redis/DynamoDB), task decomposition, testing multi-agent systems, pattern quick-selection guide, failure handling, cost management, and worktree isolation. Extends multi-agent-patterns.

microfrontend-patterns-advanced

8
from marvinrichter/clarc

Advanced Micro-Frontend patterns — testing strategy (unit per-remote, integration with mocked remotes, E2E full composition via Playwright), CI/CD independent deployments per remote, ErrorBoundary resilience, and monolith-to-MFE strangler-fig migration.

hexagonal-typescript-advanced

8
from marvinrichter/clarc

Advanced Hexagonal Architecture anti-patterns for TypeScript — domain importing framework dependencies, use cases depending on concrete adapters, HTTP handlers bypassing use cases, Zod validation inside the domain model. Each anti-pattern includes wrong/correct comparison with explanation.