Session-Level Scoring for Agent Traces
Group agent traces that share a session_id or thread_id and score each whole session once on the /sessions page, beside the usual per-trace questions.
Session-level scoring in Potato groups the traces that share a session id into one session and lets annotators score the whole session on a page at /sessions. A session is the set of traces from one user interaction, such as a support conversation in which the user comes back twice before the problem is fixed. A question such as "Did the session resolve the user's problem?" needs every trace in the session before anyone can answer. Annotation schemes marked session_level: true are answered once per session on /sessions, and every other scheme stays on the per-trace annotation page as usual.
Configuration
The top-level sessions block groups the traces into sessions, and session_level: true on a scheme moves that scheme to /sessions. Add both settings to an existing config:
sessions:
enabled: true
attributes: [user_tier]
annotation_schemes:
- annotation_type: likert
name: session_resolution
description: Did the session resolve the user's problem?
size: 5
min_label: Not at all
max_label: Fully resolved
session_level: true
- annotation_type: radio
name: trace_quality
description: Quality of this trace
labels: [good, acceptable, poor]The sessions block takes three options:
| Option | Default | What the option controls |
|---|---|---|
enabled | off | Groups traces into sessions when the server starts and turns on /sessions and the /api/sessions routes. While the option is off, /sessions sends the browser to Potato's home page and the API routes return 503. |
key | none | The one item field to group on. Without key, Potato looks for session_id, then thread_id, then conversation_id. |
attributes | none | A list of item fields copied onto the session and shown at the top of the session's detail view, such as a customer tier or an agent version. |
The annotation types that can be session-level are radio, multiselect, likert, slider, select, text, and number. Potato rejects a config that puts session_level: true on any other type, and rejects a scheme that sets both turn_level and session_level. A config with session-level schemes and no sessions.enabled still starts, but Potato logs a warning, and no page offers the session-level schemes. A config with sessions.enabled and no session-level scheme logs a warning too, because /sessions then has no questions to show.
Session-level schemes also work inside phases. Potato collects session-level schemes from the top-level annotation_schemes list or, when the config has no such list, from the annotation_schemes of every phase.
Grouping traces into sessions
Potato groups traces once, when the server starts. For each loaded item, Potato checks the session field at the top level of the item and then under the item's metadata object, and the first non-empty value becomes the session's name. Without key, Potato tries session_id, thread_id, and conversation_id in that order for each item. One data file can therefore mix items that use different field names. With key: ticket_id, only ticket_id is checked.
An item without a session value joins no session. Annotators still label that item on the per-trace page, and the item is absent from /sessions. Grouping is safe to repeat. A restart puts newly loaded items into the sessions already stored and adds no item twice. Traces that the Langfuse poller or the trace webhook add while the server is running join a session at the next server start, because grouping runs only at startup.
Potato stores sessions in the same case store as QDA Mode's participant cases, under a separate namespace named <annotation_task_name>::sessions. One item can therefore belong to a QDA case and to a session at the same time. The namespace follows annotation_task_name. Renaming the task therefore starts an empty set of sessions, and the scores saved under the old name no longer appear on /sessions.
Where session ids come from
The session field has to be on the item before the server starts. Potato finds a session field on items from the sources below:
- The Langfuse poller. Each polled trace stores the Langfuse trace's
sessionIdasmetadata.session_id, and the default keys find the value there without akeysetting. A Langfuse trace without a session gets no value and joins no session. Review Langfuse Traces in Potato sets up the poller. - The generic trace webhook. A top-level
session_idin a payload sent to/api/traces/webhookreaches the item, because the webhook keeps every top-level field the sender supplied. A session id nested under the payload'smetadataobject is lost, because the webhook replaces that object with Potato's own. The LangSmith webhook format keeps no session or thread id. - A data file you write. A top-level
session_id,thread_id, orconversation_idon each line is enough, as in the example project below. - A converted trace file, after editing. None of the 15 converters in
python -m potato.trace_converterwrites a session field at 2.14.0. For example, thelangfuseconverter leaves out the session id that a Langfuse trace has. Add asession_idto each line of the converted file before starting the server. Theclaude_codeconverter turns each Claude Code session into one trace, with the session id as the trace'sidand as a row in the trace's metadata table. A Claude Code session therefore never spans several traces.
The tracing SDK sends no session id at 2.14.0.
The /sessions page
Annotators open /sessions after logging in, and a visitor who is not logged in goes back to the home page. The page has two panels:
- Queue. Every session appears by name, with the session's trace count and the number of session-level schemes the logged-in annotator has answered, such as
2/3 scored. - Detail. Selecting a session shows the session's attributes, one question for each session-level scheme, the answers from all annotators so far, and the member traces. The member list shows each trace's id with the first 160 characters of the item's
text_keyfield, or oftask_descriptionwhentext_keyis empty. The page renders no trace display. Annotators read the full traces on the per-trace annotation page.
Each question renders as a compact control. A radio or multiselect scheme shows the scheme's labels as buttons, and a likert scheme shows numbered buttons from 1 to size with min_label and max_label at the two ends. A select scheme shows a drop-down list, slider shows a range slider and number a numeric input, both bounded by min_value and max_value (default 0 to 100, and a slider's starting_value is ignored), and text shows a text area. An answer saves as soon as the annotator clicks or changes the value, and a text area saves 0.8 seconds after typing stops. In 2.14.0 all text areas on the page share one save timer, so typing in a second text area within 0.8 seconds cancels the first one's save; pause before moving to the next text area. Clicking a chosen button again deselects the button, and an answer left empty deletes the stored row.
Below each question, the page sums up every annotator's answers. The summary gives the number of annotators, the mean of the numeric answers, and a count for each label or text value. Every logged-in user sees every session in the queue, and per-trace assignment settings such as num_annotators_per_item do not limit the queue.
Session-level and per-trace schemes together
Session-level and per-trace schemes live in the same annotation_schemes list. On the per-trace annotation page, a session-level scheme renders as a short note with the scheme's description and a link to /sessions. The note has no input, and the per-trace form submits without a session-level answer. Per-trace schemes behave the same as in a config without sessions.
One way to divide the questions puts the outcome questions on the session and the quality questions on each trace. In the example project, a likert scheme asks whether the session solved the user's problem, a multiselect scheme records problems that show only across traces (e.g., lost context and repeated work), and a radio scheme rates each trace.
Storage and export
Session-level answers are not written to <output_annotation_dir>/<user>/user_state.json, where the per-trace annotations go. Potato keeps one row per session, annotator, and scheme in the case_annotations table of <task_dir>/project.sqlite. A later answer from the same annotator replaces the earlier one.
After every save, Potato rewrites <output_annotation_dir>/session_annotations.jsonl from the case_annotations table, with one JSON line per session, annotator, and scheme:
{"session": "session-alpha", "case_id": "…", "annotator": "alice", "schema": "session_resolution", "value": {"value": 4}, "updated_at": 1751979600.0, "instance_ids": ["trace-a1", "trace-a2", "trace-a3"]}The value field holds {"value": x} for a single answer and {"values": [...]} for a multiselect scheme. instance_ids lists the traces in the session when the line was written. The file appears after the first session-level answer is saved. An admin can fetch the same rows as JSON from the API with the admin API key:
curl -H "X-API-Key: $KEY" http://localhost:8000/api/sessions/exportThe exporter python -m potato.export reads the per-trace annotations only and leaves session-level answers out. The Langfuse write-back sends no session-level score either.
Agreement on session-level schemes
Potato computes no agreement coefficient for session-level schemes at 2.14.0. The /admin/iaa dashboard reads the per-trace annotations only, and the /sessions page shows a count and a mean rather than a coefficient. To measure agreement, read session_annotations.jsonl and treat each session as one item for a coefficient such as Krippendorff's α. Inter-Annotator Agreement Explained covers the choice of coefficient.
Every annotator sees the summary under each question before answering, and again after answering once the session is reopened. The summary shows the other annotators' answers for the session, with the text of every note. Session-level answers are therefore not blind to one another.
Example project
Potato ships a runnable example in examples/agent-traces/session-scoring/, with six synthetic support traces in three sessions. The first session follows a debugging problem over three traces, and the second contains two traces in which the user finds that the agent's answer contradicts the documentation. The third session is a single trace in which a billing question goes to a human, and the trace keeps the session id under metadata. Run the example from a clone of the Potato repository:
potato start examples/agent-traces/session-scoring/config.yaml -p 8000Log in and open http://localhost:8000/sessions to score the sessions, or /annotate to rate each trace.
The config below is a complete, smaller version of the same project, and passes python -m potato.validate_cli --strict:
annotation_task_name: Support session review
task_dir: .
output_annotation_dir: annotation_output/
data_files:
- data/traces.jsonl
item_properties:
id_key: id
text_key: task_description
user_config:
allow_all_users: true
users: []
sessions:
enabled: true
attributes: [user_tier]
instance_display:
fields:
- key: task_description
type: text
label: User request
- key: conversation
type: dialogue
label: Trace
annotation_schemes:
# Answered once per session on /sessions
- annotation_type: likert
name: session_resolution
description: Did the session resolve the user's problem?
size: 5
min_label: Not at all
max_label: Fully resolved
session_level: true
- annotation_type: multiselect
name: session_issues
description: Problems across the session
labels: [lost_context, repeated_work, contradictory_answers, unneeded_escalation]
session_level: true
- annotation_type: text
name: session_notes
description: Notes on the session
session_level: true
# Answered for each trace on /annotate
- annotation_type: radio
name: trace_quality
description: Quality of this trace
labels: [good, acceptable, poor]Each line of data/traces.jsonl has the session id at the top level, and both lines below join the session session-alpha:
{"id": "trace-a1", "session_id": "session-alpha", "user_tier": "pro", "task_description": "User asks why a deploy fails with a timeout.", "conversation": [{"speaker": "User", "text": "My deploy fails with a timeout after 30 seconds."}, {"speaker": "Assistant", "text": "Your container takes longer than 30 seconds to boot. Raise the healthcheck timeout."}]}
{"id": "trace-a2", "session_id": "session-alpha", "user_tier": "pro", "task_description": "Same user returns because the fix did not work.", "conversation": [{"speaker": "User", "text": "I raised the timeout to 120 seconds and it still fails."}, {"speaker": "Assistant", "text": "The container is killed for running out of memory at boot. Raise the memory limit to 512Mi."}]}For polled Langfuse traces, add the sessions block and the session-level schemes to the polling config on the Langfuse page. The default keys find metadata.session_id without a key setting. Restart the server to group the traces polled since the last start.
Limits
- Grouping runs at startup only. Traces added by polling or the webhook while the server runs reach
/sessionsafter the next restart. - Answers are not blind. Every annotator sees the running summary of all answers for a session.
- No agreement coefficient. Compute agreement on session-level schemes from
session_annotations.jsonl. - No session ids from converters. Converted trace files need a
session_idadded to each line. - Session answers stay in Potato. Langfuse write-back and
python -m potato.exportleave session-level answers out.
Further reading
- Review Langfuse Traces in Potato, for polling traces that have Langfuse session ids
- Human Review Queues for LLM and Agent Traces, which compares review queues across tools
- Agentic Annotation, for the trace converters and trace displays
- Turn-level annotation, for questions about single turns, in Potato's source documentation
For implementation details, see the source documentation.