This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.4.0 instead.
Reason given by maintainers: Superseded by 0.3.0. Please upgrade.
pisama-agent-sdk
ATIF trace adapters and real-time failure detection hooks for agent runtimes, including the Claude Agent SDK, OpenHands, and Harbor-compatible evaluation flows.
Part of the Pisama platform for single-agent, multi-agent, and sub-agent failure detection.
Requires Python 3.10 or newer. Python 3.10 through 3.13 are tested.
Install
pip install pisama-agent-sdk
Quick Start
Passive Monitoring (hooks)
Add two lines to your Claude Agent SDK setup:
from pisama_agent_sdk 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
Every tool call is now checked for failure patterns in real-time (<100ms). If a loop or other issue is detected, the hook returns a blocking signal to stop the agent.
Active Self-Check
Let the agent verify its own output:
from pisama_agent_sdk 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"]:
# result["issues"] describes what went wrong
print(result["issues"])
Custom Tool for Claude Agent SDK
Give the agent a tool it can call to self-check:
from pisama_agent_sdk import create_check_tool
from claude_agent_sdk import ClaudeAgentOptions
options = ClaudeAgentOptions(
custom_tools=[create_check_tool()],
)
Configuration
from pisama_agent_sdk import configure_bridge, BridgeConfig
configure_bridge(BridgeConfig(
fail_open=True, # Allow execution if detection errors (default: True)
detection_timeout_ms=80, # Max detection time per hook (default: 80)
))
Tool Matchers
Control which tools get checked:
from pisama_agent_sdk import PreToolUseHook, HookMatcher
# Only check file and shell tools
matcher = HookMatcher(
tool_name_pattern=r"^(Read|Write|Edit|Glob|Grep|Bash|bash|shell)$"
)
hook = PreToolUseHook(matcher=matcher)
agent.hooks.pre_tool_use = hook
Built-in matchers: ALL_TOOLS, FILE_TOOLS, SHELL_TOOLS, DANGEROUS_COMMANDS, AGENT_TOOLS.
How It Works
- Your agent makes a tool call
pre_tool_use_hookconverts the call into a PisamaSpan- Registered detectors run against the span + recent session context
- If a failure is detected (e.g., 5th consecutive
Readof the same file), the hook returns a blocking result - The agent receives the block signal and adjusts its behavior
Detection runs entirely locally using pisama-core detectors. No network calls unless you configure a remote endpoint.
Evaluator Mode
Use Pisama as an evaluator in multi-agent harnesses:
from pisama_agent_sdk import PisamaEvaluator
evaluator = PisamaEvaluator(endpoint="https://your-pisama-instance/api/v1")
result = await evaluator.evaluate(trace_data)
print(result.passed, result.failures)
Requires pip install pisama-agent-sdk[evaluator].
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pisama_agent_sdk-0.2.1.tar.gz.
File metadata
- Download URL: pisama_agent_sdk-0.2.1.tar.gz
- Upload date:
- Size: 81.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e4d7191873724cf83a5157b46c5c10bc7e2fc0fe6b52f6b9036b6ec02906b7f
|
|
| MD5 |
b080d03bb8bd5cd8ec4634e6d7505aeb
|
|
| BLAKE2b-256 |
91ab25d5672457e92e3ab596237e2e3433cdd5c03e247886cb6aaaca074d58a3
|
Provenance
The following attestation bundles were made for pisama_agent_sdk-0.2.1.tar.gz:
Publisher:
publish.yml on Pisama-AI/pisama-agent-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pisama_agent_sdk-0.2.1.tar.gz -
Subject digest:
7e4d7191873724cf83a5157b46c5c10bc7e2fc0fe6b52f6b9036b6ec02906b7f - Sigstore transparency entry: 2266915317
- Sigstore integration time:
-
Permalink:
Pisama-AI/pisama-agent-sdk@a65054b9193501422b5b98fed7c3e3ede2e7cc33 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Pisama-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a65054b9193501422b5b98fed7c3e3ede2e7cc33 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pisama_agent_sdk-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pisama_agent_sdk-0.2.1-py3-none-any.whl
- Upload date:
- Size: 69.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9fdf41cd6d23f985fbfe15d5258aa5a1d0e0be95ed7965755fb6cb96cba823
|
|
| MD5 |
d0b2ad1cccf3fb89c8277a181530257a
|
|
| BLAKE2b-256 |
6543f6a25494b04fff4438351be7652999a407415e12607502705e37d2ea42bd
|
Provenance
The following attestation bundles were made for pisama_agent_sdk-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on Pisama-AI/pisama-agent-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pisama_agent_sdk-0.2.1-py3-none-any.whl -
Subject digest:
6d9fdf41cd6d23f985fbfe15d5258aa5a1d0e0be95ed7965755fb6cb96cba823 - Sigstore transparency entry: 2266915805
- Sigstore integration time:
-
Permalink:
Pisama-AI/pisama-agent-sdk@a65054b9193501422b5b98fed7c3e3ede2e7cc33 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Pisama-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a65054b9193501422b5b98fed7c3e3ede2e7cc33 -
Trigger Event:
push
-
Statement type: