Skip to main content
The package exports SovaraClient and trace. Trace-scoped helpers are methods on SovaraClient; module-level recording scopes and logging helpers are not supported. For existing integrations, client.run(run_id=...), client.subrun() and client.get_run_id() remain deprecated aliases for the trace methods below. client.log() also accepts run_id, run_input and run_output; supplying both an old and new name for the same field raises an error. These aliases use the current server contract and trace ID derivation.

SovaraClient(*, project_name, base_url=None, agent_token=None, http_client=None)

Creates a client bound to one project name. Project admins can rename a project from the Sovara app; update this value when they do.
For a remote server, pass base_url and agent_token explicitly:

client.trace(name=None, *, trace_id=None, eval_run_id=None, capture_logs=True, lesson_scope=<inherit>)

Opens a recording session on a durable trace, usable with with or async with. No turn is created implicitly; work outside turn() remains recorded without a turn.
Entering the context yields the trace ID, or None if recording is unavailable. Use a stable trace_id to append to the same trace. A sovara- ID must already exist in the project.

client.subtrace(name, *, lesson_scope=<inherit>)

Creates a child trace under the active trace.
name is required. Returns SovaraTraceContext, supporting with and async with; entering it yields the subtrace’s trace ID, or None in no-capture mode. Requires an enclosing trace opened by the same client.

client.turn(*, turn_input=None)

Groups one interaction in the active trace or subtrace. Supports with and async with, yielding the turn ID or None if recording is unavailable. turn_input accepts a string or None. Use the same client and do not nest turns within a trace.
Finish tasks and streams before leaving the trace. See the usage guide for turn examples.

trace(fn=None, *, name=None, meta=None)

Wraps a sync or async function as a tool-like step. It is the only top-level instrumentation helper. It records a step inside the current trace and does not open a trace; use client.trace() for that.
The wrapper preserves the call signature, records arguments and return values, records raised exceptions, and re-raises them.

Lesson methods

client.lesson_scope(scope)

Temporarily replaces the active lesson scope. Paths include descendants; None means root/all and [] disables retrieval.

client.disable_lesson_injection()

Temporarily prevents automatic lesson retrieval while leaving tracing active.

client.create_eval_run()

Creates an evaluation in the client’s project and returns its eval_run_id. Record samples with client.trace(eval_run_id=...), then log results with client.log().

client.log(*, trace_id=..., eval_run_id=..., **fields)

Logs to an explicit target, including after the recording context closes. No identifier is inherited from a context. Agent traces and eval runs must already exist. Reserved fields trace_input, trace_output, groundtruth, and llm_judge_output accept strings; llm_judge_is_correct accepts a boolean. These require trace_id. Custom fields accept booleans, strings, finite floats, and integers between -253 and 253. Explicit None is invalid. Writes replace supplied fields and leave others unchanged. Logging never changes a trace’s evaluation owner. groundtruth updates the trace annotation; llm_judge_is_correct records a separate evaluation verdict. See Evaluations for aggregate metrics and accuracy.
log() and create_eval_run() are synchronous and raise on errors. Skip trace logging when recording yields None. After a timeout, check the saved result before retrying; the write may have succeeded.

client.get_trace_id()

Returns the current trace or subtrace ID as a string, or None when called outside an active trace.

Context and tracing controls

client.with_context(fn)

Captures the current context and returns a wrapper for another thread.

client.disable_tracing()

Temporarily disables supported provider, MCP, and explicit trace recording.