Staso Docs
Reference

Span kinds, statuses, and well-known metadata keys — the shape of every Staso trace record.

Span kinds

staso.SpanKind — matches the backend SpanKindEnum.

ValueTypical use
llmA single LLM call (chat completion, streaming, tool use). Populated by patch_openai / patch_anthropic.
toolA tool function invoked by an agent. Set by @st.tool.
chainA generic sequence of steps. Default for st.span and @st.trace.
retrieverA vector search, SQL query, or document lookup.
agentAn agent entry-point. Set by @st.agent. Usually the root span of a trace.
customAnything that doesn't fit the above.

Span statuses

staso.SpanStatus — matches the backend StatusEnum.

ValueWhen
okDefault. The operation succeeded.
errorSet automatically by span.record_exception or any decorator that catches an exception.
timeoutExplicit timeout — set manually via span.set_status(SpanStatus.TIMEOUT).

Span shape

Top-level span fields written to storage:

FieldTypeDescription
namestrSpan label.
kindSpanKindSee above.
statusSpanStatusSee above.
trace_iduuidShared across every span in one trace.
span_iduuidUnique per span.
parent_span_iduuid | nullParent span in the trace tree. null for root.
modelstrLLM model name. Populated on kind=llm spans.
input_tokensintPrompt tokens.
output_tokensintCompletion tokens.
total_tokensintSum — not re-derived on the backend.
inputdictFree-form request payload. Serialized to JSON on flush.
outputdictFree-form response payload.
metadatadictWell-known keys listed below, plus any custom keys you add.
conversation_idstrSet by st.conversation or read from context.
agent_namestrSet by @st.agent or st.init(agent_name=...).
agent_idstrDeterministic UUID5 of agent_name.
user_idstrSet by st.conversation(user_id=...).
error_messagestr | nullSet by record_exception.

Well-known metadata keys

Every key below lives in span.metadata. The SDK reads some from LLM providers automatically (via patch_openai / patch_anthropic); the rest you set yourself. Use these exact strings so the backend can index and chart them.

LLM request parameters

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 metadata

KeyType
stop_reasonstr
stop_sequencestr
response_idstr
providerstropenai, anthropic, etc.

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 st.init(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