wrap_agent.
Required
Create a run wrapper
Execute the run
run_id is the stable identifier you can return, store, and correlate with downstream signals.
Optional run data
Attach run-level attributes on the root span:lemma.user_idlemma.session_idlemma.environmentlemma.feature
Mark a run as failed
Userecord_error and re-raise the exception:
Dashboard outcome
A run appears as the top-levelai.agent.run span with:
- total duration
- final output from
on_complete - error state (if
record_erroris called or an uncaught exception occurs) - custom attributes for filtering

