Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Agent Resilience: crash-safe, idempotent AI agents

    1

    Audits your AI agent for 8 production failure modes, then adds checkpoints, safe retries, an outbox, human approval, token budgets and cancel, and proves each fix with failure tests.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Agent Resilience: crash-safe, idempotent AI agents

    Agent Resilience: crash-safe, idempotent AI agents

    Example session with this skill installed

    Audit the agent in this repo for production reliability. It's a Celery task that reads support tickets and can refund via Stripe and email the customer. Don't change code yet.

    • Read your context and instructions
    • Compiled the agent resilience

    Agent reliability audit: naive-agent

    Scope: agent.py, which is the whole project at 35 lines.

    Stack: Python, Celery on Redis, the Anthropic SDK, Stripe and SMTP. There is no database.

    Verdict

    Score: 0/16. It is not ready for production. Under the audit rubric, a repeated side effect that costs money is a blocker on its own (F3 = 0). There are also two problems outside the rubric that matter more. Anyone who writes a ticket can choose which charge gets refunded and for how much. And the agent probably can't complete a refund conversation at all, because the request it builds is likely to be rejected by the API.

    I only read the code. I didn't run it.

    Problems outside the rubric (fix these first)

    #ProblemEvidence
    AA ticket can trigger refunds and emails it shouldn't. The ticket text goes straight to the model as the only prompt. The model then picks charge_id, amount and to, and those go to Stripe and SMTP without any check. Nothing checks that the charge belongs to the person who wrote the ticket, nothing caps the amount, and nothing requires a human to approve.agent.py:25, :13-14, :17-19, :32
    BTool definitions are probably invalid. "input_schema": {} has no "type": "object", no properties and no descriptions.agent.py:10
    CResponses with more than one tool call break the conversation. If the model asks for refund and email_customer in one response, the next API call fails, so the refund has gone through, but the customer never gets an email and the task errors out.agent.py:31-34
    DOrdinary errors crash the task. An unknown tool name raises KeyError, Stripe errors are never caught, and stop_reason values such as max_tokens aren't handled.agent.py:30, :32

    Scores

    #Failure modeScoreEvidence
    F1Progress is lost on crash0The conversation is a local list (agent.py:25, :33-34) and is never saved.
    F2The model re-decides a step after a crash0The decision isn't saved before the tool runs. After a redelivery the model starts again and may choose differently.
    F3Side effects repeat on retry or resume0 (blocker)stripe.Refund.create (:14) has no idempotency_key, and sendmail (:19) has no outbox. With acks_late=True (:23), a worker that dies after the refund gets the task redelivered: a second refund and a second email.
    F4Two workers run the same run0No claim or lock. If a task runs past Redis's 1-hour visibility_timeout, a second worker gets the same ticket and both refund.
    F5A worker writes after losing ownership0Ownership is never tracked. A stalled worker that wakes up still refunds and sends email.
    F6Runs get stuck or lost0No run record outside the queue message. Without task_reject_on_worker_lost, an OOM-killed task disappears without a trace.
    F7Failures unbounded or mis-handled0No timeouts (smtplib.SMTP at :18 can block forever), no retries or backoff. The run "finishes" as soon as the model replies with text.
    F8Runaway runs and missing controls0while True (:26) has no step limit, token budget or loop detection. No approval before a refund, no cancel.

    Side effects inventory

    Tool / callLocationWhat it does outside the processProtected by
    refund → stripe.Refund.createagent.py:14Moves money to the customerNothing
    email_customer → smtplib.sendmailagent.py:18-19Sends email to any address the model choosesNothing

    Fixes, in order

    Authorize refunds outside the model (A, F8). Accept a charge_id only if it belongs to the ticket's customer, cap the amount, and require human approval above a limit, releasing the worker while it waits. Email only the customer on file.
    2.

    Make refunds and emails safe to repeat (F3). Pass idempotency_key=f"{run_id}:{step_no}" to Refund.create. Write emails to an outbox table in the same transaction that marks the step complete.
    3.

    Fix the agent loop (B, C, D). Proper JSON schemas, one assistant message per response with all tool results in one user message, tool errors returned as is_error, handle stop_reason.
    4.

    Keep run state in a database (F1, F2, F4, F5, F6). runs and steps tables with a unique key per ticket, atomic UPDATE … RETURNING claim plus heartbeat, every write inside an ownership check, a reaper, and task_reject_on_worker_lost=True.
    5.

    Bound failures (F7). Timeouts on every tool and LLM call, limited retries for transient errors only, and a finish tool as the only way a run completes.
    6. Add guards (F8). Step limit, per-run token budget, repeated-call detection and cancel.

    Decisions for you

    • Fixes 2, 4 and 5 need a database. Postgres or SQLite?
    • Your refund policy: up to what amount can the agent refund on its own, and who approves above that?
    • Do tickets have a stable ID I can use as the idempotency key?

    I haven't changed any code. Answer the questions above and I'll make the fixes, including failure tests against a real database.

    (Follow-up in the same project: after answering "SQLite, 50 USD, ticket_id", the skill retrofitted the agent and wrote 47 failure tests, including a real worker kill right after a refund that ends with exactly one refund.)

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Your agent works in the demo. Then a worker restarts mid-run and the customer gets refunded twice. Or a queue redelivers a job, two workers both send the email, and nobody can stop a run that's burning tokens.

    This skill teaches your coding agent (Claude Code, Cursor, Codex, Copilot and others) to find and fix those failures in your own agent code:

    • Audit: scores your agent loop on 8 failure modes (lost progress, re-decided steps, repeated side effects, double execution, zombie writers, stuck runs, unbounded failures, runaway runs), with file:line evidence and fixes in priority order. It includes an offline scanner that locates LLM calls, side effects and existing safeguards.
    • Retrofit: adds the patterns in the right order. That means a durable checkpoint before every tool call, an atomic lease with heartbeat and fencing, side-effect-free tools with an idempotent outbox, bounded retries and timeouts, a reaper, an explicit finish tool, and human approval that doesn't block a worker.
    • Guards: per-run token budgets, no-progress loop detection, and a cancel that stops a worker mid-step before anything commits.
    • Proof: chaos test recipes (simulated crash, 8 workers racing, stale worker waking up, hung tool, concurrent approve/cancel) that your agent writes against a real database.

    Complete reference implementations for Python + Postgres, Node/TypeScript + Postgres and Python + SQLite (no Postgres needed). Each passes its own chaos test suite. It also covers how this maps onto Temporal, LangGraph and Celery: what they already guarantee, and what they don't.

    Built from resilient-agent-runner, an open backend where every guarantee is tested, including a real SIGKILL demo.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.

    Not for single-shot LLM calls or stateless chat with no tools. The retrofit needs a database you control (Postgres or SQLite); reference code is Python and Node/TypeScript, so other languages get the patterns but not ready-made code. The token budget counts planning calls only. Provider idempotency keys (for example Stripe's) expire after a while, so very late retries still rely on your own outbox.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 18 days ago

    Software
    Python 3.8+ (for the offline scanner)
    PostgreSQL
    orSQLite (in your own project)
    Git

    Permissions

    Terminal / Shell
    Read Files
    Write Files

    The skill reads your agent's source files to audit it, edits them when you ask for a retrofit, and runs your test suite in the terminal. Its one script (scripts/scan_agent.py) uses the Python standard library only: it reads files and prints JSON, with no network access, no environment or credential reads, and it never writes or executes anything.

    Listed18 days ago

    What's inside

    Frequently Asked Questions

    A SKILL.md with four modes (audit, retrofit, guards, chaos tests), an 8-point audit checklist with a report template, 12 resilience patterns, chaos test recipes, database schemas for Postgres and SQLite, an offline scanner script, and complete tested reference implementations for Python + Postgres, Node/TypeScript + Postgres and Python + SQLite.

    Any agent loop you own in Python or Node/TypeScript, built on raw SDKs (Anthropic, OpenAI) or a queue like Celery, with Postgres or SQLite. For Temporal and LangGraph it explains what they already guarantee and which gaps (such as side effects outside the workflow) you still need to cover.

    Unlike simple prompt engineering, this skill addresses infrastructure-level failures—such as a worker crashing mid-execution—ensuring that side effects like payments aren't duplicated and progress isn't lost.

    No. The skill retrofits your existing loop step by step: first making side effects safe to repeat, then adding durable state, leases and guards. It asks before choices that depend on you (database, approval limits, idempotency keys) and keeps your tools and prompts.

    Yes. The chaos-test mode has your agent write tests against a real database for the failures that matter: a crash right after a side effect, 8 workers racing for one run, a stale worker waking up after losing its lease, a hung tool, and approve/cancel racing each other. The reference implementations pass these same tests.

    This skill is specifically built for multi-step agentic workflows that modify external state; it is not intended for simple, single-shot LLM calls or stateless chatbots.

    New in Agents & Orchestration