Skip to main content
The package exports SovaraClient and trace. Run-scoped helpers are methods on SovaraClient; module-level run, subrun, and logging helpers are not supported.

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

Creates a client bound to one immutable project name.
client.project_name is read-only. For a remote agent host, keep the token in the host’s secret manager or an excluded .env file and pass it explicitly:
The custom client is optional. Without it, Sovara creates and manages its normal internal HTTP client.

client.run(name=None, *, client_run_id=None, capture_logs=True, lesson_scope=<inherit>)

Creates a top-level run context usable with with or async with.
Returns SovaraRunContext.

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

Creates a child run under the active run.
name is required. Returns SovaraRunContext.

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.
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.inject_lessons(context=None)

Retrieves lessons for the active run and returns a prompt-ready managed block, or "" outside a run or when nothing matches.

client.disable_lesson_injection()

Temporarily prevents automatic lesson retrieval while leaving tracing active.

client.log_input(input)

Stores the latest user-visible input string on the active run. This value appears in the Input column of the Runs table and replaces the previously logged input.
Outside an active run, it logs a warning and does nothing.

client.log_output(output)

Stores the latest user-visible output string on the active run. This value appears in the Output column of the Runs table and replaces the previously logged output.
Outside an active run, it logs a warning and does nothing.

client.log_metrics(**metrics)

Adds filterable custom metrics to the active run. Values must be booleans, integers, or finite floats; keys must be lower snake case and at most 32 characters.
Logging the same key again updates its latest value. Outside an active run, it logs a warning and does nothing.

client.get_run_id()

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

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.