Skip to main content

Multi-agent failure detection for production AI systems

Project description

Pisama

Find and fix failures in AI agent systems. No LLM calls required.

PyPI License: MIT Python 3.10+

Pisama ships heuristic detectors that apply across frameworks including n8n, LangGraph, Dify and OpenClaw, with per-platform gating (for example coordination runs only on multi-agent platforms). They run locally with zero LLM cost on the heuristic tier.

Install

pip install pisama

Usage

from pisama import analyze

result = analyze("trace.json")  # also accepts dicts and JSON strings

for issue in result.issues:
    print(f"[{issue.type}] {issue.summary} (severity: {issue.severity})")
    print(f"  Fix: {issue.recommendation}")

CLI

pisama analyze trace.json          # Analyze a trace
pisama watch python my_agent.py    # Watch a live agent (pip install "pisama[auto]")
pisama replay <trace-id>           # Re-run detection on stored traces
pisama smoke-test --last 50        # Batch test recent traces
pisama detectors                   # List all core detectors
pisama mcp-server                  # Start MCP server (pip install pisama[mcp])

MCP Server

Works in Cursor, Claude Desktop, and Windsurf. No API key is needed:

{
  "mcpServers": {
    "pisama": { "command": "pisama", "args": ["mcp-server"] }
  }
}

Optional extras

The base pisama install has zero-cost heuristic detection covered. Two extras add opt-in functionality on top.

Auto-instrumentation: pisama[auto]

Zero-code tracing for LLM calls. init() patches supported clients (Anthropic, OpenAI) so every call after it emits an OTEL trace Pisama can analyze, no manual instrumentation needed.

pip install "pisama[auto]"
import pisama.auto

pisama.auto.init(api_key="ps_...")

# All subsequent LLM calls are automatically traced
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(...)  # traced automatically

This used to require the standalone pisama-auto package. That package still works and stays fully supported for existing installs; pisama[auto] is the same code, folded into the base package so there is one less dependency to track. New projects should install it this way.

Agent hooks and tools: pisama[agents]

Real-time hooks, tools, and self-check utilities for agent runtimes (built for the Claude Agent SDK), wired to Pisama's detection infrastructure for in-loop failure prevention rather than after-the-fact analysis.

pip install "pisama[agents]"
from pisama.agents import pre_tool_use_hook, post_tool_use_hook

agent.hooks.pre_tool_use = pre_tool_use_hook
agent.hooks.post_tool_use = post_tool_use_hook

Active self-check is available the same way:

from pisama.agents import check

result = await check(
    output="The server is healthy based on the metrics.",
    context={"query": "Is auth-service down?", "sources": [...]},
)
if not result["passed"]:
    ...  # revise output based on result["issues"]

This used to require the standalone pisama-agent-sdk package. That package still works and stays fully supported for existing installs; pisama[agents] is the recommended path for new projects, one package instead of two.

Detectors

Core detectors, gated per platform (n8n, LangGraph, Dify, OpenClaw and others). A representative selection:

Detector What It Catches
loop Infinite loops, retry storms, stuck patterns
coordination Deadlocked handoffs, message storms
hallucination Factual errors, fabricated tool results
injection Prompt injection, jailbreak attempts
corruption State corruption, type drift
persona_drift Persona drift, role confusion
derailment Task deviation, goal drift
context Context neglect, ignored instructions
specification Output vs. requirement mismatch
communication Inter-agent message breakdown
decomposition Poor task breakdown, circular dependencies
workflow Unreachable nodes, missing error handling
completion Premature completion, unfinished work
withholding Suppressed findings, hidden errors
convergence Metric plateau, regression, thrashing
overflow Context window exhaustion
propagation Silent error propagation across steps
citation Fabricated citations and source misattribution
routing Inputs misrouted to the wrong specialist agent
mcp_protocol MCP tool-communication failures

Links

License

MIT

Source boundary

This repository is the public source for the MIT-licensed pisama Python package. It does not contain the Pisama Cloud backend, dashboard, calibration data, managed detection tiers, or paid automation.

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

pisama-0.6.1.tar.gz (158.2 kB view details)

Uploaded Source

Built Distribution

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

pisama-0.6.1-py3-none-any.whl (138.6 kB view details)

Uploaded Python 3

File details

Details for the file pisama-0.6.1.tar.gz.

File metadata

  • Download URL: pisama-0.6.1.tar.gz
  • Upload date:
  • Size: 158.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pisama-0.6.1.tar.gz
Algorithm Hash digest
SHA256 4ac53a29ec00b22874a8411ddb829b7eb4fc5acf28f6ea0fb5d63044d19e55ed
MD5 d040cc66cb1246341dcbf3eb9372e815
BLAKE2b-256 d803bc6ad1d1732faf2c686a96b3c4301ecc85ad33ac96fd55a41db5b7bb0006

See more details on using hashes here.

Provenance

The following attestation bundles were made for pisama-0.6.1.tar.gz:

Publisher: publish.yml on Pisama-AI/pisama-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pisama-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: pisama-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 138.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pisama-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d25e625c3ff8adef2c89046f07bccce0f3ffd03688dba86a72d62094a13b7e65
MD5 94eb5dfb7f70b9e6be25699e2c33c052
BLAKE2b-256 d57855f033c4356c9c20bb77fc648f6a46e37b70788877538b491e888f46f3d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pisama-0.6.1-py3-none-any.whl:

Publisher: publish.yml on Pisama-AI/pisama-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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