Agent insight not loaded

Why these 3 don’t have usage metrics in Log Agent insight
Room Id : RM_R688mmNWxYxw
RM_mqWdXm6zCn8f
RM_xzBrURRSTBmG

I want to know Usage: UsageSummary

CODE:


session = AgentSession(
        tools=[end_interview],
        stt=stt_plugin.FallbackAdapter([
            stt,
            assemblyai.STT(model="universal-streaming", api_key=ASSEMBLYAI_API_KEY)
        ]),
        # llm="openai/gpt-4o",
        llm = llm.FallbackAdapter(llm=[
            openai.LLM(
                model="gpt-5",
                api_key=OPENAI_API_KEY
            ),
            openai.LLM(
                model="gpt-4o"
            )
        ]),
        tts=tts_plugin.FallbackAdapter([
            tts,
   
        ]),
        vad=silero.VAD.load(),
        turn_detection=MultilingualModel(),
        preemptive_generation=True,
        allow_interruptions=True,
        min_interruption_duration=1.2, # Minimum speech length (s) to register as an interruption
        min_endpointing_delay=1.6, # Minimum time-in-seconds since the last detected speech before the agent declares the user's turn complete.
        max_endpointing_delay=7.0, # Maximum time-in-seconds the agent will wait before terminating the turn
        false_interruption_timeout=1.5, #
        user_away_timeout=20
    )

 usage = metrics.UsageCollector()

    @session.on("metrics_collected")
    def _m(ev):
        usage.collect(ev.metrics)

    async def log_usage():
        logger.info(f"Usage: {usage.get_summary()}")

    ctx.add_shutdown_callback(log_usage)

Even in my local, i didn’t printed this line

logger.info(f"Usage: {usage.get_summary()}")

Your other sessions are saving insights and just not these three or none are saving insights?

I got the issue and solved it.
Thanks for your response

How did you solve it, just wondering incase others have the same issue.

I’m currently using the following code:

@session.on(“close”)
async def on_closed(session):
logger.info(“\n------ Cleaning up timeout task on session close ------”)
logger.info(f"Session closed Usage: {usage.get_summary()}")
timeout_task.cancel()

However, it seems that using async with the @session.on("close") handler may not be supported.

When I change it to:

@session.on(“close”)
def on_closed(session):

(without async), I do not encounter any errors and the usage summary is correctly reflected in the insights dashboard.