i consistently get "Agent did not join call" why?
# ask-ai
b
i consistently get "Agent did not join call" why?
t
Thanks for reaching out, Sebastian. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! The "Agent did not join call" error can happen for a few different reasons—like issues with getting the agent set up, some hiccups in the dispatch configuration, or even authentication troubles. To help you better, could you share a bit more about your setup? • Are you using SIP calls, a custom frontend, or something else? • What kind of agent are you working with (like voice, Python, JS)? • Have you had a chance to peek at the agent logs to see if there are any errors or timeouts? Sources: SIP troubleshooting guide | LiveKit Docs | livekit-plugins/livekit-plugins-bithuman/livekit/plugins/bithuman/avatar.py | LiveKit Agents | WorkerError | LiveKit Agents | complex-agents/drive-thru/frontend/components/session-view.tsx
b
class Assistant(Agent): def __init__(self, custom_instructions: str | None = None) -> None: super().__init__( instructions=custom_instructions, ) def prewarm(proc: JobProcess): proc.userdata["vad"] = silero.VAD.load() _, session_maker = create_engine_and_session() proc.userdata["db_sessionmaker"] = session_maker async def entrypoint(ctx: JobContext): metadata = get_job_metadata(ctx) prompt = metadata.get("prompt") or DEFAULT_INSTRUCTIONS initial_message = metadata.get("initial_message") or DEFAULT_INITIAL_MESSAGE model = metadata.get("model") or DEFAULT_MODEL session = AgentSession( stt=deepgram.STT(model="nova-3", language="en-US"), llm=openai.LLM(model=model), tts=elevenlabs.TTS(voice_id="cjVigY5qzO86Huf0OWal", model="eleven_flash_v2_5"), vad=ctx.proc.userdata["vad"], turn_detection=EnglishModel() ) SessionLocal = ctx.proc.userdata["db_sessionmaker"] agent_config_ref = agent_config_ref_from(metadata) call_uuid = uuid.uuid4() start_ts = time.time() await session.start( agent=Assistant(custom_instructions=prompt), room=ctx.room, room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC() ), ) recording_key = f"{call_uuid}.ogg" await start_recording(ctx, recording_key) await ctx.connect() await session.say( initial_message, add_to_chat_ctx=True, ) async def on_call_end(): duration = int(time.time() - start_ts) transcript = session.history.to_dict() transcript = json.loads(json.dumps(transcript, default=str)) async with SessionLocal() as s: await create_call( s, agent_config_ref, call_id=call_uuid, started_at=datetime.fromtimestamp(start_ts, timezone.utc), ended_at=datetime.now(timezone.utc), duration_seconds=duration, recording_key=recording_key, recording_url=get_recording_url(recording_key), transcript=transcript, ) ctx.add_shutdown_callback(on_call_end) if name == "__main__": cli.run_app( WorkerOptions( entrypoint_fnc=entrypoint, prewarm_fnc=prewarm, agent_name='signalcore-agent', initialize_process_timeout=120 ) ) and start recording is: import json from livekit.agents import JobContext from livekit.protocol.egress import EncodedFileType, S3Upload, StopEgressRequest, RoomCompositeEgressRequest, EncodedFileOutput from constants import ( EGRESS_S3_ACCESS_KEY, EGRESS_S3_BUCKET, EGRESS_S3_REGION, EGRESS_S3_SECRET, ) async def start_recording(ctx: JobContext, filepath: str) -> None: s3_bucket = EGRESS_S3_BUCKET s3_region = EGRESS_S3_REGION s3_access_key = EGRESS_S3_ACCESS_KEY s3_secret = EGRESS_S3_SECRET req = RoomCompositeEgressRequest( room_name=ctx.room.name, audio_only=True, file_outputs=[ EncodedFileOutput( file_type=EncodedFileType.OGG, filepath=filepath, disable_manifest=True, s3=S3Upload( bucket=s3_bucket, region=s3_region, access_key=s3_access_key, secret=s3_secret, ), ) ], ) response = await ctx.api.egress.start_room_composite_egress(req) return response.egress_id async def stop_recording(ctx: JobContext, egress_id: str) -> None: request = StopEgressRequest(egress_id=egress_id) await ctx.api.egress.stop_egress(request) def get_job_metadata(ctx: JobContext) -> dict: if not ctx.job.metadata: return {} try: return json.loads(ctx.job.metadata) except Exception: return {} def agent_config_ref_from(metadata: dict) -> dict: ref = {} url = metadata.get("config_url") commit = metadata.get("config_ref") if url: ref["url"] = url if commit: ref["commit"] = commit return ref def get_recording_url(key: str) -> str: return f"https://{EGRESS_S3_BUCKET}.s3.{EGRESS_S3_REGION}.amazonaws.com/{key}"
t
Hey there! That “Agent did not join call” error usually pops up when there’s a hiccup with your agent’s setup or connection. Looking at your code, here are a few friendly tips to help you troubleshoot: • Authentication: Double-check that your
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
, and
LIVEKIT_URL
are all set correctly. If any of these are missing or off, the agent might not be able to join. • Room Connection: Make sure you’re awaiting
ctx.connect()
before kicking off the agent session. If the room isn’t connected yet, the agent won’t be able to move forward. • Timeouts: Take a peek at the
initialize_process_timeout
in your
WorkerOptions
. Sometimes, if the agent needs a bit more time to get going, increasing this timeout can help. • Logs: Check out your logs for any errors during the agent’s initialization or connection steps. Look for things like timeouts, authentication hiccups, or WebSocket disconnects. • Recording Configuration: Also, double-check the S3 bucket details and credentials you’re using in the
start_recording
function. If something’s off here, it might cause trouble too. If you’re still stuck after trying these, feel free to share the exact error logs or any other info about your setup—like which LiveKit library and Python versions you’re using. I’m here to help you get this sorted! Sources: livekit-agents/livekit/agents/worker.py | Still Have Questions | complex-agents/ivr-agent/agent.py | Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki
b
• also why do i get multiple tries of egress? it says Start signal not received
t
Hey there! The error "Start signal not received" pops up when the egress process is set to wait for a start signal but doesn’t get it in time. This can cause a few retry attempts before the session gives up. Here are some friendly tips to help you out: • Check the
await_start_signal
Configuration:
If you’re using delayed start, make sure the
await_start_signal
flag is turned on in your egress request and that your app is actually sending the start signal like it should. • Disable
await_start_signal
if You Don’t Need It:
If delayed start isn’t part of your plan, turning off this flag can save you from those extra waits and retries. • Take a Look at the Logs: Peek into the egress logs to see why the start signal might be missing. This often helps spot any hiccups in your app’s logic or setup. If you’d like a hand digging deeper, feel free to share your egress setup and any logs you have. I’m here to help! Sources: README.md | Infrastructure & Deployment | livekit/livekit_composite | DeepWiki | rpc/egress_client.go | pkg/routing/signal.go
b
I don't have any special settings activated
t
Hey there! If you’re not using any special settings, the "Start signal not received" error can still pop up because of default configurations or unexpected delays during the egress process. No worries though—here are a few things you can try to troubleshoot: • Verify Egress Request: Double-check that your egress request doesn’t include the
await_start_signal
flag. Sometimes this flag is set by default, which can make the system wait for a signal that isn’t coming. • Check Network and API Connectivity: Make sure the egress service can talk to the LiveKit server smoothly. Network hiccups can sometimes cause delays or block signals. • Review Logs: Take a peek at the egress logs for any errors or warnings that might shed light on why the start signal wasn’t received. This often gives helpful clues. If you’re still stuck after trying these, feel free to share your egress request details or any logs you have. I’m here to help you figure this out!
b
why am i getting , line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/sebastianescudero/Desktop/SignalCore Livekit POC/signalcore-agent/.venv/lib/python3.13/site-packages/livekit/agents/ipc/job_proc_lazy_main.py", line 240, in _traceable_entrypoint await self._job_entrypoint_fnc(job_ctx) File "/Users/sebastianescudero/Desktop/SignalCore Livekit POC/signalcore-agent/src/agent.py", line 153, in entrypoint vad=ctx.proc.userdata["vad"], ~~~~~~~~~~~~~~~~~^^^^^^^ KeyError: 'vad' {"pid": 43352, "job_id": "AJ_6DG6doAnRLov
t
Hey there! The error
KeyError: 'vad'
pops up because the VAD model isn’t properly loaded into
ctx.proc.userdata
before it’s accessed in the entrypoint function. No worries though — here’s how you can fix it: • Prewarm Function: Double-check that your
prewarm
function is loading the VAD model correctly and storing it in
proc.userdata
. For example:
Copy code
def prewarm(proc: JobProcess):
    proc.userdata["vad"] = silero.VAD.load()
• WorkerOptions: Make sure the
prewarm_fnc
is set up in your
WorkerOptions
configuration like this:
Copy code
WorkerOptions(
    entrypoint_fnc=entrypoint,
    prewarm_fnc=prewarm,
    agent_name='signalcore-agent',
    initialize_process_timeout=120
)
• Access in Entrypoint: When you get to the entrypoint function, confirm you’re grabbing the VAD model from
ctx.proc.userdata
like so:
Copy code
vad = ctx.proc.userdata["vad"]
Following these steps will make sure your VAD model is loaded and ready to go when the agent starts. If you’re still running into trouble, feel free to share any updates or logs — I’m here to help! Sources: agent.py | Anatomy of an Agent | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py | agent/main.py