Skip to main content

Post-mortem debugger for AI agents

Project description

AgentAutopsy

PyPI version Downloads GitHub stars License: MIT Python 3.8+

The post-mortem debugger for AI agents. When your agent fails silently — AgentAutopsy tells you exactly why.

Lifecycle

Install  →  Watch  →  Fail  →  Trace  →  Replay  →  Fix
   │          │        │         │          │        │
 pip      watch()   silent   SQLite     rewind    auto-fix
install              failure   log      + fork    + cache
Stage What happens
Install pip install agentautopsy — no cloud account, no config file
Watch agentautopsy.watch() intercepts LLM, HTTP, MCP, and tool calls
Fail Agent errors or returns bad output; run is marked in local SQLite
Trace Full event timeline: prompts, tools, schemas, tokens, timestamps
Replay Rewind to any step, fork with new input, diff original vs replay
Fix Root-cause report, AI chat on trace, verified fix cached for next run

Commands

What you're doing Command Key principle
Zero config setup agentautopsy.watch() One import catches everything
View trace UI agentautopsy ui Visual timeline of every step
Replay a failure agentautopsy replay --run-id <id> --from-step <n> Rewind to exact failure point
Detect schema drift SchemaDriftDetector().watch() Catch API changes before production
Trace MCP servers MCPAutopsy().watch_mcp_server() Every MCP call recorded
Fork and fix DVRReplay().fork(run_id, at_step=3) Branch from any step
Generate tests from failures agentautopsy generate-evals Never fix the same bug twice

Quick Start

pip install agentautopsy
import agentautopsy

agentautopsy.watch()
# your existing agent code — nothing else changes

Features

Feature What It Does Use When
MCP Post-Mortem Tracing Traces every MCP server call, shows bad data source Using Claude Code, Cursor, any MCP client
Schema Drift Detector Detects renamed/removed/added fields automatically After any API or tool upgrade
DVR Fork and Replay Rewind, replay, fork from any step Debugging production failures
Swarm Tracing Causality tracing across 50+ agents Multi-agent workflows
AI Chat on Trace Ask questions about your failure When root cause is unclear
Prompt Diffing Compare runs side by side Optimizing agent behavior
Contract Checkpointing Enforces Pydantic schemas and checkpoints valid states Preventing late-stage failures caused by early bad data
Automatic Eval Generation Generates pytest test cases from every failure automatically When you want to make sure the same failure never happens again

Framework Support

Works with: LangChain, LangGraph, CrewAI, AutoGen, LlamaIndex, OpenAI, Anthropic, MCP

Module Quick Start

Basic

import agentautopsy

agentautopsy.watch()

MCP

from agentautopsy import MCPAutopsy

MCPAutopsy().watch_mcp_server("my-mcp-server")

Schema Drift

from agentautopsy import SchemaDriftDetector

SchemaDriftDetector().watch()

DVR Replay

from agentautopsy import DVRReplay

dvr = DVRReplay()
dvr.replay(run_id, from_step=3)
dvr.fork(run_id, at_step=3, new_input={"query": "fixed prompt"})

Auto Eval Generation

from agentautopsy import EvalGenerator

gen = EvalGenerator()
gen.generate_all()  # generates tests from all recorded failures

Contract Checkpointing

from agentautopsy import ContractCheckpointer
from pydantic import BaseModel

class OutputSchema(BaseModel):
    __rules_version__ = "1.0"  # Optional: bump to force cache invalidation on external dependency drift
    summary: str

checkpointer = ContractCheckpointer(run_id)
# Fails immediately if invalid, otherwise saves state to SQLite for resuming.
# Automatically normalizes and hashes the AST (Abstract Syntax Tree) of the validator, global constants, and helper functions to detect logic drift without false positives!
validated = checkpointer.enforce("step_1", raw_output, OutputSchema)

Contributing

Fork the repo, open a PR with tests. See CONTRIBUTING.md for setup and CI commands.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentautopsy-2.3.0.tar.gz (99.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentautopsy-2.3.0-py3-none-any.whl (98.2 kB view details)

Uploaded Python 3

File details

Details for the file agentautopsy-2.3.0.tar.gz.

File metadata

  • Download URL: agentautopsy-2.3.0.tar.gz
  • Upload date:
  • Size: 99.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for agentautopsy-2.3.0.tar.gz
Algorithm Hash digest
SHA256 b599780cd574398d1bb46f1a46de236369cc19db0b07eaf43a7d0fd12fc9928c
MD5 1092bfad4977baad3e6b29cef93c52f0
BLAKE2b-256 54d58852098adafb9d2edddddf6075882ecfd3c52193b7b1a44619896513635a

See more details on using hashes here.

File details

Details for the file agentautopsy-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: agentautopsy-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 98.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for agentautopsy-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0480b9517c4525d8318695d0ca2314fb631bf413be8f71cc1edca84f3e116269
MD5 88f65e5d20635a6c1ab3b2453d977d08
BLAKE2b-256 bced7dd5500907b5955b59efe965cec38bba2694564c7af88b2c6d66a3c52d8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page