Staso Docs
Reference

Data model

Span kinds

staso.SpanKind:

ValueUse
llmLLM call. Set by patch_openai / patch_anthropic.
toolTool function. Set by @st.tool.
chainGeneric. Default for st.span and @st.trace.
retrieverVector search, SQL, document lookup.
agentAgent entry-point. Set by @st.agent. Usually the root span.
customAnything else.

Statuses

staso.SpanStatus:

ValueWhen
okDefault. Operation succeeded.
errorSet by record_exception or any decorator that catches an exception.
timeoutManual via span.set_status(SpanStatus.TIMEOUT).

Span shape

FieldTypeDescription
namestrSpan label.
kindSpanKindSee above.
statusSpanStatusSee above.
trace_iduuidShared across every span in one trace.
span_iduuidUnique per span.
parent_span_iduuid | nullnull for root.
modelstrLLM model name. Populated on kind=llm.
input_tokensint
output_tokensint
total_tokensint
inputdictFree-form request payload.
outputdictFree-form response payload.
metadatadictWell-known keys (below) plus your own.
conversation_idstrSet by st.conversation or context.
agent_namestrSet by @st.agent or st.init.
agent_idstrDeterministic UUID5 of agent_name.
user_idstrSet by st.conversation(user_id=...).
error_messagestr | nullSet by record_exception.

Well-known metadata keys

Use these exact strings so the backend can index and chart them.

LLM request

KeyType
temperaturefloat
max_tokensint
top_pfloat
top_kint
stop_sequenceslist[str]
tool_choicestr | dict
thinkingdict
service_tierstr
response_formatstr | dict
frequency_penaltyfloat
presence_penaltyfloat
seedint

LLM response

KeyType
stop_reasonstr
stop_sequencestr
response_idstr
providerstr

Tokens

KeyType
cache_read_input_tokensint
cache_creation_input_tokensint
reasoning_tokensint
audio_input_tokensint
audio_output_tokensint

Performance

KeyType
time_to_first_tokenfloat seconds

Code location (set by decorators)

KeyType
code.filepathstr
code.linenoint
code.functionstr

VCS (set by capture_git=True)

KeyType
vcs.commit.shastr
vcs.branchstr
vcs.repo_urlstr
vcs.is_dirtybool

Guard

KeyType
guard_actionstrallow | block | modify | escalate
guard_reasonstr
guard_latency_msfloat