cuddly-vr-85751
12/02/2025, 6:08 PMtall-airline-16756
12/02/2025, 6:09 PMtall-airline-16756
12/02/2025, 6:09 PMcuddly-vr-85751
12/02/2025, 6:10 PMtall-airline-16756
12/02/2025, 6:10 PMctx.make_session_report() for a full SDK report and include it.
Example patch (drop into your file; preserves your structure):
from datetime import datetime
import json
# (keep your existing imports)
# inside entrypoint
async def entrypoint(ctx: JobContext):
agent = WebAgent(getattr(ctx.job, "metadata", "{}"))
session = AgentSession()
start_time = datetime.utcnow()
transcript_items = []
@session.on("user_input_transcribed")
def on_user_transcribed(event):
transcript_items.append({
"role": "user",
"text": getattr(event, "transcript", ""),
"is_final": getattr(event, "is_final", False),
"ts": datetime.utcnow().isoformat()
})
@session.on("conversation_item_added")
def on_conversation_item(event):
transcript_items.append({
"role": getattr(event.item, "role", "agent"),
"text": getattr(event.item, "text_content", ""),
"ts": datetime.utcnow().isoformat()
})
@session.on("close")
def on_close(event):
end_time = datetime.utcnow()
duration_seconds = (end_time - start_time).total_seconds()
report = {
"session_id": getattr(ctx.job, "sid", None),
"room_name": getattr(ctx.room, "name", None),
"start_time": start_time.isoformat(),
"end_time": end_time.isoformat(),
"duration_seconds": duration_seconds,
"participant_identity": getattr(ctx.room.local_participant, "identity", None),
"transcript": transcript_items,
"error": getattr(event, "error", None)
}
print(json.dumps(report, indent=2))
# optional: save to file
# with open(f"report_{report['session_id']}.json","w") as f:
# json.dump(report, f, indent=2)
async def on_session_end():
# optional: include SDK session report if available
try:
sdk_report = ctx.make_session_report()
report_full = {"sdk_report": sdk_report.to_dict()}
print(json.dumps(report_full, indent=2))
except Exception:
pass
ctx.add_shutdown_callback(on_session_end)
await session.start(agent=agent, room=ctx.room)
await session.say(get_greeting_from_config(getattr(ctx.job, "metadata", "{}")))
If you want:
• report saved to S3 or a webhook, tell me which and I’ll add the snippet; or
• to include recording file paths / egress details from ctx.make_session_report(), confirm you want the SDK report included and I’ll show how to extract those fields.
Which output method do you prefer (stdout / file / webhook / S3)?
Sources: Observability data hooks | LiveKit docs | Events and error handling | LiveKit docs | Text and transcriptions | LiveKit docs