Skip to main content
Every @agent_task LLM calls, tool invocations, and task dependencies is recorded as a span automatically. No manual instrumentation required. Traces capture timing, inputs, outputs, and parent relationships so you can understand exactly what your agent did and why.
Run MOTUS_TRACING=1 python my_agent.py to enable detailed tracing with file export in a single environment variable.

Collection levels

MOTUS_TRACING=1 sets collection to detailed and enables file export. The basic level is always on by default it adds negligible overhead and gives you timing data for every run.

Environment variables

Export formats

After a run, TraceManager.export_trace() writes the following files to the output directory:

Lifecycle hooks

Tracing is built on HookManager. You can register callbacks at three levels of specificity global (every task), per-name (a specific function or tool), and per-type (all tool calls or all model calls).

Registering hooks

Decorator equivalents

Execution order within each event: global hooks, then name hooks, then type hooks. Pass prepend=True to run a callback first within its group. Both sync and async callbacks are supported. Exceptions in callbacks are logged and never propagated.

HookEvent fields

Programmatic access

Advanced configuration

For fine-grained control, construct a TraceConfig directly instead of relying on environment variables:

Cloud Tracing

When your agent is deployed to Motus Cloud via motus deploy, traces are automatically streamed to the Motus dashboard — no additional configuration needed. The cloud infrastructure sets MOTUS_ON_CLOUD=1, which enables cloud trace upload alongside your existing credentials. Local runs never send traces to the cloud, even if you are logged in. This prevents accidental uploads during development.