Skip to main content

Sessions

Every sequence of AI interactions is grouped into a session. Sessions provide the full context for enforcement decisions — what an agent has accessed, what data classifications it has touched, and how its behavior has evolved across a conversation.

What is a session?

A session is a continuous thread of interactions between an actor (user or agent) and one or more AI providers. Rivaro groups requests into sessions automatically using several signals:

  1. An explicit x-session-id header in your request
  2. A W3C traceparent header (OpenTelemetry compatible)
  3. The adapter's own session/thread/run identifier
  4. Smart detection — requests from the same actor within a 30-minute window are grouped automatically

Sessions are important for enforcement because Rivaro maintains a security context that accumulates across the session. If an agent accesses credentials in turn 3, that context is considered in the risk assessment for turn 7.

Session Fields

FieldDescription
sessionIdUnique session identifier (UUID)
actorIdUser or service identifier making the requests
agentIdAgent identity (ag_xxx) responsible for the session
statusOPEN, CLOSED, or ESCALATED
createdAtWhen the session started
lastActivityAtMost recent request timestamp (updated every 60 seconds)
traceIdW3C Trace Context trace ID (for OTel integration)
spanIdW3C Trace Context span ID
interactionIdFramework thread/run ID (LangChain, AutoGen, etc.)

Aggregated metrics

These are computed asynchronously (accurate within ~60 seconds) and denormalized on the session for fast querying:

FieldDescription
totalCostUsdSum of token costs across all requests in the session
totalTokensTotal tokens used
detectionCountNumber of policy violations detected
incidentSeverityHighest severity score seen in the session (0–100)
eventCountTotal events recorded

Security context

Rivaro maintains a security context that accumulates over the session's lifetime:

FieldDescription
originalRequestTruncated first user message — immutable once set, used to detect goal drift
dataClassificationsAccessedHigh-water mark of data classifications seen in this session (e.g. PII,PHI,CREDENTIALS)
note

The session context directly feeds the risk assessment. An agent that accessed credentials earlier in the session carries elevated session risk for subsequent enforcement decisions — even if the current request looks benign.

Session Events

Events are the append-only record of everything that happened inside a session. Each event references an entity (a detection, a telemetry record, a content record) and records when it happened and which agent produced it.

Event types

Event typeWhat it records
TELEMETRYToken counts, latency, cost for a request
CONTENTThe request/response content (subject to retention policy)
DETECTIONA policy violation found during ingress or egress scanning
POLICY_ACTIONThe enforcement action taken (BLOCK, REDACT, LOG, etc.)
ALERTAn elevated alert triggered by a detection
RAG_FETCHA retrieval-augmented generation fetch — what data was pulled
MCP_TOOLAn MCP tool invocation — which tool, with what arguments
SESSION_CLOSEDSession closure event with summary metadata

Event fields

FieldDescription
eventTypeOne of the event types above
entityTypeType of the referenced entity (Detection, TelemetryMetric, etc.)
entityIdID of the referenced entity for cross-referencing
timestampWhen this event occurred
agentIdWhich agent produced this event
adapterWhich provider adapter was used
resourceApp, page, or tool where this happened
traceId / spanIdOpenTelemetry trace context

Session Lifecycle

Opening a session

Sessions are created automatically when a request arrives with no matching open session. No SDK changes are needed — Rivaro handles session management transparently.

To correlate requests into a session explicitly, pass an x-session-id header or use the W3C traceparent header from your tracing system.

Session status

StatusMeaning
OPENActive — requests are being grouped into this session
CLOSEDSession ended normally (explicit close or inactivity timeout)
ESCALATEDSession flagged for admin review due to governance escalation

Closing a session

Sessions close in three ways:

  • Explicit close — your application sends a close signal
  • Inactivity timeout — no new requests for the session timeout window (30 minutes by default)
  • Governance action — quarantine or termination of the actor automatically closes open sessions

Session Risk & Enforcement

Session context contributes to the risk score of every enforcement decision made within it:

Context signalRisk impact
Credentials accessed in session+30 to risk score
Sensitive data + outbound tool call in session+20 to risk score
High event volume (>20 events)+10 to risk score

This means a single session where an agent accessed a secret early on will trigger stricter enforcement on subsequent requests — even if later requests look clean in isolation. See Actor Governance for the full risk score formula.

Viewing Sessions

Sessions are visible in the dashboard under Activity. For each session you can see:

  • Full event timeline with timestamps
  • All detections and the enforcement actions taken
  • Token usage and cost breakdown
  • Data classifications accessed
  • RAG fetches and MCP tool calls
  • The session's original request (first message)

Next steps