Durable Agent Sessions

    0

    Design and audit AI agent sessions to survive crashes, retries, and restarts without state loss or side-effect duplication.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Durable Agent Sessions

    Example session with this skill installed

    Audit our session handling in server/agent_loop.py. We store messages in Postgres but users report double-tool execution when the websocket reconnects. Check for idempotency and recovery tails.

    • Read your context and instructions
    • Compiled the durable agent sessions

    I have audited the session logic in server/agent_loop.py against the durable session contract. The current implementation lacks a terminal interpretation for interrupted tool calls, leading to duplicate side-effects on reconnect.

    Durable Session Audit: server/agent_loop.py

    Work UnitStorage AuthorityCommit PointModel Context
    Sessionsessions tableOn initYes (Metadata)
    Turnmessages tablePost-LLM responseYes (History)
    Tool Calltool_resultsPost-executionYes (Evidence)

    Recovery Decision Table

    Tail StateInterpretationAction
    call_id without resultUncertain CommitCheck idempotency key in provider API before retry.
    Message without run_idDangling TurnReject history; session is structurally inconsistent.
    Pending tool at restartInterrupted EffectQuery downstream service for call_id status.

    Failure Test Matrix

    • Crash before tool commit: Verify that the system does not assume success on restart.
    • Network timeout during tool call: Ensure the same call_id is passed to the tool on retry.
    • Websocket reconnect during write: Test for duplicate row insertion in messages table.

    Risk Findings

    High Risk (Double-Effect): agent_loop.py:142 calls process_payment() without a stable idempotency key. A restart during this await block causes a second charge.
    2.

    Medium Risk (Evidence Destruction): The recovery entry point clears the pending_actions buffer on start, losing the only record of unobserved tool calls.

    Next steps

    • Implement a client_token or call_id as an idempotency key for all tool execution calls.
    • Change the session schema to include a status field (pending/committed) for tool results.
    • Add an integration test simulating a SIGKILL during the tool execution phase.

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

    About this skill

    Building AI agents that crash or lose state mid-task destroys user trust and wastes tokens. This skill provides a rigorous framework for designing and auditing agent sessions to ensure they survive restarts, cancellations, and network failures without repeating side-effects. It moves beyond simple logging to enforce hard durability contracts.

    What it does

    • Fact Cataloging maps every piece of session data to its commit point, model context inclusion, and owner.
    • Lifecycle Closure traces every unit of work through success, failure, and process interruption to ensure terminal states.
    • Idempotency Auditing verifies that side-effecting tools and API calls use stable identities to prevent double-execution during retries.
    • Recovery Logic defines specific decisions for incomplete session tails, prioritizing structural integrity over heuristic guessing.
    • Failure Matrixing generates test cases for crashes occurring before, during, and after data commit points.

    How it works

    1. Define Work Units by identifying the system's specific session, turn, and tool call boundaries.
    2. Trace Interruptions by analyzing how the system handles timeouts and process restarts at every await boundary.
    3. Audit Storage Contracts to check for atomicity, writer ownership, and safe repair of corrupted histories.
    4. Generate Verdicts including a fact catalogue, recovery decision tables, and a prioritized risk report.

    Frameworks & tools

    This workflow is framework-agnostic and applies to any agent system using persistent storage, including LangGraph, AutoGen, PydanticAI, or custom orchestration layers using SQL, NoSQL, or vector-based state stores.

    Why this beats prompting it yourself

    Generic prompts often mistake "saving chat history" for "session durability." This skill enforces low-level reliability patterns like writer ownership and atomic publication that LLMs typically overlook without a structured audit framework.

    Use cases

    • Audit an existing agent's recovery logic to prevent duplicate API billing.
    • Design a session schema for long-running agents that must survive server reboots.
    • Map idempotency keys for agents performing financial or infrastructure side-effects.
    • Create a failure test suite to verify agent behavior during network partitions.

    Known limitations

    Does not provide implementation code unless explicitly requested. Requires access to session schemas or code for a full audit; otherwise, it produces a design-level review.

    Requires session schemas or source code for full audits. Provides design reviews if implementation details are missing. Focuses on durability, not agent reasoning quality.

    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 any payment.

    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 17 days ago

    Permissions

    Read Files

    Reads the agent runtime's source code, schemas, persistence paths, architecture documentation, and tests to produce an evidence-backed durability review. It does not write files or execute commands unless the buyer separately requests implementation.

    Listed17 days ago

    What's inside

    Frequently Asked Questions

    While chat history saves what was said, this skill ensures the system remembers exactly what it *did*—preventing issues like an agent rerunning a credit card charge or sending duplicate emails after a crash.

    This skill is framework-agnostic and works with any system using persistent storage, including LangGraph, AutoGen, PydanticAI, or custom Python/Node.js orchestration layers.

    You receive a comprehensive audit package containing a Fact Catalog, a Recovery Decision Table for session failures, and a prioritized Risk Report identifying potential side-effect duplications.

    Yes, this skill is specifically designed to audit side-effecting tools by verifying idempotency keys and stable identities to ensure financial or infrastructure actions never execute twice.

    No, this is a design and audit framework; while it provides the logic and schemas required for durability, it does not include pre-written code for specific database integrations.

    This skill is ideal for any agent that performs multi-step tasks where a failure mid-stream would cause data inconsistency, duplicate API costs, or loss of user progress.

    New in Agents & Orchestration