Staso Docs
Python SDK

Python decorators

The supported launch path uses two decorators. Both work with regular and async def functions.

@st.agent

Put @st.agent on the entry point for one agent run. It creates the root span and gives nested provider and tool spans the same trace ID.

@st.agent
def research(query: str) -> str:
    return answer(query)


@st.agent(name="billing-agent", tags=["billing"])
async def bill(account_id: str) -> str:
    return await process(account_id)

@st.tool

Put @st.tool on the Python function that performs tool work. The decorator records the actual duration, status, arguments, return value, and propagated exception.

@st.tool
def search_docs(query: str) -> list[str]:
    return index.search(query)


@st.tool(name="publish_report")
async def publish_report(report_id: str) -> bool:
    return await reports.publish(report_id)

@st.tool observes execution. It does not run Guard by itself. Provider-proposed tools are evaluated in supported patched provider loops; direct calls need an explicit st.guard() check when they require enforcement.

Provider patches retain proposal IDs to link a later tool-result continuation. They do not infer execution duration, success, output, or errors from the gap between model calls.

Parameters

ParameterDefaultDescription
nameFunction nameSpan and tool label.
tagsNoneString tags stored in span metadata.
metadataNoneAdditional serializable span metadata.
capture_inputTrueRecord function arguments.
capture_outputTrueRecord the return value.

Both bare and configured forms work:

@st.agent
def run() -> None: ...


@st.tool(name="lookup", capture_output=False)
def lookup(account_id: str) -> dict: ...

Errors

When the wrapped function raises or an async task is cancelled, Staso marks the span as an error, records available exception details, and propagates the original exception or cancellation.

Capture controls

Set capture_input=False or capture_output=False to omit that decorator payload. This is capture suppression, not content redaction.

The local flag is combined with the global category policy:

Decorator payloadRequired global category
@st.agent or @st.trace argumentsrequest
@st.tool argumentstool_arguments
Any decorated return valueoutput
Caller-provided decorator metadatarequest

A local False always wins. When effective input capture is off, the wrapper does not materialize function arguments for telemetry. Error prose is omitted whenever the effective content policy is not fully enabled; the exception class and error status remain operational.

Next