jolly-autumn-53818
12/31/2025, 11:21 PMtall-airline-16756
12/31/2025, 11:21 PMtall-airline-16756
12/31/2025, 11:21 PM{{metadata.room_name}} and use secrets for `LIVEKIT_API_KEY`/`LIVEKIT_API_SECRET`.
c. Have your backend call api_client.room.delete_room(api.DeleteRoomRequest(room=room_name)).
• Export the agent as code and add a function tool that calls delete_room directly (then deploy the agent from the code). This gives full control but requires custom code — you can’t add that function from the UI alone.
Which approach do you prefer — Actions to call an existing backend, or exporting the agent to add direct SDK hangup logic? If you want, tell me how your backend is set up (language/framework) and I’ll give the exact request and server code snippet.
Sources: Agents telephony integration | LiveKit docs | Job lifecycle | LiveKit docs | Agent Builder | LiveKit docsjolly-autumn-53818
12/31/2025, 11:22 PMtall-airline-16756
12/31/2025, 11:22 PMjolly-autumn-53818
12/31/2025, 11:23 PMjolly-autumn-53818
12/31/2025, 11:23 PMtall-airline-16756
12/31/2025, 11:23 PMdelete_room, and redeploying it to LiveKit Cloud.
1) Export the agent from Agent Builder
• In Agent Builder, choose Export → Python. Download the generated project.
2) Add a hangup function
• Open the project and add a function tool that calls LiveKit’s room delete API. Example (use inside the agent’s tools file):
from livekit import api
@function_tool
async def hangup_call(self, ctx: RunContext):
"""End the current call by deleting the room."""
room_name = ctx.job.room.name
await ctx.job.api.room.delete_room(api.DeleteRoomRequest(room=room_name))
return {"status": "ended", "room": room_name}
• Ensure imports match the codebase; ctx.job.api is the API client available in the exported runtime.
3) Wire the function into the agent
• Add the new function tool name to the agent’s tool list or instructions so the agent can call it when appropriate (e.g., on user intent to hang up).
4) Ensure credentials and permissions
• Confirm the agent’s runtime on LiveKit Cloud has access to LiveKit credentials (API key/secret) with rights to delete rooms. Keep secrets secure per the project’s secret management.
5) Deploy the modified agent back to LiveKit Cloud
• Follow the project’s README for packaging/deploy steps included in the export. Typically:
a. Install dependencies: pip install -r requirements.txt
b. Run any build/deploy commands provided (or use the LiveKit Cloud CLI/process described in the exported README).
c. Upload/redeploy the modified agent bundle to LiveKit Cloud per the export instructions.
6) Test
• Start a test call in a room, invoke the agent and trigger hangup. Verify all participants are disconnected and the room is deleted.
If you want, I can:
• Provide a full file-level patch for where to insert the function in your exported project (share the main agent file names), or
• Show a minimal runnable example of the exported agent’s structure with the hangup_call integrated.
Which would you like next?