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 stores named environment profiles in ~/.staso/profiles.json. Both are restricted to the current user. Agent hook files contain only stable Staso entrypoints. 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 profile set local --api-key ak_... --base-url http://localhost:6999 --workspace qa --environment local
staso profile use local                                 # activate for CLI-agent testing
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

The active profile applies globally to installed Codex and Claude Code hooks, including Codex Desktop. Use STASO_PROFILE=<name> for a one-process CLI override without changing the saved active profile. After staso profile use, staso sync intentionally replaces legacy per-hook routing with stable entrypoints; the selected active profile is the routing authority for every installed hook.

Without an active profile, sync converts legacy hooks only when their effective configuration can be unified safely. Otherwise it keeps every legacy route, reports the conflict, and exits nonzero if required hook events cannot be repaired without guessing a route.

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.10.tar.gz (500.7 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.10-py3-none-any.whl (144.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: staso-0.5.10.tar.gz
  • Upload date:
  • Size: 500.7 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.10.tar.gz
Algorithm Hash digest
SHA256 76c2027d7245b31fef791dd18d0b1d2c8efd010fa694235eb24d7bb98fb6b72f
MD5 8b92009d8be1589db3deb6b0c47dd01f
BLAKE2b-256 5a5363ea23f6e49ee1df94b80d51445a2f2ee31ac94f1c42e0c9c5606c700ea9

See more details on using hashes here.

Provenance

The following attestation bundles were made for staso-0.5.10.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.10-py3-none-any.whl.

File metadata

  • Download URL: staso-0.5.10-py3-none-any.whl
  • Upload date:
  • Size: 144.0 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.10-py3-none-any.whl
Algorithm Hash digest
SHA256 e3c8f39b846b88c689c230714ab3cbdbb37284f61bfc8a5fdf13cbe626586453
MD5 827b0e84a0499ac4ebf238b747b46701
BLAKE2b-256 9ae3939aa276447fc1233bfdc45e49c4f3089eaca6acd8707b8bb00eab996bc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for staso-0.5.10-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

This release

0.5.10 This release

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

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