refined-airport-68974
12/23/2025, 7:58 AMtall-airline-16756
12/23/2025, 7:58 AMtall-airline-16756
12/23/2025, 7:59 AM{ should_end_call: true }), check that result in your agent/handler immediately after the tool call, then shut down the agent session and (optionally) delete the LiveKit room to end the call for all participants.
Example patterns you can follow:
1) Agent/tool returns the flag
• Tool returns JSON like { "should_end_call": true, "reason": "safety" }.
2) Act on the result (Python-style pseudocode)
result = await analyze_user_request(context, query)
if result.get("should_end_call"):
# optional: send final reply to user
await context.session.generate_reply(instructions="Ending the call now.")
# end the LiveKit room for all participants
await job_ctx.api.room.delete_room(api.DeleteRoomRequest(room=job_ctx.room.name))
# gracefully shut down the agent session (drain finishes speech)
await context.session.shutdown(drain=True)
3) Node.js equivalent
• Use the agent context/tool result check, call await ctx.session.generateReply(...) if needed, call RoomServiceClient.deleteRoom(...) to remove the room, then await ctx.shutdown() to end the session.
Key notes
• Return a clear boolean flag from the tool so the agent can react deterministically.
• Use session.shutdown(drain=True) (or ctx.shutdown() in Node) to let in-flight speech finish before closing.
• Deleting the room ends the call for everyone; shutting down the session ends the agent’s connection only.
If you want, tell me:
• which SDK/language you’re using (Python or Node), and
• whether you want to end the call for everyone or only disconnect the agent — I’ll provide a concrete code snippet for that environment. Sources: Agents telephony integration | LiveKit docs | Gemini Live API plugin | LiveKit docs