Skip to main content

The ownership model

The Python SDK exposes two top-level building blocks:
  • SovaraClient owns project identity and run-scoped helpers.
  • trace wraps application functions that should appear as steps.
All run, subrun, logging, lesson, and control operations go through that client. The project is not inferred from the working directory.

Top-level runs

Use one top-level run for one user request, conversation turn, eval sample, batch job, or other execution you want to inspect.
The SDK registers the run with the exec server when the context opens and finalizes it when the context exits. The same context works with with and async with. For a durable conversation or workflow, pass an application-owned correlation ID. Reusing it appends new steps to the same canonical Sovara run.
Keep prompts, messages, and secrets out of client_run_id; use a stable ID such as a chat, ticket, or job ID.

Steps and explicit tracing

Inside a run, supported provider and MCP calls become ordered steps with input, output, latency, status, and error data. trace adds the same visibility to important application work that automatic instrumentation does not capture.
Place explicit tracing at shared tool or dispatch chokepoints. A trace filled with miscellaneous helper calls is harder to understand than one that exposes the agent’s decisions and meaningful actions.

Subruns

Subruns organize child agents, delegated branches, parallel work, and coherent multi-step phases under the active run.
Nested top-level client.run(...) calls are ignored with a warning. Use client.subrun(...) when the child work should appear in the run tree.

Run metadata

Add the user-visible input/output and small scalar metrics from inside a run.
Metric values must be booleans, integers, or finite floats. Keep prompts, responses, lists, dictionaries, and secrets out of metrics.

Lessons

Automatic lesson injection is project-wide by default for supported model calls. Narrow retrieval with lesson_scope on a run or subrun:
Temporarily replace the active scope inside a smaller block:
Use manual injection only when your application must place the managed lesson block itself.
inject_lessons(...) returns a prompt-ready string or "". Manual injection suppresses automatic injection for that model call.

Controls and concurrency

Async tasks inherit context. Wrap callables submitted to a thread pool with sovara_client.with_context(...). For concurrent top-level runs, set capture_logs=False to avoid mixing process stdout/stderr between runs.

Inspect the result

Run normally, or use the passive wrapper to print the run ID:
Use the API reference for exact signatures.