why my agent providing me the heigh latency
# ask-ai
l
why my agent providing me the heigh latency
t
Thanks for reaching out, Pavan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help troubleshoot the high latency. To narrow the cause, could you share a few quick details? • Where is your agent deployed (cloud provider and region)? • What instance type are you using (e.g., t3/t4, m5, c5)? • Are you seeing any specific errors or timeouts (example:
TimeoutError
in
_bounce_eou_task
)? • Do you have recent latency metrics (TTFT, TTFB, turn detection latency) or CloudWatch
CPUCreditBalance
if on AWS? • Is the agent colocated with your LLM/STT/TTS providers or calling public inference endpoints? If you prefer, paste one log snippet showing the latency or error and I’ll point to the most likely cause and next steps. Sources: examples/frontdesk | livekit/livekit_composite | DeepWiki | Agents Framework | livekit/livekit_composite | DeepWiki | How can I reduce latency in voice agents using STT, TTS and LLM? | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS | Introducing LiveKit Inference: A unified model interface for voice AI
l
i am using sarvam for stt and tts google llm i have deply agent in livekit cloud
t
Thanks — that helps. You're using Sarvam for STT/TTS, Google LLM, and your agent is deployed on LiveKit Cloud. I’ll focus troubleshooting on that setup. A few targeted checks will quickly narrow the cause — please share any you can: • Region: which cloud region is your LiveKit Cloud agent deployed in? • Provider proximity: are your Sarvam and Google LLM endpoints in the same region as your LiveKit agent? • Latency metrics: recent TTFT, TTFB, and turn-detection latency (or approximate response times you observe) • Errors/logs: any timeout errors (e.g.,
_bounce_eou_task
TimeoutError) or long EOU detection ( >1s ) • Instance info: if you know instance family (burstable like t3/t4 vs non-burstable like m5/c5) • Traffic pattern: intermittent spikes or consistently high latency? • Number of agent workers: how many workers run for this agent_name? If you prefer, paste one representative log snippet or the last 60s of metrics and I’ll point to the most likely cause and exact next steps (region colocation, switching instance type, scaling workers, or using provisioned inference).
l
region age defrent but latency is so much heigh
t
Thanks — that helps. Since your agent is in a different region than Sarvam and Google LLM, region distance is very likely causing the high latency. I can help pinpoint and fix it — please provide the following so I can recommend the best next steps: • Exact LiveKit Cloud region where your agent is deployed • Regions/endpoints for Sarvam (STT/TTS) and Google LLM you’re calling • Recent latency metrics if available: TTFT, TTFB, turn-detection latency (or approximate response times) • Any error logs or timeout messages (example:
TimeoutError
in
_bounce_eou_task
) • Whether latency is constant or occurs during traffic spikes • Number of agent workers running for this
agent_name
If you can’t pull metrics, paste one representative log snippet showing latency/timeout and I’ll identify the most likely cause and concrete fixes (region colocation, switching instance types, adding workers, or using provisioned inference).
l
how to remove agent from livekit cloud
t
You're asking how to remove an agent from LiveKit Cloud — here’s the quick way. 1. Authenticate to your LiveKit Cloud project with the
lk
CLI. 2. Run:
Copy code
lk agent delete --id=<agent-id>
If you have a
livekit.toml
in the current directory, the CLI will read the agent ID from that file and you can omit
--id
. Notes: • This deletes the deployed agent and stops new requests, but does not remove rooms or recordings. • If you redeploy later, update any dispatch rules or frontend integrations as needed. Tell me the agent ID if you want and I can confirm the exact command for your setup. Sources: Deploying to production | LiveKit Docs | Agents (Python) | livekit/livekit_composite | DeepWiki
l
CA_rzUFMySjj8gE
t
Thanks — I’ve got the agent ID: CA_rzUFMySjj8gE. To remove that agent from LiveKit Cloud, run the
lk
CLI delete command:
Copy code
lk agent delete --id=CA_rzUFMySjj8gE
If you have a
livekit.toml
in the current directory that already contains that agent ID, you can run:
Copy code
lk agent delete
Reminder: this stops and deletes the deployed agent but does not delete rooms or recordings. Would you like me to walk you through authenticating the CLI or confirm any other cleanup steps first?
l
command for live logs
t
You're asking for the command to view live logs for your agent (ID: CA_rzUFMySjj8gE). To stream real-time deploy logs:
Copy code
lk agent logs --id=CA_rzUFMySjj8gE
To view build logs:
Copy code
lk agent logs --id=CA_rzUFMySjj8gE --log-type=build
If your
livekit.toml
contains the agent ID, you can omit
--id
. Want me to show how to authenticate the CLI before running these? Sources: Deploying to production | LiveKit Docs
l
how many region are avilable in livekit for agent deployment
t
LiveKit supports 17 regions for agent deployment: • Australia • Brazil • France • Germany • India • India 2 • Israel • Japan • Saudi Arabia • Singapore • South Africa • Switzerland • UAE • UK • US Central • US East • US West You can specify a region with the CLI
--region
flag when deploying. Would you like help choosing the best region for Sarvam and Google LLM colocation? Sources: LiveKit | Examples | livekit/livekit_composite | DeepWiki | LiveKit Pricing
l
{"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 507.29296875, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121110.788716+00:00"} i am geting this in livkit cloud
t
Thanks — I see the warning in LiveKit Cloud showing memory_usage_mb: 507.29 (warn threshold 500 MB) for job AJ_cAYjG6GkAmhj in room RM_4BVxXu5pgQP5. That means the agent process is nearing the warning threshold but isn't yet killed. Recommended next steps (quick): 1. Check whether this is transient or persistent: ◦ Run live logs to watch memory over time:
Copy code
lk agent logs --id=CA_rzUFMySjj8gE --follow --job-id=AJ_cAYjG6GkAmhj
1. If memory stays high or grows across sessions: ◦ Reuse loaded models across jobs via
proc.userdata
(avoid reloading per session). ◦ Clear large buffers/objects after use (audio frames, transcript buffers). ◦ Ensure you don't retain long-lived references, listeners, or background tasks. 1. If your workload regularly exceeds ~500 MB: ◦ Deploy multiple agent workers under the same
agent_name
to spread load. ◦ Consider offloading heavy models to external inference services if possible. 1. Investigate leaks: ◦ Run a stress test of repeated sessions locally and watch memory growth. ◦ Check for closures, globals, or unremoved event handlers that accumulate state. 1. If you want immediate relief: ◦ Restart the agent worker instance to reclaim memory (temporary). ◦ I can help craft a minimal log capture or suggest code snippets to safe-guard model loading. Which would you like to do next: stream the live logs now, share the relevant agent code where models are loaded, or scale/add workers? Sources: Deploying to production | LiveKit Docs | Agents Framework | livekit/livekit_composite | DeepWiki | How to Get Help from LiveKit
l
{"message": "WebSocket session completed successfully", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293665146192, "connection_state": "connected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "3bf343825b0c", "server_request_id": "20251224_a48fea95-5cf6-4165-9045-fbc6ab6e36e4", "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121045.662375+00:00"} {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 510.1484375, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121045.777481+00:00"} {"message": "_SegmentSynchronizerImpl.resume called after close", "level": "WARNING", "name": "livekit.agents", "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121049.437313+00:00"} {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 507.28515625, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121050.779557+00:00"} {"message": "Starting TTS WebSocket session", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293720057936, "connection_state": "disconnected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "9658b6a390ea", "server_request_id": null, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121051.771629+00:00"} {"message": "WebSocket connected successfully", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293720057936, "connection_state": "connected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "9658b6a390ea", "server_request_id": null, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121051.771803+00:00"} {"message": "WebSocket session completed successfully", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293720057936, "connection_state": "connected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "9658b6a390ea", "server_request_id": "20251224_a48fea95-5cf6-4165-9045-fbc6ab6e36e4", "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121053.170345+00:00"} {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 507.26953125, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121055.782856+00:00"} {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 507.26953125, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121100.784860+00:00"} {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 507.29296875, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121105.787253+00:00"} {"message": "Starting TTS WebSocket session", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293716537360, "connection_state": "disconnected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "27707eaefa1a", "server_request_id": null, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121107.952373+00:00"} {"message": "WebSocket connected successfully", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293716537360, "connection_state": "connected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "27707eaefa1a", "server_request_id": null, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121107.952540+00:00"} {"message": "WebSocket session completed successfully", "level": "INFO", "name": "livekit.plugins.sarvam.log", "session_id": 140293716537360, "connection_state": "connected", "model": "bulbul:v2", "speaker": "anushka", "client_request_id": "27707eaefa1a", "server_request_id": "20251224_a48fea95-5cf6-4165-9045-fbc6ab6e36e4", "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121110.033519+00:00"} {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 507.29296875, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 145, "job_id": "AJ_cAYjG6GkAmhj", "room_id": "RM_4BVxXu5pgQP5", "timestamp": "2025-12-24T121110.788716+00:00"} scanner error: read tcp 192.168.31.12955118 &gt;130.162.234.21443: wsarecv: An existing connection was forcibly closed by the remote host. i am running only one agent
t
Thanks — I see the logs you pasted: repeated Sarvam TTS/STT sessions complete successfully, but the agent process repeatedly logs memory warnings around ~507 MB (warn threshold 500 MB) for job AJ_cAYjG6GkAmhj, plus a scanner WebSocket error: "connection was forcibly closed by the remote host." You also said you’re running only one agent. Recommended next steps (quick and actionable): 1. Stream the live logs now to confirm trend and timing:
Copy code
lk agent logs --id=CA_rzUFMySjj8gE --follow --job-id=AJ_cAYjG6GkAmhj
1. Immediate mitigations ◦ Restart the agent worker to reclaim memory (temporary fix). ◦ If Sarvam sessions are short-lived, limit concurrent TTS/STT requests per job to avoid accumulating buffers. 1. Short-term code fixes to reduce memory ◦ Reuse any loaded model/clients across jobs via
proc.userdata
instead of re-creating per request. ◦ Explicitly clear large buffers after each TTS/STT call (audio frame arrays, transcript buffers). ◦ Remove/unregister any event listeners or background tasks when a session ends. 1. Investigate the WebSocket scanner error ◦ That error often indicates the remote Sarvam endpoint closed the connection. Check network stability between LiveKit Cloud and Sarvam and whether Sarvam rate-limits or closes idle connections. ◦ In your client code, add retry/backoff for WebSocket connects and handle abrupt closes gracefully. 1. If memory stays >500 MB under normal load ◦ Deploy multiple workers under the same
agent_name
to spread load. ◦ Offload heavy processing (large models) to an external inference service if possible. 1. Diagnostic info to share if you want deeper help ◦ A short code snippet showing how you create/use Sarvam client and models ◦ Whether you create model instances per session or reuse via
proc.userdata
◦ Frequency/concurrency of TTS calls per job ◦ Any recent changes before warnings started Which would you like to do next — stream logs now, restart the worker, or share the Sarvam client code so I can suggest exact changes?
l
how to restart the agent
t
To restart your agent on LiveKit Cloud you can either update secrets (which triggers a restart) or redeploy. Use one of these CLI commands: 1. Trigger a restart by updating secrets:
Copy code
lk agent update-secrets --id=CA_rzUFMySjj8gE --secrets "DUMMY_KEY=dummy_value"
1. Redeploy the agent (graceful restart with new version):
Copy code
lk agent deploy --id=CA_rzUFMySjj8gE
If your
livekit.toml
contains the agent ID, you can omit
--id
. Would you like me to show the exact command to authenticate the CLI first? Sources: Deploying to production | LiveKit Docs | Agents (Python) | livekit/livekit_composite | DeepWiki
l
how to restart agent
t
To restart your agent on LiveKit Cloud you can either trigger a restart by updating secrets or redeploy the agent. Use one of these commands: 1) Trigger restart by updating secrets (no code change):
Copy code
lk agent update-secrets --id=CA_rzUFMySjj8gE --secrets "DUMMY_KEY=dummy_value"
2) Redeploy (graceful restart with new version):
Copy code
lk agent deploy --id=CA_rzUFMySjj8gE
If your
livekit.toml
contains the agent ID, you can omit
--id
. Do you want the exact steps to authenticate the CLI first or me to run through either option with you?
l
PS C:\Codeshastra_Projects\hamariai-health\api\services\agent-runner> lk agent deploy --id=CA_gzupQmze3V3S Incorrect Usage: flag provided but not defined: -id flag provided but not defined: -id
t
You're seeing the CLI error because the LiveKit CLI expects the
--id
flag with a space (not
--id=...
). Use one of these options: 1) Redeploy (graceful restart):
Copy code
lk agent deploy --id CA_gzupQmze3V3S
2) Trigger restart by updating secrets:
Copy code
lk agent update-secrets --id CA_gzupQmze3V3S --secrets "DUMMY_KEY=dummy_value"
3) If you have a
livekit.toml
containing the agent id, omit `--id`:
Copy code
lk agent deploy
# or
lk agent update-secrets --secrets "DUMMY_KEY=dummy_value"
If you still get errors, run:
Copy code
lk --version
lk cloud auth
lk project list
and paste the outputs so I can verify your CLI version and authentication. Which would you like to try now? Sources: Deploying to production | LiveKit Docs | server-sdk-go | livekit/livekit_composite | DeepWiki