Skip to main content

Staso Python SDK

Observe, guard, and control your AI agents. Every tool call, LLM interaction, token count, latency, and error -- on your Staso dashboard. Guard agent actions before they execute -- block dangerous operations, modify risky inputs, escalate to humans.

pip install staso
import staso as st
from staso import guard

st.init(api_key="ak_...", agent_name="my-agent")

@st.agent(name="support-agent")
def handle_request(message: str) -> str:
    context = search_kb(message)
    return call_llm(context, message)

@st.tool(name="search_kb")
def search_kb(query: str) -> str:
    return db.search(query)

@st.tool(name="process_refund")
def process_refund(customer_id: str, amount: float) -> str:
    result = guard(tool_name="process_refund", tool_input={"amount": amount})
    if result.action == "block":
        return f"Blocked: {result.reason}"
    return do_refund(customer_id, amount)

with st.conversation("conversation-123"):
    handle_request("How do I reset my password?")

st.shutdown()

Open your dashboard. Full execution tree -- agents, tools, LLM calls, tokens, timing, errors. Guard evaluations on every tool call.

Auto-Instrument LLM Calls

pip install "staso[anthropic]"  # or "staso[openai]" or "staso[all]"

st.init() detects installed provider SDKs (OpenAI, Anthropic, LiteLLM) and patches them automatically -- every LLM call is traced with tokens, model, latency, and errors. The whole integration:

import staso as st
st.init(agent_name="my-agent")

Prefer explicit control? Set STASO_AUTO_PATCH=false and patch yourself:

st.integrations.patch_anthropic()
st.integrations.patch_openai()

Both sync and async clients. Streaming fully supported.

Guard Agent Actions

Evaluate tool calls before they execute. Four actions: allow, block, modify, escalate.

from staso import guard

result = guard(tool_name="delete_records", tool_input={"table": "users"})
if result.action == "block":
    raise PermissionError(result.reason)

Guards run automatically in Claude Code and Codex sessions -- blocking dangerous tools and modifying risky inputs in real-time. In patched LLM SDK integrations (Anthropic, OpenAI), a tool call that trips an enforce rule raises staso.GuardBlocked -- catch it in your agent loop:

try:
    response = client.chat.completions.create(model="gpt-4o", messages=messages, tools=tools)
except st.GuardBlocked as blocked:
    handle_blocked_tool(blocked.tool_name, blocked.reason)

Score Agent Runs

Evaluate completed traces against built-in or custom rules -- task completion, output quality, drift across prompt versions.

run = st.evals.run(
    scope={"session_id": "run-2026-05-10-001"},
    zero_configs=["task_completion_rate", "hallucination", "output_artifact_quality"],
    name="run-001 eval",
)
summary = st.evals.summary(run.id)
print(summary.passed, "/", summary.total)

A/B compare two runs to gate prompt or model rollouts -- st.evals.compare(v1.id, v2.id) returns per-rule deltas plus the traces that flipped.

CLI Agent Integrations

Trace Claude Code (39 tool types) and Codex (32 tool types) sessions automatically. Every tool call renders as a human-readable card on your dashboard -- diffs, terminal output, agent trees, plan steps. Not raw JSON. Guards evaluate each tool before execution.

Run the interactive wizard:

staso setup

Or pass flags directly:

staso setup --target claude-code --api-key ak_... --workspace my-workspace
staso setup --target codex --api-key ak_... --workspace my-workspace
# Add --scope project to configure only the current project; the default is global.

Setup stores the API key in ~/.staso/credentials.json, outside agent settings and restricted to the current user. Agent hook files contain only a non-secret credential reference. In CI and containers, an injected STASO_API_KEY environment variable takes precedence. The credential file is plaintext and must not be shared; its directory and file are restricted to the current user with modes 0700 and 0600 respectively.

CLI Commands

staso setup                                              # interactive setup wizard
staso setup     --target claude-code --api-key ak_...    # scripted setup
staso status                                             # show what's configured
staso sync                                               # sync hooks after upgrade
staso update                                             # upgrade package + sync
staso uninstall --target codex                           # remove hooks, clean up
staso version                                            # show version info

For Codex, setup enables the current [features].hooks = true setting and writes hooks at either ~/.codex/hooks.json (global) or ./.codex/hooks.json (project). Codex still requires the user to review and trust each non-managed command hook in its Hooks settings; Staso never bypasses that security boundary. Use staso status --target codex to distinguish configured hooks from hooks that still need Codex trust review. An explicit --target is honored by the wizard. Because migrating or changing a Codex command changes its exact trusted hook definition, review the hooks again after the first credential migration.

Docs

Python 3.11+ · Apache 2.0

Download files

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

Source Distribution

staso-0.5.7.tar.gz (491.8 kB view details)

Uploaded Source

Built Distribution

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

staso-0.5.7-py3-none-any.whl (137.8 kB view details)

Uploaded Python 3

File details

Details for the file staso-0.5.7.tar.gz.

File metadata

  • Download URL: staso-0.5.7.tar.gz
  • Upload date:
  • Size: 491.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for staso-0.5.7.tar.gz
Algorithm Hash digest
SHA256 a2e054854c7d400b7da7cabe80b5f8ef4cf6da661cc8d2da294bac3ca9092d83
MD5 c30aaaa17ebbb754119fdc45fdfeba74
BLAKE2b-256 6bda8ea7425f121a295dcc0d21d2b709c512d5d21e32cf46484b7441424a41f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for staso-0.5.7.tar.gz:

Publisher: build_deploy_pip_registry.yml on StasoAI/sdk-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 staso-0.5.7-py3-none-any.whl.

File metadata

  • Download URL: staso-0.5.7-py3-none-any.whl
  • Upload date:
  • Size: 137.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for staso-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d1bcb253ce60401e161895c84b68b01cc9724b87a59d019b82892f38be75bc46
MD5 cbd5c4f2a3c4dfe577a4e9eff27d1932
BLAKE2b-256 6d19a474b71f3cc7644b3fc1a53251fce8178b3f2705f62d089a3fe0b713787d

See more details on using hashes here.

Provenance

The following attestation bundles were made for staso-0.5.7-py3-none-any.whl:

Publisher: build_deploy_pip_registry.yml on StasoAI/sdk-python

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

Release history Release notifications | RSS feed

0.5.20

2 files

0.5.19

2 files

0.5.18

2 files

0.5.17

2 files

0.5.16

2 files

0.5.15

2 files

0.5.14

2 files

0.5.13

2 files

0.5.12

2 files

0.5.11

2 files

0.5.10

2 files

0.5.9

2 files

0.5.8

2 files

This release

0.5.7 This release

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.2.0

2 files

0.1.41

2 files

0.1.40

2 files

0.1.38

2 files

0.1.37

2 files

0.1.36

2 files

0.1.35

2 files

0.1.34

2 files

0.1.33

2 files

0.1.32

2 files

0.1.31

2 files

0.1.30

2 files

0.1.28

2 files

0.1.27

2 files

0.1.25

2 files

0.1.24

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.10

2 files

0.1.9

2 files

0.1.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page