polite-dog-12152
11/18/2025, 2:54 PMtall-airline-16756
11/18/2025, 2:54 PMtall-airline-16756
11/18/2025, 2:54 PMpolite-dog-12152
11/18/2025, 2:55 PMtall-airline-16756
11/18/2025, 2:55 PMpolite-dog-12152
11/18/2025, 3:22 PMtall-airline-16756
11/18/2025, 3:23 PMpolite-dog-12152
11/18/2025, 3:46 PMtall-airline-16756
11/18/2025, 3:47 PMfrom livekit.plugins import openai
from livekit.agents import AgentSession
# Using Letta for persistent memory across conversations
session = AgentSession(
llm=openai.LLM.with_letta(
agent_id="agent-your-agent-id", # Must begin with "agent-"
base_url="https://api.letta.com/v1/voice-beta", # Optional: defaults to Letta Cloud
),
# ... other components (tts, stt, vad, etc.)
)
• Basic Session Context (Transient Memory):
from livekit.agents import AgentSession
# Basic session with transient memory
session = AgentSession(
llm="openai/gpt-4.1-mini", # Uses session context automatically
# ... other components
)
• RAG-Based External Memory:
async def enrich_with_rag(query: str):
# Perform RAG lookup (replace with your vector DB/knowledge base)
retrieved_context = await your_knowledge_base.search(query)
return retrieved_context
For a reliable and easy-to-set-up persistent memory, I highly recommend the Letta plugin. It’s designed to handle memory management smoothly, so you can focus more on what matters most.
Sources: src/llama-memory-hybrid.h | External data and RAG | LiveKit Docs | Letta LLM plugin guide | LiveKit docs | Large language models (LLM) | LiveKit Docs | delay-handling/README.mdocpolite-dog-12152
11/18/2025, 3:50 PMtall-airline-16756
11/18/2025, 3:51 PMllama.cpp. This gives you great control over memory management, including fast KV caching and handling recurrent states efficiently.
• Enable Recurrent Memory: You can utilize llama_memory_recurrent for effective memory reuse in state-space models. Here's a simple example:
llama_memory_recurrent mem(
model,
std::move(filter),
GGML_TYPE_F32, // type_r
GGML_TYPE_F32, // type_s
true, // offload tensors to GPU
2048, // mem_size
1 // n_seq_max
);
• Optimize Memory Parameters: Tweaking KV cache types and memory size during context initialization can help you reduce memory usage and boost throughput.
• Preserve Conversational State: Using state_write() and state_read() allows you to save and restore memory states between sessions, keeping your conversations smooth and continuous.
For real-time applications, combining LiveKit’s agent pipeline with `llama.cpp`’s memory subsystem is a fantastic way to ensure low-latency and memory-efficient performance.
Sources: ggml/src/ggml-vulkan/ggml-vulkan.cpp | Pipeline nodes and hooks | LiveKit docs | Large language models (LLM) | LiveKit Docspolite-dog-12152
11/19/2025, 7:37 AMtall-airline-16756
11/19/2025, 7:37 AMpip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
1. Set the OTLP Exporter Endpoint: Next, you'll want to set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable to your new backend's OTLP ingestion URL. If your backend requires authentication, you can also set the OTEL_EXPORTER_OTLP_HEADERS variable with the necessary headers.
2. Configure the Tracer Provider: Here’s a simple code snippet to help you set up the new backend:
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from livekit.agents.telemetry import set_tracer_provider
def setup_custom_telemetry_backend(endpoint: str, headers: dict = None):
trace_provider = TracerProvider()
# Configure OTLP exporter
exporter = OTLPSpanExporter(
endpoint=endpoint,
headers=headers # e.g., {"Authorization": "Bearer xyz"}
)
trace_provider.add_span_processor(BatchSpanProcessor(exporter))
# Apply to LiveKit
set_tracer_provider(trace_provider)
# Usage
setup_custom_telemetry_backend(
endpoint="https://your-otel-backend.com/v1/traces",
headers={"Authorization": "Bearer your-token"}
)
1. Call Early in the Application: To make sure you capture all telemetry data, please call set_tracer_provider before starting the agent session.
This setup works wonderfully with any OpenTelemetry-compatible backend like Honeycomb, Datadog, Jaeger, or AWS X-Ray. If you need more details about endpoint URLs or authentication, your backend’s documentation is a great resource.
Sources: Logs, metrics, and telemetry | LiveKit Docs | livekit-agents/livekit/agents/telemetry/__init__.pypolite-dog-12152
11/20/2025, 8:18 AMtall-airline-16756
11/20/2025, 8:19 AMsilero_vad.onnx. By default, this file is conveniently loaded from the package resources located at:
livekit.plugins.silero.resources / "silero_vad.onnx"
If you'd like to use your own custom model, no worries! You can simply specify the file path with the onnx_file_path parameter in VAD.load(). Just make sure that the path you provide points to a valid .onnx file.
Sources: livekit-plugins/livekit-plugins-silero/livekit/plugins/silero/__init__.pypolite-dog-12152
11/21/2025, 3:59 AMtall-airline-16756
11/21/2025, 4:00 AMSessionManager correctly tracks and synchronizes states like "active" and "escalated" to avoid incorrect behavior during transfers.
• Error Handling: Handle failures during SIP calls or room merging gracefully by notifying the user and resuming the session.
• Hold Management: Use start_hold() and stop_hold() to manage audio input/output and play hold music during the transfer.
• Room Lifecycle: Properly clean up event listeners and agent sessions after merging rooms to prevent memory leaks or duplicate callbacks.
• Supervisor Unavailability: Detect voicemail or unavailability using tools like voicemail_detected and implement fallback logic.
• Telephony Setup: Ensure SIP trunk and API credentials are correctly configured for outbound calls.
• Room Naming: Use consistent room names and participant identities to avoid conflicts during room merging.
Review these areas in your implementation to identify potential issues and ensure smooth call transfers.
Sources: examples/voice_agents/error_callback.py | Agent-assisted warm transfer | LiveKit docspolite-dog-12152
11/21/2025, 4:07 AMtall-airline-16756
11/21/2025, 4:07 AMawait session.start(agent, room) before performing any actions like say() or transfer_call.
2. Check Session State: Verify that the session is active using self.session.started or self.session.activity before invoking methods.
3. Avoid Premature Closure: Ensure no aclose() or close() calls are made on the session before the transfer completes.
4. Validate API Credentials: Confirm that LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET are correctly set.
5. Follow Warm Transfer Best Practices: Maintain the customer session, place the user on hold, and merge rooms only after the supervisor answers.
These steps should help resolve the issue and ensure smooth call transfers. Let me know if you need further assistance!
Sources: telephony/warm_handoff.py | livekit-agents/livekit/agents/voice/agent.py | Agents telephony integration | LiveKit Docs | SIP troubleshooting guide | LiveKit docs | Agent-assisted warm transfer | LiveKit docspolite-dog-12152
11/21/2025, 5:38 AMtall-airline-16756
11/21/2025, 5:39 AMcurrent_speech = self.session.current_speech
if current_speech:
await current_speech.wait_for_playout()
1. Interrupt Speech: Stop the agent's speech immediately using:
self.session.interrupt()
self.session.input.set_audio_enabled(False)
self.session.output.set_audio_enabled(False)
1. Use Hold Management: Place the caller on hold during the transfer process and disable audio input/output:
self.session.input.set_audio_enabled(False)
self.session.output.set_audio_enabled(False)
# Optionally play hold music
These methods ensure the agent stops speaking during or after the transfer process. Let me know if you need further assistance!
Sources: agent.py | Text and transcriptions | LiveKit docs | agent.py | Agent-assisted warm transfer | LiveKit docs | Agent speech and audio | LiveKit docspolite-dog-12152
11/21/2025, 5:58 AMtall-airline-16756
11/21/2025, 5:58 AMcustomer_session.input.set_audio_enabled(False)
customer_session.output.set_audio_enabled(False)
1. Play Hold Music: Use BackgroundAudioPlayer to play an audio file:
self.background_audio = BackgroundAudioPlayer()
await self.background_audio.start(room=self.customer_room, agent_session=self.customer_session)
self.hold_audio_handle = self.background_audio.play(AudioConfig("hold_music.mp3", volume=0.8), loop=True)
1. Stop Hold Music and Restore Audio: When the transfer is complete or fails, stop the music and re-enable audio:
if self.hold_audio_handle:
self.hold_audio_handle.stop()
self.hold_audio_handle = None
customer_session.input.set_audio_enabled(True)
customer_session.output.set_audio_enabled(True)
This ensures a smooth experience by providing continuous hold music and managing audio states effectively. Let me know if you need further assistance!
Sources: examples/warm-transfer/README.md | Agent-assisted warm transfer | LiveKit docspolite-dog-12152
11/21/2025, 6:18 AMtall-airline-16756
11/21/2025, 6:19 AMawait self.say("Transferring you now...")
await self.session.current_speech.wait_for_playout()
await self.transfer_call(identity, transfer_number)
1. Close the Agent Session: For cold transfers, close the session immediately after initiating the transfer:
await self.transfer_call(identity, transfer_number)
await self.context.delete_room()
1. Avoid Queued Messages: Ensure no say() or generate_reply() calls are scheduled after the transfer to prevent unintended speech.
These steps ensure the agent does not speak after the transfer process. Let me know if you need further assistance!
Sources: agent.py | sip-refer/README.mdoc | agent.py | Agent-assisted warm transfer | LiveKit docs | livekit-agents/livekit/agents/voice/agent_session.pypolite-dog-12152
11/21/2025, 7:14 AMtall-airline-16756
11/21/2025, 7:14 AMSIP_TRUNK_ID is valid.
2. Use AI-to-AI Transfers Where Possible: For internal routing, use agent-to-agent context transfer instead of SIP to avoid telephony stack issues.
3. Implement Proper Session Cleanup: Close agent sessions after merging rooms, remove event listeners, and clean up hold audio handles to prevent resource leaks.
4. Handle Voicemail Proactively: Use voicemail_detected() to fail early and avoid indefinite waiting during transfers.
5. Monitor SIP Errors: Check for 408 Request Timeout or other SIP-related errors in logs, which may indicate provider limitations or misconfigurations.
Let me know if you need further assistance with debugging specific transfer scenarios or implementing these recommendations.
Sources: agents/src/llm/provider_format/google.test.ts | SIP troubleshooting guide | LiveKit docs | Agent-assisted warm transfer | LiveKit docs | examples/warm-transfer/warm_transfer.py | agent.pypolite-dog-12152
11/21/2025, 7:15 AMtall-airline-16756
11/21/2025, 7:16 AMawait self.session.say() to inform the user of the transfer.
2. Complete the Transfer: Use transfer_sip_participant for cold transfers or multi-room bridging for warm transfers.
3. Close the Agent Session: Call await self.session.aclose() or self.session.shutdown(drain=True) to stop the agent and release resources.
This ensures the agent does not continue interacting after the transfer. Let me know if you need further assistance!
Sources: examples/voice_agents/error_callback.py | Job lifecycle | LiveKit docs | Call forwarding | LiveKit docs | README.mdpolite-dog-12152
11/22/2025, 4:08 PMtall-airline-16756
11/22/2025, 4:09 PMautoscaling:
enabled: true
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 60
• Agent Scaling: LiveKit Cloud provides elastic agent scaling and stateful load balancing to handle voice or video agent sessions efficiently.
• Regional Distribution: Use LiveKit's global infrastructure to minimize latency by connecting participants to the nearest SFU.
Let me know if you need help with a specific scaling approach or configuration!
Sources: Deploy and scale agents on LiveKit Cloud | Deploying to production | LiveKit Docs | delay-handling/raw_data.txt | LiveKit Server Platform | livekit/livekit_composite | DeepWiki | Deploying LiveKit | LiveKit docspolite-dog-12152
11/22/2025, 4:29 PMtall-airline-16756
11/22/2025, 4:30 PMfrom livekit.plugins import speechmatics
stt = speechmatics.STT(
language='en',
enable_partials=True # Default is True
)
1. Handle Transcripts on the Frontend: Use registerTextStreamHandler to listen for transcription events:
room.localParticipant.registerTextStreamHandler('lk.transcription', (stream, info) => {
stream.on('data', (text) => {
const isFinal = info.attributes['lk.transcription_final'] === 'true';
if (isFinal) {
transcriptElement.textContent = text;
} else {
livePreviewElement.textContent = text;
}
});
});
1. Handle Transcripts on the Agent Side: Listen for user_input_transcribed events to process partial transcripts:
@session.on("user_input_transcribed")
def on_transcript(transcript):
if not transcript.is_final:
print(f"Partial: {transcript.transcript}")
else:
print(f"Final: {transcript.transcript}")
This setup ensures real-time partial transcription updates for both frontend and backend processing. Let me know if you need further assistance!
Sources: Speechmatics STT plugin guide | LiveKit Docs | livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.p... | pipeline-stt/transcriber/README.md | Text and transcriptions | LiveKit docs | Agent Session Management & Turn Detection | livekit/livekit_composite | Dee...polite-dog-12152
11/22/2025, 4:34 PMtall-airline-16756
11/22/2025, 4:34 PMstt = speechmatics.STT(
language='en',
enable_partials=True,
max_delay=0.7, # Reduce delay for faster interim results
end_of_utterance_silence_trigger=0.3
)
1. Stream Audio Efficiently: Use small, frequent chunks (e.g., 10ms at 16kHz) to minimize input lag.
2. Leverage Preemptive Generation: Use partial transcripts to start downstream processing early, reducing response latency.
3. Choose Low-Latency STT Providers: Google Cloud STT and Speechmatics are optimized for fast streaming recognition.
4. Optimize Endpointing: Configure silence detection (e.g., endpointing=0.05) to finalize transcripts quickly after speech ends.
These optimizations ensure faster transcript delivery and response times. Let me know if you need further assistance!
Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Speechmatics STT plugin guide | LiveKit Docs | Live Conversations with AI using ChatGPT and WebRTC | Operational Best Practices | livekit/livekit_composite | DeepWikipolite-dog-12152
11/22/2025, 4:35 PMtall-airline-16756
11/22/2025, 4:36 PMfrom livekit.plugins import aws
stt = aws.STT(
language="en-US",
enable_partial_results_stabilization=True,
partial_results_stability="high",
sample_rate=24000,
vocabulary_name="my-vocabulary",
vocab_filter_name="my-vocab-filter",
vocab_filter_method="mask"
)
1. Leverage AWS Regional Optimization: Deploy services in AWS regions closest to your users to minimize latency.
2. Integrate Additional AWS Services: Use Amazon Polly for TTS, Amazon Bedrock for LLMs, and Amazon Nova Sonic for real-time speech-to-speech processing.
3. Enable Auto-scaling: Configure horizontal pod autoscaling in AWS EKS to handle varying loads efficiently.
4. Monitor Performance: Track session restarts and latency metrics to identify bottlenecks and optimize configurations.
These steps ensure faster processing and improved performance for LiveKit deployments using AWS. Let me know if you need further assistance!
Sources: examples/server-eks.yaml | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Amazon Transcribe plugin guide | LiveKit Docs | AWS AI and LiveKit | LiveKit Docspolite-dog-12152
12/05/2025, 5:38 AMtall-airline-16756
12/05/2025, 5:39 AMpolite-dog-12152
12/05/2025, 5:40 AMtall-airline-16756
12/05/2025, 5:40 AMpolite-dog-12152
12/05/2025, 5:41 AMtall-airline-16756
12/05/2025, 5:41 AMfrom livekit.plugins import aws
stt = aws.STT(
sample_rate=8000, # Set to 8kHz for telephone audio
language="en-US", # Adjust language as needed
encoding="pcm" # Default encoding
)
Ensure your AWS credentials are properly configured and the plugin is installed. You can also use additional parameters like vocabulary_name for domain-specific terms or vocab_filter_name to filter specific words.
Let me know if you need help with real-time streaming transcription, batch processing, or other specific configurations!
Sources: livekit-plugins/livekit-plugins-gladia/livekit/plugins/gladia/stt.py | HD voice for SIP | LiveKit docs | Amazon Transcribe plugin guide | LiveKit Docs