how to create ai agent voice pipeline without usin...
# ask-ai
f
how to create ai agent voice pipeline without using Agents framework
t
Thanks for reaching out, venu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The documentation mainly focuses on creating AI agent voice pipelines with the Agents framework. To help you out better, could you please clarify a few things? • Are you looking to use LiveKit's raw RTC SDKs (like
livekit-rtc
) to manage audio streams yourself? • Which external STT, LLM, and TTS services are you planning to connect with? • Do you need real-time streaming, or would batch processing work for you? Sources: VoicePipelineAgent | LiveKit Docs | agent/main.py | chain-of-thought-tts/agent.py | agents/src/pipeline/pipeline_agent.ts | agent-examples/agent_examples/pipeline_agent.py
f
I want to pass metadata as well as want the agent to join room after user joins . Can I do this using agents framework ?
t
Absolutely! You can pass metadata and have an agent join a room right after a user does using the Agents framework. Here’s how you can do it with explicit agent dispatch: • Agent Joining After User: First, disable automatic dispatch by setting an
agent_name
in
WorkerOptions
. Then, you can use the
AgentDispatchService
to send the agent to the room once the user has joined. Another option is to set up the participant’s access token with a
RoomConfiguration
that includes the agent. • Passing Metadata: Just use the
metadata
field inside the
RoomAgentDispatch
object. This metadata will be available in the agent’s
JobContext.job.metadata
. Using JSON is a great way to keep your data structured and easy to work with. Here’s a quick example of how you might set up a participant token with room configuration:
Copy code
at.roomConfig = new RoomConfiguration({
  agents: [
    new RoomAgentDispatch({
      agentName: 'test-agent',
      metadata: '{"user_id": "123", "name": "Alice"}',
    }),
  ],
});
So, when the user joins with this token, the agent will automatically be dispatched to the room along with the metadata you provided. Pretty handy, right? Sources: examples/agent_dispatch.py | Agent dispatch | LiveKit Docs | Dispatching agents | LiveKit Docs | Dispatching agents | LiveKit Docs | Authentication | LiveKit Docs
f
can you make changes to this code - class Evi(Agent): def __init__(self): super().__init__(instructions=instructions) self.paused = False async def on_enter(self): if not self.paused: await self.session.generate_reply( instructions="Greet the user and ask how you can help them." ) async def on_exit(self): return await super().on_exit() async def handle_pause_state_change(_session_: AgentSession, _is_paused_: bool): print("PAUSED STATE:", _is_paused_) async def start_session(_ctx_: agents.JobContext): logger.info(_f_"Starting session for context: {ctx}") # metadata = json.loads(ctx.job.metadata) # voice_id = metadata.get("voice_id") # session_id = metadata.get("session_id") # logger.info(f"Session ID: {session_id}, Voice ID: {voice_id}") voice_info = VOICE_MAP.get(voice_id, VOICE_MAP["Sophie"]) session_id: str | None = None agent_instance = Evi() session = AgentSession( stt=deepgram.STT(model="nova-3", language="multi"), llm=groq.LLM(model="meta-llama/llama-4-scout-17b-16e-instruct"), tts=cartesia.TTS(model="sonic-2", voice=voice_info["id"], language=voice_info["language"]), vad=ctx.proc.userdata["vad"], _turn_detection_=MultilingualModel(), ) @_ctx_.room.on("participant_attributes_changed") def on_participant_attributes_changed(_changed_attributes_, _participant_: rtc.Participant): if participant.kind != rtc.ParticipantKind.PARTICIPANT_KIND_STANDARD: return if "paused" in _changed_attributes_: is_paused = participant.attributes.get("paused", "false").lower() == "true" asyncio.create_task(handle_pause_state_change(session, is_paused)) logger.info("Agent pause state changed") async def write_to_firestore(): if not session_id: logger.warning("Missing session_id in metadata") return try: items = session.history.to_dict().get("items", []) conversation_text = "\n".join( _f_"{item.get('role','unknown')}: {' '.join(item.get('content', []))}" for item in items if item.get("type") == "message" ) client = OpenAI(_api_key_=os.getenv("OPENAI_API_KEY"), _base_url_="https://api.deepinfra.com/v1/openai") response = client.chat.completions.create( model="meta-llama/Llama-3.2-3B-Instruct", messages=[ {"role": "system", "content": "Summarize this conversation clearly and concisely."}, {"role": "user", "content": conversation_text}, ], _max_tokens_=500, ) summary_text = response.choices[0].message.content session_data = {"id": session_id, "summary": summary_text, "createdAt": firestore.SERVER_TIMESTAMP} db.collection("users").document(ctx.room.id).update({"sessions": firestore.ArrayUnion([session_data])}) logger.info(_f_"✅ Session {session_id} saved to Firestore for user {ctx.room.id}") except Exception as e: logger.error(_f_"Error writing to Firestore: {e}") ctx.add_shutdown_callback(write_to_firestore) await session.start( room=ctx.room, agent=agent_instance, _room_input_options_=RoomInputOptions(audio_enabled=True, video_enabled=False), ) if name == "__main__": agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=start_session, prewarm_fnc=prewarm , ws_url=LIVEKIT_URL, api_key= API_KEY, api_secret= API_SECRET))
t
Thanks for sharing your code! Just to make sure I’m on the right track, could you tell me a bit more about what changes or improvements you’re looking for? For example: • Are you hoping to tweak how the agent behaves, like how it handles pauses or comes up with replies? • Do you want to adjust how metadata is handled or how it connects with Firestore? • Is there a particular error or issue in the code that you’d like some help with?
f
disable agent auto dispatch and read meta data from context
t
Hey there! If you want to disable agent auto-dispatch and read metadata from context in the LiveKit Agents framework, here’s a simple way to do it: 1. Turn Off Automatic Dispatch: Just set the
agent_name
field in
WorkerOptions
when you’re initializing your agent. This little tweak stops auto-dispatch for that agent:
Copy code
opts = WorkerOptions(
    entrypoint_fnc=entrypoint,
    agent_name="my-agent",  # This disables auto-dispatch
)
1. Manually Dispatch Agents with Metadata: You’ll want to dispatch the agent yourself using one of these handy methods: • Dispatch via API: Use the
AgentDispatchService
to create a dispatch request and include your metadata:
Copy code
async def create_explicit_dispatch():
    lkapi = api.LiveKitAPI()
    dispatch = await lkapi.agent_dispatch.create_dispatch(
        api.CreateAgentDispatchRequest(
            agent_name="test-agent",
            room="my-room",
            metadata='{"user_id": "12345"}'
        )
    )
    print("created dispatch", dispatch)
• Dispatch on Participant Connection: Set up the participant’s access token to dispatch the agent with metadata as soon as they join:
Copy code
def create_token_with_agent_dispatch() -> str:
    token = (
        AccessToken()
        .with_identity("my_participant")
        .with_grants(VideoGrants(room_join=True, room=room_name))
        .with_room_config(
            RoomConfiguration(
                agents=[
                    RoomAgentDispatch(
                        agent_name="test-agent",
                        metadata='{"user_id": "12345"}'
                    )
                ],
            ),
        )
        .to_jwt()
    )
    return token
1. Grab Metadata Inside the Agent: When your agent starts, you can access the metadata right in the entrypoint function using
ctx.job.metadata
. Just decode it with
json.loads
to get your structured data:
Copy code
async def entrypoint(ctx: JobContext):
    metadata = json.loads(ctx.job.metadata)
    user_id = metadata["user_id"]
    logger.info(f"Agent started for user: {user_id}")
And that’s it! Following these steps will help you turn off auto-dispatch and work with metadata smoothly. If you have any questions or want to chat more about it, I’m here to help! Sources: Dispatching agents | LiveKit Docs | Dispatching agents | LiveKit Docs | examples/agent_dispatch.py | External data and RAG | LiveKit Docs | External data and RAG | LiveKit Docs
f
if name == "__main__": agents.WorkerOptions(entrypoint_fnc=start_session, prewarm_fnc=prewarm , ws_url=LIVEKIT_URL, api_key= API_KEY, api_secret= API_SECRET) is this fine? or should I include run_app
t
Hey there! When you're working with the LiveKit Agents framework and using
WorkerOptions
, it's super important to include
run_app
. Think of
WorkerOptions
as the setup for your worker, and
run_app
is the friendly helper that actually gets your worker up and running, whether you're developing or deploying. Here's a quick example to guide you:
Copy code
if __name__ == "__main__":
    agents.cli.run_app(
        agents.WorkerOptions(
            entrypoint_fnc=start_session,
            prewarm_fnc=prewarm,
            ws_url=LIVEKIT_URL,
            api_key=API_KEY,
            api_secret=API_SECRET
        )
    )
Doing it this way makes sure your worker starts smoothly and everything runs as expected. Hope this helps! Sources: runApp | LiveKit Agents | agents/src/worker.ts | Worker options | LiveKit Docs | Worker | LiveKit Agents
f
but won't it get automatically dispatched to the room
t
Just a heads-up: when you use
run_app
with
WorkerOptions
and set the
agent_name
field, it won’t automatically send agents to rooms. Setting
agent_name
actually turns off automatic dispatch, so the agent will only join rooms if you explicitly tell it to, like through: • The
AgentDispatchService
API • Setting up participant access tokens • Using SIP dispatch rules Here’s a quick example showing how this disables automatic dispatch:
Copy code
cli.run_app(
    WorkerOptions(
        entrypoint_fnc=entrypoint,
        agent_name="my-agent"  # Disables automatic dispatch
    )
)
On the other hand, if you don’t set
agent_name
, the agent will hop into new rooms automatically. Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | Agents telephony integration | LiveKit Docs | Making calls using SIP | LiveKit Docs | examples/minimal_worker.py
f
ERROR livekit.agents - unhandled exception while running the job task Traceback (most recent call last): File "/Users/venuchoudhary/Developer/freelance/nextpeer_backend/venv/lib/python3.13/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/venuchoudhary/Developer/freelance/nextpeer_backend/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/venuchoudhary/Developer/freelance/nextpeer_backend/agent.py", line 54, in start_session metadata = json.loads(ctx.job.metadata) File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/__init__.py", line 346, in loads return _default_decoder.decode(s) ~~~~~~~~~~~~~~~~~~~~~~~^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/decoder.py", line 345, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/decoder.py", line 363, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0 getting this error
t
Hey there! The
JSONDecodeError
happens because the metadata string you’re passing to the agent isn’t valid JSON. No worries though — here’s a simple way to fix it: 1. Make Sure Your JSON Is Properly Encoded: When you’re dispatching the agent, double-check that the
metadata
field is a valid JSON string. For example:
Copy code
import json
from livekit.api import LiveKitAPI, CreateAgentDispatchRequest

metadata = json.dumps({
    "user_name": "Alice",
    "phone_number": "+1234567890",
    "row_index": 1
})

dispatch = await LiveKitAPI().agent_dispatch.create_dispatch(
    CreateAgentDispatchRequest(
        agent_name="survey-agent",
        room="my-room",
        metadata=metadata
    )
)
1. Handle Metadata Parsing with Care: It’s a good idea to wrap the
json.loads()
call in a try-except block. This way, if the input isn’t quite right, your code can handle it smoothly without crashing:
Copy code
import json
import logging

async def entrypoint(ctx: JobContext):
    logger = logging.getLogger("agent")
    metadata_str = ctx.job.metadata

    try:
        metadata = json.loads(metadata_str)
        user_name = metadata.get("user_name", "Unknown")
        logger.info(f"Successfully parsed metadata for user: {user_name}")
    except json.JSONDecodeError as e:
        logger.error(f"Failed to decode job metadata as JSON: {e}")
        metadata = {}  # Fallback to empty dict or default values

    # Proceed with agent logic using metadata
Following these steps will help make sure your metadata is formatted and parsed correctly, so you won’t run into that
JSONDecodeError
again. If you have any questions or need a hand, just let me know! Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | telephony/survey_caller/survey_calling_agent.py | Job lifecycle | LiveKit Docs
f
token = AccessToken( _api_key_=API_KEY, _api_secret_=API_SECRET ).with_grants( VideoGrants( room=room.name, room_join=True, can_publish=True, can_subscribe=True, can_publish_data=True, can_publish_sources=["microphone"], can_update_own_metadata=True ) ).with_identity(_user_id_).with_room_config( RoomConfiguration( agents=[ RoomAgentDispatch(_agent_name_="Evi", metadata=metadata) ] ) ).to_jwt() How to access the metadata
t
Hey there! To grab the metadata passed in
RoomAgentDispatch
, you’ll want to use the
ctx.job.metadata
field right in your agent’s entrypoint. Just a heads-up—the metadata comes as a string, so you’ll need to parse it with
json.loads
to get it into a handy structured format. Here’s a quick example to make it clearer:
Copy code
import json

async def entrypoint(ctx: JobContext):
    metadata_str = ctx.job.metadata
    try:
        metadata = json.loads(metadata_str)
        user_id = metadata.get("user_id", "Unknown")
        print(f"Agent received user_id: {user_id}")
    except json.JSONDecodeError as e:
        print(f"Failed to parse metadata: {e}")
        metadata = {}  # Fallback to empty metadata

    # Use the metadata as needed in your agent logic
Also, just make sure the metadata is properly JSON-encoded when you’re creating the token or dispatching the agent. For example:
Copy code
token = AccessToken(
    api_key=API_KEY,
    api_secret=API_SECRET
).with_grants(
    VideoGrants(
        room=room.name,
        room_join=True,
        can_publish=True,
        can_subscribe=True,
        can_publish_data=True,
        can_publish_sources=["microphone"],
        can_update_own_metadata=True
    )
).with_identity(user_id).with_room_config(
    RoomConfiguration(
        agents=[
            RoomAgentDispatch(agent_name="Evi", metadata=json.dumps({"user_id": "12345"}))
        ]
    )
).to_jwt()
This way, your metadata will be easy to access and perfectly formatted for your agent. Hope this helps! Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | Job lifecycle | LiveKit Docs | protobufs/livekit_agent_dispatch.proto | examples/agent_dispatch.py
f
ERROR livekit.agents - unhandled exception while running the job task Traceback (most recent call last): File "/Users/venuchoudhary/Developer/freelance/nextpeer_backend/venv/lib/python3.13/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/venuchoudhary/Developer/freelance/nextpeer_backend/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/venuchoudhary/Developer/freelance/nextpeer_backend/agent.py", line 54, in start_session metadata = json.loads(ctx.job.metadata) File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/__init__.py", line 346, in loads return _default_decoder.decode(s) ~~~~~~~~~~~~~~~~~~~~~~~^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/decoder.py", line 345, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/decoder.py", line 363, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None
t
It looks like the error is pointing to the metadata string (
ctx.job.metadata
) being empty or not valid JSON. Could you help me out by confirming a few things? • How are you passing the metadata when creating the token or dispatching the agent? • Is the metadata field set explicitly, and if yes, what value are you assigning? • Have you checked if the metadata is a valid JSON string?
f
lkapi = LiveKitAPI(url=LIVEKIT_URL, _api_key_=API_KEY, _api_secret_=API_SECRET) room = await lkapi.room.create_room(CreateRoomRequest( name=str(uuid.uuid4()), _empty_timeout_=timeout, _max_participants_=2, )) print(_f_"Room created: {room}") metadata = json.dumps({ "voice_id": _voice_id_, "session_id": _session_id_, }) token = AccessToken( _api_key_=API_KEY, _api_secret_=API_SECRET ).with_grants( VideoGrants( room=room.name, room_join=True, can_publish=True, can_subscribe=True, can_publish_data=True, can_publish_sources=["microphone"], can_update_own_metadata=True ) ).with_identity(_user_id_).with_room_config( RoomConfiguration( agents=[ RoomAgentDispatch(_agent_name_="Evi", metadata=metadata) ] ) ).to_jwt()
t
Thanks so much for sharing the code! From what I see, the metadata is being passed correctly as a JSON string when creating the token. That said, the error hints that the metadata might not be reaching the agent as expected. Let’s walk through a few steps to help you debug and fix this: 1. Verify Metadata in the Agent: Try adding a debug log right at the agent’s entrypoint to print out the raw
ctx.job.metadata
before parsing it. This can give us a clearer picture:
Copy code
async def entrypoint(ctx: JobContext):
    print(f"Raw metadata: {ctx.job.metadata}")
    try:
        metadata = json.loads(ctx.job.metadata)
        print(f"Parsed metadata: {metadata}")
    except json.JSONDecodeError as e:
        print(f"Failed to parse metadata: {e}")
1. Check Metadata Dispatch: Double-check that the metadata is being passed correctly when you dispatch the agent. For example, make sure the
metadata
field in
RoomAgentDispatch
isn’t empty or malformed. 2. Validate Metadata: Before passing the metadata along, it’s a good idea to validate it to confirm it’s a valid JSON string:
Copy code
try:
    json.loads(metadata)  # Validate JSON
except json.JSONDecodeError:
    print("Invalid metadata JSON")
1. Inspect Room Configuration: Take a look at the room configuration to ensure the agent includes the correct metadata. You can print out the token or check the room details after creation to verify this. Hopefully, these steps will help you pinpoint whether the hiccup is happening during metadata creation, dispatch, or parsing. Let me know how it goes or if you want to chat through it more!
f
Raw metadata: Failed to parse metadata: Expecting value: line 1 column 1 (char 0)
t
It looks like the error is happening because
ctx.job.metadata
is empty, so it can’t be parsed. This usually means the metadata isn’t getting passed to the agent properly. No worries though—here are some friendly steps to help you figure this out: 1. Double-check Metadata Assignment: Make sure the
metadata
variable is actually filled with the right info before you pass it to
RoomAgentDispatch
. For example:
Copy code
metadata = json.dumps({
    "voice_id": voice_id,
    "session_id": session_id,
})
print(f"Metadata being passed: {metadata}")
1. Take a Look at Token Creation: Confirm that the
RoomAgentDispatch
object includes the metadata by printing out the token or checking the room setup like this:
Copy code
print(f"Token: {token}")
1. Debug the Room Creation: See if the room creation is properly linking the agent and metadata. You can log the room details right after it’s created to double-check:
Copy code
print(f"Room created: {room}")
1. Add a Fallback Just in Case: It’s a good idea to handle situations where metadata might be empty by adding a fallback in the agent, like this:
Copy code
async def entrypoint(ctx: JobContext):
    metadata_str = ctx.job.metadata or "{}"  # Fallback to empty JSON
    try:
        metadata = json.loads(metadata_str)
        print(f"Parsed metadata: {metadata}")
    except json.JSONDecodeError as e:
        print(f"Failed to parse metadata: {e}")
Hopefully, these tips help you spot what’s going on and get the metadata passing smoothly to the agent. If you hit any snags, just let me know—I’m here to help!
f
can you tell me the process to get live kit url , api keys , api secret . This has to be the same on both token server and agent right ?
t
To grab your LiveKit URL, API key, and API secret, here’s a quick and easy guide: 1. First, sign up for LiveKit Cloud at https://cloud.livekit.io. 2. Next, create a project, and you’ll get: • LIVEKIT_URL: This is the WebSocket URL for your LiveKit server (like
wss://<your-project>.livekit.cloud
). • LIVEKIT_API_KEY: This key helps you authenticate your API requests. • LIVEKIT_API_SECRET: This secret works with your API key to sign tokens securely. Make sure to keep these credentials safe in your environment files (for example,
.env.local
). Do the credentials need to match between the token server and the agent? Yes, they do! The
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
should be exactly the same on both the token server and the agent. This way, they’ll authenticate properly and connect to the same LiveKit project without any hiccups. Use these credentials in both places: • The token server to create access tokens. • The agent to connect and work with rooms. Keeping everything consistent will help you avoid any authentication or connection troubles. If you run into any issues, feel free to reach out! Sources: Authentication Examples | livekit/livekit_composite | DeepWiki | Next.js quickstart | LiveKit Docs | agent/.env.example | examples/.env.example | .env.example
f
i have created project where will I get the url, keys, secret
t
Once you’ve created a project in LiveKit Cloud, you can easily find your URL, API key, and API secret in the project settings. Here’s how: 1. Log in to your LiveKit Cloud account at https://cloud.livekit.io. 2. Head over to the project you just created. 3. Click on the Settings or API Keys section in the project dashboard. 4. There, you’ll see: • LIVEKIT_URL: This is the WebSocket URL for your project (like
wss://<your-project>.livekit.cloud
). • LIVEKIT_API_KEY: Your API key for authentication. • LIVEKIT_API_SECRET: The secret key you’ll use to sign tokens. Make sure to copy and keep these credentials somewhere safe—they’re important for setting up your token server and agent configuration. If you need a hand, we’re here to help!
f
I have added the same keys everywhere but my agent worker is not receiving job requests
t
Hey there! If your agent worker isn’t getting job requests even though the API keys and URL seem right, no worries—let’s walk through some common reasons and easy fixes together: 1. Check Agent Name Configuration: Make sure the
agentName
in
WorkerOptions
exactly matches the
agent_name
in your dispatch rule. If these don’t line up, the worker won’t get any jobs. 2. Verify Worker Registration: Double-check that your worker is properly registered with the LiveKit server. You should see logs showing a registered worker ID and a confirmed connection. 3. Inspect WebSocket Connection: Confirm the worker is connecting to the right
LIVEKIT_URL
and that the WebSocket connection is steady and reliable. 4. Environment Variables: Take a moment to verify that
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
are all correctly set up in the worker’s environment. 5. Logs: Peek at the worker logs for any errors or warnings—they often hold clues about why jobs aren’t coming through. Hopefully, these tips help you pinpoint and fix the issue. If you want, I’m here to help you dig into any of these steps more deeply—just let me know! Sources: livekit-agents/livekit/agents/worker.py | Deploying to production | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | Anatomy of an Agent | LiveKit Docs | pkg/service/agentservice.go
f
await lkapi.room.dispatch_agent(RoomAgentDispatch( room=room.name, agent_name="Evi", # must match agent_name in your worker config=RoomConfiguration(metadata=metadata) ))
t
Hey there! Looking at your code snippet, the dispatch request seems to be set up correctly. To help get things working smoothly, here are a few things to double-check: 1. Agent Name Match: Make sure the
agent_name
in
RoomAgentDispatch
("Evi") exactly matches the
agentName
you set in the worker's
WorkerOptions
. If these don’t line up, the worker won’t get the job. 2. Metadata: Check that the
metadata
you’re passing is a valid JSON string. A handy trick is to log it right before dispatching, just to be sure it’s formatted correctly:
Copy code
print(f"Dispatching with metadata: {metadata}")
1. Worker Logs: Take a peek at the worker logs to confirm it’s connected to the LiveKit server and has registered properly. Look out for any messages that say the worker is ready to receive jobs. 2. Dispatch Confirmation: It’s also a good idea to log the response from the
dispatch_agent
call to verify the dispatch request went through successfully:
Copy code
response = await lkapi.room.dispatch_agent(...)
print(f"Dispatch response: {response}")
Following these steps should help pinpoint why the agent worker isn’t getting the job. If you want, I’m here to help you troubleshoot further!