square-flag-66304
10/27/2025, 6:48 AMtall-airline-16756
10/27/2025, 6:48 AMtall-airline-16756
10/27/2025, 6:49 AMdeparture_timeout setting when creating a room. This will automatically close the room shortly after the last participant leaves. For example:
room = await room_service.create_room(CreateRoomRequest(
name="my-room",
departure_timeout=10 # Keeps the room open for 10 seconds after the last participant leaves
))
• Agent-Based Deletion: If you’re working with LiveKit Agents, you can set delete_room_on_close=True so the room is deleted as soon as the agent session ends:
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(
delete_room_on_close=True, # Deletes the room when the session closes
),
)
• Manual Deletion: You can also delete the room programmatically using the server-side API. For instance, with the RoomService client:
await room_service.delete_room("room_name")
Feel free to choose whichever method fits your setup best. And if you have any questions or need more help, just let me know—I’m here for you!
Sources: protobufs/livekit_room.proto | Core Platform Architecture & Authentication | livekit/livekit_composite | D... | Managing rooms | LiveKit Docs | autocomplete/fish_autocomplete | livekit-agents/livekit/agents/voice/room_io/room_io.pysquare-flag-66304
10/27/2025, 6:52 AMtall-airline-16756
10/27/2025, 6:52 AMdelete_room_on_close option isn’t available in your setup, you can delete the room manually using the API right after the call finishes. For example:
async def end_call(self, context: RunContext):
room_name = self.job_context.room.name
await self.job_context.api.room.delete_room(
api.DeleteRoomRequest(room=room_name)
)
This approach makes sure the room is cleaned up immediately after the call ends, disconnecting everyone and stopping any ongoing processes.
If you’d like, I’m here to walk you through the implementation or answer any questions you might have!
Sources: agent.py | Job lifecycle | LiveKit Docs | Agents telephony integration | LiveKit Docs | livekit-agents/livekit/agents/voice/room_io/room_io.py | telephony/sip_lifecycle.pysquare-flag-66304
10/27/2025, 6:56 AMtall-airline-16756
10/27/2025, 6:56 AMasync def end_call(self, context: RunContext):
room_name = self.job_context.room.name
await self.job_context.api.room.delete_room(
api.DeleteRoomRequest(room=room_name)
)
1. Trigger the Function: Make sure to call this function as soon as the call ends. You might want to include it in your call termination logic or event handler.
2. Ensure Authentication: Double-check that your LiveKit server has the right API credentials set up (LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET) so the function can communicate with the API smoothly.
If you’d like, I’m here to help you integrate this into your setup or answer any questions you have!
Sources: Job lifecycle | LiveKit Docs | Managing rooms | LiveKit Docs | livekit-api/livekit/api/room_service.py | telephony/sip_lifecycle.py | agent.pysquare-flag-66304
10/27/2025, 6:57 AMtall-airline-16756
10/27/2025, 6:59 AMonDisconnect callback in the AgentControlBar component. This callback activates when the user clicks the "END CALL" button. Here’s a simple example:
<AgentControlBar
onDisconnect={() => {
console.log("Call ended by user");
// Call your function here
endCallFunction();
}}
/>
1. Agent-Side: If the agent needs to end the call for everyone involved, the delete_room API is the way to go. Take a look at this example:
async def end_call(self, context: RunContext):
room_name = self.job_context.room.name
await self.job_context.api.room.delete_room(
api.DeleteRoomRequest(room=room_name)
)
1. Server-Side: You can also handle disconnection events using room callbacks. For instance, with the Go SDK, it looks like this:
roomCallback := &lksdk.RoomCallback{
OnDisconnected: func() {
log.Println("Room disconnected")
// Trigger your function here
},
}
I’d love to know which approach feels like the best fit for your setup. Just let me know, and I’ll be happy to walk you through it with more details!
Sources: callback.go | src/room/Room.ts | complex-agents/role-playing/role_playing_frontend/components/livekit/agent-... | Agents telephony integration | LiveKit Docs | README.mdsquare-flag-66304
10/27/2025, 7:00 AMtall-airline-16756
10/27/2025, 7:01 AMdelete_room_on_close=True option when starting the agent session. This way, the room will be automatically deleted as soon as the session ends, like when the user disconnects. Here's how you can do it:
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(delete_room_on_close=True)
)
1. Manual Room Deletion: If you'd prefer to control it yourself based on your own logic, you can use the delete_room API to terminate the room programmatically. For example:
await ctx.job_request.delete_room()
Or, if you're working from a server environment, you can do this:
from livekit import api
await api.LiveKitAPI().room.delete_room(room=room_sid_or_name)
Both of these methods will make sure the room is properly cleaned up, disconnecting everyone and stopping any ongoing processes. If you have any questions or want help implementing this, just let me know—I'm here to support you!
Sources: livekit-agents/livekit/agents/voice/room_io/room_io.py | Job lifecycle | LiveKit Docs | Agents telephony integration | LiveKit Docs | pkg/service/roommanager.go | Connecting to LiveKit | LiveKit Docssquare-flag-66304
10/28/2025, 4:34 AMtall-airline-16756
10/28/2025, 4:35 AMctx.room.name property inside the JobContext object that’s passed to your entrypoint function. Here’s a quick example to help you out:
async def entrypoint(ctx: JobContext):
room_name = ctx.room.name
logger.info(f"Room name: {room_name}")
# Proceed with your agent logic
If anything’s unclear or if you’d like me to walk you through it a bit more, just let me know—I’m here to help!
Sources: basics/exit_message.py | Job lifecycle | LiveKit Docssquare-flag-66304
10/30/2025, 7:55 AMtall-airline-16756
10/30/2025, 7:56 AMgemini-2.5-flash or gemini-2.0-flash-live-001. You can specify the model clearly in your configuration like this:
llm = LLM(model="gemini-2.5-flash")
1. Network Latency: It really helps to deploy your agent server close to Google’s regional endpoints, such as us-central1, to cut down on data travel time.
2. Configuration Parameters: Tweaking settings like transcript_timeout (try reducing it to 1.0s or less) and avoiding unnecessary thinking_config or very high max_output_tokens can make a big difference.
3. Trigger Responses Immediately: You can use generate_reply() to get around delays that happen when waiting for user input to finish, like this:
await agent_session.generate_reply()
1. Limit Tools and Inputs: Reducing the number of tools, vision inputs, and long context windows can help lower processing time.
Please feel free to reach out if you’d like any help implementing these suggestions—I’m here to support you every step of the way!
Sources: Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | Troubleshooting & Common Issues | livekit/livekit_composite | DeepWiki | tests/test_agent_session.py | Google Gemini LLM | LiveKit Docs | Vision | LiveKit Docssquare-flag-66304
10/30/2025, 7:59 AMtall-airline-16756
10/30/2025, 8:00 AMgemini-2.0-flash-live-001 with minimal tools, I’d love to share some additional steps that can help optimize your performance even more:
1. Adjust Model Parameters: You can fine-tune these settings to help reduce latency:
model = RealtimeModel(
model="gemini-2.0-flash-live-001",
temperature=0.7,
max_output_tokens=256,
candidate_count=1,
top_p=0.9,
top_k=40,
tool_behavior=Behavior.BLOCK # Disable unnecessary tool calls
)
1. Optimize HTTP and Connection Settings: Tweaking timeouts and retries can make a difference:
model = RealtimeModel(
model="gemini-2.0-flash-live-001",
http_options=types.HttpOptions(timeout=5000),
conn_options=APIConnectOptions(
timeout=5.0,
retry_interval=0.5,
max_retries=2
)
)
1. Disable Unnecessary Features: Turning off features that aren’t needed for your setup can help streamline things:
model = RealtimeModel(
input_audio_transcription=None,
output_audio_transcription=None,
enable_affective_dialog=False,
proactivity=False
)
I hope these suggestions help reduce latency for you! Please don’t hesitate to reach out if you’d like a hand implementing any of these changes — I’m here to help.
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real... | plugins/google/src/beta/realtime/api_proto.ts