How do I see which agent version handled a request in an agent built with Pydantic AI?
Rius shows which agent version handled a request in the Version column and the trace header, once you set RIUS_MAIN_AGENT_VERSION for your Pydantic AI process. The Pydantic AI integration records the run, each model request and each tool call on its own, but the version is a value you supply. Rius reads it as the rius.main_agent.version attribute and shows it on every trace the process sends.
How it works
What the integration records on its own. Pydantic AI emits its own OpenTelemetry spans, and Rius reads them without wrappers. Each agent run becomes the root span, named invoke_agent followed by your agent’s name. Each model request becomes a generation named chat followed by the model, with tokens and cost. Each tool call becomes a span named execute_tool followed by the tool name. These spans tell you which agent, model and tools ran. They do not tell you which version of your code ran.
What you set yourself. The agent version is the attribute rius.main_agent.version, which you set with the environment variable RIUS_MAIN_AGENT_VERSION. It is set once for the process, so every trace that process sends carries it. No span of your own and no extra code is needed. RIUS_AGENT_NAME sets the name the agent is grouped under, and it defaults to your service name.
Where it shows.
- The Version column in the trace list, which shows the agent version, or the build when there is none.
- The header of an open trace, next to the end user, the session and the build when the trace carries them.
- The Agents page, which compares two versions of an agent on failed rate, cost per trace, latency, time to first token and tokens per trace.
See Exploring traces for the list and the trace page.
Set it up
-
Install the SDK and initialize it before you create your agent. The full Pydantic AI setup is on the Pydantic AI integration page.
pip install glassflow-rius pydantic-ai -
Set the version in the environment of the process that runs the agent. Use whatever identifies the release you deploy, such as a release tag or a build number. This value is yours.
export RIUS_MAIN_AGENT_VERSION=2026.10.2 export RIUS_AGENT_NAME=support_agent -
Run your agent as usual. The code needs no version argument, because the SDK reads the variable.
import rius from pydantic_ai import Agent rius.init(api_key="ri_...", service_name="my-agent") Agent.instrument_all(True) support_agent = Agent( "openai:gpt-5-mini", instructions="Answer support questions.", ) conversation_id = "conv-123" # your own conversation id ticket = "How do I reset my password?" with rius.session(conversation_id): result = support_agent.run_sync(ticket) print(result.output) -
Open Traces in the console. Find the request, by session ID if you scope runs with rius.session, and read the Version column. Open the trace to see the same version in its header.
-
To list only the requests one version handled, click Add filter, pick the version attribute as the field, and choose the value. Filters live in the URL, so you can copy the link for a teammate.
Change RIUS_MAIN_AGENT_VERSION each time the agent’s prompt, tools or policy change. Traces keep the version they were sent with, so old and new releases stay apart in the list.
What you get
- For any request, you read which agent version handled it from the trace list or the trace header, next to the spans Pydantic AI already produces: the invoke_agent root, the chat generations and the execute_tool spans.
- You filter the Traces and Spans views down to one version when you chase a regression.
- The Agents page lets you compare two versions side by side on failed rate, cost per trace, latency and tokens. It warns you when a side has fewer than 20 traces.
- Cost on each model request is a list-price estimate in US dollars, computed by Rius from the model and token counts. You never send it.
For the wider picture of watching agents after a release, see Monitor AI agents in production.
When something else fits
- If you only need to tell builds apart, RIUS_SERVICE_VERSION sets service.version. The trace list falls back to the build when a trace has no agent version.
- If other frameworks run in the same project, the integrations overview shows what each one records. The version is set the same way for all of them.