Eval writes scores for you during an offline run, and hosted judges store their answers as session insights instead.
Before you begin
Before you start, make sure you have:- atlanai SDK with tracing: Installed as in Install atlanai SDK, with
init_loggerorinitLoggerset up as in Trace first agent run. - API key and workspace ID: In
ATLAN_API_KEYandATLAN_WORKSPACE_ID. The key must be able to create scorers in the workspace.
1
Register scorers once
Every score cites a scorer ID and version. Create a
code scorer for an automated check, or a human scorer for feedback. Do this once, for example at deploy time, and keep each scorer’s id and version_ordinal.Scorer names are unique in the workspace, so the helper reuses a scorer that already has the name. Pick names specific to your application, and give each scorer one meaning: when a check’s logic changes, register a new name or update the scorer to record a new version.- Python
- TypeScript
2
Score request while it runs
score attaches a score to the span you call it on. Call it on the root span to score the whole request, or on a child span to score one step, such as a retrieval. Keep the trace ID and root span ID if feedback may arrive later.- Python
- TypeScript
score_trace in Python or scoreTrace in TypeScript with the same arguments. If the root span is not in this process, the score attaches to the span you called it on.Match data_type (dataType in TypeScript) to the value:Use stable, lowercase score names with underscores, such as
thumbs_up: statistics aggregate by name. Add comment to record why, and keep user content out of it unless your data policy allows it, because comments are stored on the trace.3
Attach feedback after request
Feedback often arrives later, from another process. Open a span in the original trace with the IDs you kept, and score it. The feedback span becomes a child of the original root, so the trace shows the answer and the verdict together.
- Python
- TypeScript
4
Verify scores on trace
A score without a valid scorer ID and version is dropped with a warning, not raised, so check that each one arrived.
- Check in the app: Open the request’s trace. Each score appears as a child span named
score.<name>withscore_value,scorer_id, andscorer_versionset. - Check in code: When the request belongs to a session, list its spans with
client.sessions.traces.list_spans(session_id, trace_id, fields="core,attributes"), orclient.sessions.traces.listSpans({ sessionId, traceId, fields: "core,attributes" })in TypeScript. Spans become readable a few seconds afterflush(), so poll briefly.
ATLAN_DEBUG=true and run again: the warning names the missing scorer ID or version. Other causes are in Eval errors.Troubleshooting
Scores that never appear usually have a missing scorer ID or version, or a value that does not match its data type. See Eval errors. If no traces appear at all, see Install and setup errors.Next steps
- Turn production failures into test cases: Keep a failure your scores found as a repeatable offline case.
See also
- Score production sessions: Run a hosted judge over recorded sessions instead of scoring from code.
- Make app traffic scoreable: Record requests as sessions so you can read their spans back.
- Write code scorers: Scores that
Evalwrites during offline runs.