DEBUG:websockets.client:> TEXT '{"realtime_inpu...
# ask-ai
b
DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "_..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "_..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "_..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client< BINARY 7b 0a 20 20 22 73 65 72 76 65 72 43 6f 6e 74 65 ... 5d 0a 20 20 7d 0a 7d 0a [453 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "_..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client< BINARY 7b 0a 20 20 22 73 65 73 73 69 6f 6e 52 65 73 75 ... 65 0a 20 20 7d 0a 7d 0a [138 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "_..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "_..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] DEBUGwebsockets.client> TEXT '{"realtime_input": {"mediaChunks": [{"data": "A..._type": "audio/pcm"}]}}' [2213 bytes] INFOlivekit.agentsclosing agent session due to participant disconnect (disable via
RoomInputOptions.close_on_disconnect=False
) INFOlivekit.agentsclosing agent session due to participant disconnect (disable via
RoomInputOptions.close_on_disconnect=False
) {"message": "closing agent session due to participant disconnect (disable via
RoomInputOptions.close_on_disconnect=False
)", "level": "INFO", "name": "livekit.agents", "participant": "sip_+16193049830", "reason": "CLIENT_INITIATED", "pid": 1897171, "job_id": "AJ_7uBsRmtPG7N4", "timestamp": "2025-08-19T072325.812914+00:00"} DEBUGlivekit.agentsstream closed DEBUGlivekit.agentsinput stream detached DEBUGlivekit.plugins.googlesend task finished. DEBUGwebsockets.client> CLOSE 1000 (OK) [2 bytes] DEBUGwebsockets.client= connection is CLOSING DEBUGwebsockets.client< CLOSE 1000 (OK) [2 bytes] DEBUGwebsockets.client< EOF DEBUGwebsockets.client> EOF DEBUGwebsockets.client= connection is CLOSED DEBUGwebsockets.clientx closing TCP connection DEBUGlivekit.agentssession closed DEBUGlivekit.agentsshutting down job task INFOlivekit.agentsprocess exiting {"message": "process exiting", "level": "INFO", "name": "livekit.agents", "reason": "", "pid": 1897171, "job_id": "AJ_7uBsRmtPG7N4", "timestamp": "2025-08-19T072347.010958+00:00"} DEBUGlivekittungstenite:protocol666tungstenite:protocol - Received close frame: Some(CloseFrame { code: Normal, reason: "" }) DEBUGlivekit.agentshttp_session(): closing the httpclient ctx DEBUGlivekit.agentshttp_session(): creating a new httpclient ctx i want to turn off the logs
t
Thanks for reaching out, Aman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To disable logs in LiveKit, it really depends on which SDK or component you're working with: • Flutter SDK: You can use
disableLogging()
or
setLoggingLevel(LoggerLevel.kOFF)
. • Android SDK: Just set
LiveKit.loggingLevel = LoggingLevel.OFF
. • React Native SDK: Try
setLogLevel("silent")
. • Agents Framework: You’ll want to configure the log level in your Dockerfile, like
CMD ["python", "agent.py", "start", "--log-level=ERROR"]
. If you tell me which SDK or component you’re using, I’d be happy to help you out with more tailored advice! Sources: web/e2ee.logger.dart | livekit-android-test/src/main/java/io/livekit/android/test/util/LoggingRule... | docs/variables/log.html | Log collection | LiveKit Docs | livekit-agents/livekit/agents/cli/log.py
b
Agents Framework
t
To turn off logs in the LiveKit Agents Framework, you can simply set the log level in your Dockerfile. For example:
Copy code
CMD ["python", "agent.py", "start", "--log-level=ERROR"]
This way, you'll only see error messages. If you have any questions or need a hand with this, just let me know!
b
i am using the below command t$ python3 -m teliphoney_agent_v2 start ans my code is below import asyncio import os from dotenv import load_dotenv import json import re from livekit.rtc import ParticipantKind from livekit import agents from livekit.agents import AgentSession, Agent, RoomInputOptions, cli from livekit.plugins import ( noise_cancellation, google ) from livekit.agents import ( Agent, AgentSession, JobContext, WorkerOptions, cli, function_tool ) # from app.prompt_services import prompts # from app.tool_services import LK_room_tools # from app.resources.constants import get_constant load_dotenv() # import time # from app.db_implementations.mongo_implementation import MongoDBClient # from app.prompt_services.archives.prompt_services import get_bot_system_prompt from app.bot_config import BotConfig # Global variables to store context and session for call termination _ctx = None _session = None _call_sid = None # Store the extracted Call SID # client = MongoDBClient("teliphoney_bot_v1_db") def extract_call_sid_from_participant(participant, room_name): """ Extract Call SID from various sources in order of preference: 1. Participant metadata (JSON format) 2. Participant metadata (raw string) 3. Participant identity 4. Room name pattern 5. SIP headers (if available) """ call_sid = None if participant.kind == ParticipantKind.SIP: call_sid = participant.attributes.get('sip.twilio.callSid') if call_sid: print(f"Call SID: {call_sid}") else: print("Call SID not found in participant attributes.") print(f"🔍 Attempting to extract Call SID for participant: {participant.identity}") # Method 1: Try parsing metadata as JSON if participant.metadata: print(f"📋 Raw metadata: '{participant.metadata}'") try: metadata = json.loads(participant.metadata) print(f"📋 Parsed metadata: {metadata}") # Check various possible key names for Call SID possible_keys = ['callSid', 'call_sid', 'CallSid', 'CALL_SID', 'twilio_call_sid', 'sid'] for key in possible_keys: if key in metadata: call_sid = metadata[key] print(f"🔥 CALL SID found in metadata['{key}']: {call_sid}") return call_sid except json.JSONDecodeError: print("⚠️ Metadata is not valid JSON, trying as raw string") # Method 2: Search for Call SID pattern in raw metadata string # Twilio Call SIDs typically start with 'CA' followed by 32 hex characters call_sid_pattern = r'CA[a-f0-9]{32}' match = re.search(call_sid_pattern, participant.metadata, re.IGNORECASE) if match: call_sid = match.group(0) print(f"🔥 CALL SID found in raw metadata: {call_sid}") return call_sid # Method 3: Check participant identity for Call SID if participant.identity: print(f"🆔 Checking participant identity: {participant.identity}") call_sid_pattern = r'CA[a-f0-9]{32}' match = re.search(call_sid_pattern, participant.identity, re.IGNORECASE) if match: call_sid = match.group(0) print(f"🔥 CALL SID found in participant identity: {call_sid}") return call_sid # Method 4: Extract from room name pattern # Assuming room name might contain Call SID print(f"🏠 Checking room name: {room_name}") call_sid_pattern = r'CA[a-f0-9]{32}' match = re.search(call_sid_pattern, room_name, re.IGNORECASE) if match: call_sid = match.group(0) print(f"🔥 CALL SID found in room name: {call_sid}") return call_sid # Method 5: Check for any other patterns that might be Call SID # Sometimes the last part of room name could be Call SID room_parts = room_name.split('_') for part in room_parts: if len(part) >= 30: # Call SIDs are typically 34 characters print(f"🔍 Potential Call SID candidate: {part}") # You can add more validation here if part.startswith('CA') or len(part) == 34: call_sid = part print(f"🔥 POTENTIAL CALL SID from room parts: {call_sid}") return call_sid print(" No Call SID found in any source") return None async def entrypoint(ctx: agents.JobContext): global _ctx, _session, _call_sid _ctx = ctx # Store context globally for end_call function system_prompt = """ you are a helpful assistant your name is Summer instructions:- before ending the call say it was nice talking to you and then use the end_call function when the conversation is complete or the caller wants to hang up, always call the end_call function """ print("room_name", ctx.room) print("building prompt") parts = str(ctx.room.name).split("_") bot_id = parts[1] if len(parts) > 1 else "unknown" caller_number = parts[2] if len(parts) > 2 else "unknown" print("initializing bot config for bot_id:", bot_id) bot_config = BotConfig(bot_id) system_prompt=bot_config.get_prompt() await ctx.connect() # Enhanced participant event listener def on_participant_connected(participant): global _call_sid print(f"👤 Participant connected: {participant.identity}") print(f"📞 Participant kind: {participant.kind}") print(f"📋 Participant metadata: '{participant.metadata}'") # Check if it's a SIP participant if participant.kind == 3: # SIP participant type print("🔌 SIP Participant detected!") # Extract Call SID using our comprehensive method _call_sid = extract_call_sid_from_participant(participant, ctx.room.name) if _call_sid: print(f" SUCCESSFULLY EXTRACTED CALL SID: {_call_sid}") # Store Call SID for later use (e.g., in tools for ending call) # You can save this to database or pass to your tools else: print(" Could not extract Call SID from any source") print("🔧 Debug info:") print(f" - Room name: {ctx.room.name}") print(f" - Participant identity: {participant.identity}") # print(f" - ParticipantKind.SIP: {participant.attributes['sip.twilio.callSid']}") print(f" - Participant metadata: '{participant.metadata}'") print(f" - Participant kind: {participant.kind}") else: print(f"👤 Non-SIP participant (kind: {participant.kind})") # Method to get current Call SID # def get_current_call_sid(): # return _call_sid # Register the event listener # ctx.room.on("participant_connected", on_participant_connected) # session_ctx = LK_room_tools.SessionContext(ctx) # You can also pass the Call SID getter to your tools # session_ctx.get_call_sid = get_current_call_sid class AssistantWithNotes(Agent): def __init__(self, prompt="you are a helpful assistant") -> None: super().__init__( instructions=prompt, tools=bot_config.get_tools() ) # Create session and store globally _session = AgentSession( llm=google.beta.realtime.RealtimeModel( model="gemini-2.0-flash-exp", voice="Aoede", temperature=0.8, instructions="start with a greeting", ), ) print("session created") await _session.start( room=ctx.room, agent=AssistantWithNotes(prompt=system_prompt), room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC(), ), ) print("Room created:", ctx.room) await _session.generate_reply( instructions="start with a greeting and say that you have reached <org name>", ) import logging if name == "__main__": # Configure logging for better debugging # logging.basicConfig( # level=logging.INFO, # format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' # ) # Run the agent with the name that matches your dispatch rule cli.run_app(WorkerOptions( entrypoint_fnc=entrypoint, agent_name="telephony_agent", num_idle_processes=3 ))
t
To turn off logs in your current setup, you can tweak the logging configuration in your Python script. What you want to do is set the logging level so it only shows the important stuff. Just add these lines to your script:
Copy code
import logging
logging.basicConfig(level=logging.ERROR, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
This way, you'll only see error messages. If you need any more help, just give me a shout!