How do I move my sessions from LangSmith to Rius?
Rius maps a LangSmith thread to a session: wrap each conversation turn in rius.session(thread_id) and every span inside it carries the session ID. You stop putting thread_id in run metadata, and the turns group in the Rius sessions view. Traces you already have in LangSmith stay there, and Rius starts grouping from the first span you send. The LangSmith migration guide covers the rest of the move.
How it works
A LangSmith thread is a set of runs that share a thread_id or session_id in their metadata. You have to put that value on every run, child runs included. In Rius the same idea is a session, stored as session.id on each span.
- A scope, not metadata.
rius.session()is a context manager. Every span started inside it getssession.id, including spans from auto-instrumented libraries such as OpenAI, Anthropic and LangChain. You set it once per request.observetakes no session argument for this reason. - TypeScript. The TypeScript SDK has the same shape with
withSession. - A whole process. If one process always serves one session, set
RIUS_SESSION_IDinstead of using a scope. - No session set. A trace with no
session.idis its own session. - Metadata and tags. Rius has no separate tag concept. Other LangSmith metadata becomes a span attribute: call
span.set_attribute(key, value)insiderius.start_as_current_span(...), oropentelemetry.trace.get_current_span().set_attribute(key, value)inside an@rius.observefunction.
If you use LangSmith’s OpenTelemetry export (Path C in the guide), a thread_id or session_id arrives as langsmith.metadata.thread_id, not as session.id. Traces are not grouped into sessions that way. Use the Rius SDK to get sessions.
Set it up
- Install the Rius SDK with the extra for your stack and set your key. For a LangChain or LangGraph app, that is the
langchainextra. For@traceablecode with OpenAI and Anthropic clients, use[openai,anthropic]instead. The migration overview helps you pick a path.
pip install "glassflow-rius[langchain]"
export RIUS_API_KEY="ri_..."-
Remove the thread from your metadata. In LangSmith code you had
@traceable(name="Chat Pipeline", metadata={"thread_id": thread_id}). In Rius you decorate with@rius.observe(name="Chat Pipeline")and drop the metadata. -
Wrap each conversation turn in
rius.session(...), passing the same ID you used asthread_id. Herethread_idis your own variable.
import rius
rius.init(service_name="my-agent")
with rius.session(thread_id):
agent.invoke({"messages": [{"role": "user", "content": "Weather in Lisbon?"}]})-
Keep the ID stable across turns. Reuse the value your app already generates per conversation, so turn two lands in the same session as turn one.
-
Unset
LANGSMITH_TRACINGonce you no longer want LangSmith’s callback tracer running next to Rius. While you evaluate, leave it set and both backends receive traces from the same process. -
Check the result. Send two turns with the same ID and confirm they group in the sessions view. Then compare trace counts and token totals against LangSmith on real traffic for a few days.
What you get
- Grouped conversations. Turns that share an ID appear as one session, with their traces together.
- One place to set it. The session ID covers every span in scope, so you no longer tag child runs.
- Cost and tokens per session. Each model call is a generation with model, token counts and a server-side cost estimate.
- Users alongside sessions. You can also track the end users your agents served.
- Both backends in parallel. You can run LangSmith and Rius together, then cut over when Rius shows what you need.
What has no counterpart in Rius today:
- Old threads. Rius has no importer for LangSmith runs, so past threads stay in LangSmith.
- Feedback and annotation queues. There are no feedback scores on runs and no human review queues.
- Datasets, experiments and evaluators. Rius has none of these, including LLM as judge.
- Prompt Hub and Playground. Rius has no prompt registry or playground. Prompt content on spans is still captured and inspectable.
When something else fits
- If feedback scores, annotation queues or evaluators are central to how you review threads, keep LangSmith for those and run Rius next to it for tracing, cost and alerts.
- If you cannot change code yet, LangSmith’s OpenTelemetry export gets traces into Rius quickly, but without sessions or content. Use it as a bridge, then move to the SDK.