Staso Docs
Python SDK

Conversations

Every trace inside the with block shares the same conversation_id — the dashboard renders them as one timeline.

with st.conversation("user-42-chat-7", user_id="user-42"):
    for turn in chat_turns:
        run_agent(turn)

Signature

st.conversation(conversation_id: str | None = None, *, user_id: str | None = None) -> ContextManager[None]
ParameterDefaultDescription
conversation_idauto UUIDYour identifier. Omit to autogenerate.
user_idNoneEnd-user identifier. Inherited by every trace inside.

When to use

  • Multi-turn chatbots — one conversation per chat thread.
  • Long-running agent tasks — one conversation per user request, even when the agent makes 12 tool calls.
  • Background jobs — one conversation per job run.

Nesting works; the innermost scope wins.

@st.agent
def chat_turn(message: str) -> str: ...

with st.conversation():
    chat_turn("hi")
    chat_turn("book me a flight")

Next