- TypeScript
- Python
A run is a single end-to-end execution of your agent. In Lemma custom instrumentation, runs are created with
wrapAgent.Required
Create a run wrapper
- TypeScript
- Python
Execute the run
- TypeScript
- Python
runId is the stable identifier you can store, return to clients, and correlate with downstream events.Per-invocation options
Pass a second argument to the wrapped function forlemma.thread_id and to override the default experiment flag for that call only. Full reference: Per-invocation options.
Optional run data
- TypeScript
- Python
Run-level data is usually attached as span attributes from inside the wrapped function:Recommended run-level keys:
lemma.user_idlemma.session_idlemma.environmentlemma.feature
Mark a run as failed
- TypeScript
- Python
Use
recordError and rethrow so the run is visibly errored and your app still handles failures normally.Dashboard outcome
A run appears as the top-levelai.agent.run span with:
- total duration
- final output from
onComplete/on_complete - error state (if
recordError/record_erroris called or an uncaught error occurs) - custom attributes for filtering

