Skip to main content
The overmind package instruments your LLM stack over OpenTelemetry and exports spans to Overmind. One init() call captures every supported provider call automatically; decorators and span helpers trace the code around those calls.
The package also ships the overmind CLI used by optimisation runs and an OpenAI-compatible inference client.

init()

Call once at process startup, before any LLM call. Idempotent and re-entrant — calling again with more providers enables them without tearing down the tracer.
Environment variables: OVERMIND_API_KEY, OVERMIND_API_URL, OVERMIND_SERVICE_NAME, OVERMIND_STRICT_MODE. After init(), calls made with the OpenAI, Anthropic, Google Gemini, and Agno client libraries produce llm_call spans automatically, capturing messages and tool calls, model and request parameters, token usage, latency, and errors. Spans export via a batching OTLP/HTTP exporter to POST {base_url}/api/v1/traces.

Tracing your own code

Auto-instrumentation only sees model calls. Wrapping the code around them — the entry point, tools, retrieval steps — turns flat spans into a tree that mirrors your agent’s structure.

Span types

Decorators

@observe is the general decorator; @entry_point, @workflow, @tool, @retrieval, and @function are typed shortcuts. All of them capture arguments as inputs and the return value as outputs (JSON-serialised, best effort). They record duration and status, re-raise exceptions after recording them, and work on both sync and async functions.
Because each function calls the next, spans nest into one tree: handle_requestresearchweb_search → the auto-captured llm_call spans underneath.
Always add an @entry_point(). It marks the unit that trace scoring and dataset conversion treat as one run — without it, model calls arrive as disconnected spans. Tools are the next most valuable layer; most teams stop there.
For functions that handle secrets or oversized payloads, observe_safe traces without capturing inputs or outputs.

start_span() — blocks and loops

A context manager for regions that aren’t whole functions. It opens a child span under whatever span is active. Unlike the decorators, it captures nothing automatically — attach metadata via attributes or set_tag().

get_tracer() — raw OpenTelemetry

For span lifetimes that don’t fit a single block, drop down to the OTel tracer. Raises RuntimeError before init().

Context helpers

All operate on the current span/trace — call them inside a traced function or request handler.

PromptString — explicit prompt structure

Passing prompts as plain strings forces Overmind to infer which parts are template versus dynamic input. PromptString declares that structure, giving agent discovery a stable signal:
Use the same id for logically identical prompts across providers and versions, and Overmind groups them as one agent. Use one PromptString per LLM call — the SDK raises an error if it detects more.

Full example

One trace: handle_support_query (entry point) → gather_contextlookup_order (tool) → the OpenAI llm_call, tagged with the user and workflow, attributed to the Support Triage agent.