agents icon indicating copy to clipboard operation
agents copied to clipboard

Unable to access current span on `add_shutdown_callback` or on `on_session_end`

Open debajyoti-truefoundry opened this issue 3 weeks ago • 1 comments

Bug Description

https://docs.livekit.io/deploy/observability/data/#save-conversation-history-example

https://docs.livekit.io/deploy/observability/data/#session-reports

I want to be able to add the whole session report as a span attribute to the root span.

I am unable to do it today because no callback executes after await job_entrypoint_fnc in _traceable_entrypoint.

https://github.com/livekit/agents/blob/620ed3485aa1abb12cd86c59ac893d5bf2da3d38/livekit-agents/livekit/agents/job.py#L776

By the time the shutdown callback or session end callback is called, the root span has already ended.

Expected Behavior

I should be able to access the root span in shutdown or session end callback so that I can add my own span attributes after the conversation is over.

Reproduction Steps

Not relevant

Operating System

Not relevant

Models Used

No response

Package Versions

Not relevant

Session/Room/Call IDs

No response

Proposed Solution


Additional Context

No response

Screenshots and Recordings

No response

debajyoti-truefoundry avatar Dec 30 '25 15:12 debajyoti-truefoundry