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.

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.

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.5.tar.gz (486.5 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.5-py3-none-any.whl (133.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: staso-0.5.5.tar.gz
  • Upload date:
  • Size: 486.5 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.5.tar.gz
Algorithm Hash digest
SHA256 be9a360374802013399d188325fbbf5e443cb120c9e1be905b3d925016b9aac1
MD5 92cf0fee6b43756576ffd6a85ceb5c04
BLAKE2b-256 11ca41503136991ef75484fed3f7fff2560a739f3a6f905f2cdc34bc81ab8444

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: staso-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 133.9 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6bca29f80fa0fcaee921b200eabcd96e9cd6fcf8f113f7997208f189c999503a
MD5 5847f180091e023ce09895682a897664
BLAKE2b-256 aac200c57342b02568a946b9817e60c5b4e37c8facc115c76ff028072852ad05

See more details on using hashes here.

Provenance

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

0.5.7

2 files

0.5.6

2 files

This release

0.5.5 This release

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