can we have test agent (AI evaluating agent) and a...
# ask-ai
g
can we have test agent (AI evaluating agent) and a AI voice agent, communicate with each other in a room without a human and carry out a complete conversation between themselves?
t
Thanks for reaching out, Dhruv. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely! AI agents can chat with each other in a LiveKit room without any human stepping in, but you'll need to tweak a few settings first. By default, LiveKit agents don’t pick up on speech from other agents in the same room. To get them talking, you’ll want to set the
RoomInputOptions
to include agent kinds as participants whose speech should be listened to and processed:
Copy code
RoomInputOptions.participant_kinds = [rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]
Once that’s set, agents can: • Hear speech from other agents in the room • Turn that speech into input (like speech-to-text) • Reply using synthesized speech (Text-to-Speech) This is super handy for testing, where one agent might follow a script and another checks how it responds—basically, fully automated, agent-only conversations. If you want a hand setting this up or have any questions, just let me know—I’m here to help! Sources: Realtime media | LiveKit Docs | LiveKit Docs | Rooms, participants, and tracks | LiveKit Docs | How to Enable Agent-to-Agent Speech Detection in LiveKit | Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki
g
I get this error after 15 seconds of two agents conversing with each other 2025-08-26 112724,985 - DEBUG livekit.agents - stream closed {"participant": "assistant-agent-bandhan-langgraph", "source": "SOURCE_MICROPHONE"} 2025-08-26 112725,002 - DEBUG grpc.aio._call - Client request_iterator raised exception: Traceback (most recent call last): File "D:\Fintaar\livekit\venv\Lib\site-packages\grpc\aio\_call.py", line 450, in _consume_request_iterator async for request in request_iterator: File "D:\Fintaar\livekit\venv\Lib\site-packages\livekit\plugins\google\tts.py", line 356, in input_generator async for input in input_stream: File "D:\Fintaar\livekit\venv\Lib\site-packages\livekit\agents\tokenize\token_stream.py", line 109, in anext return await self._event_ch.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Fintaar\livekit\venv\Lib\site-packages\livekit\agents\utils\aio\channel.py", line 176, in anext return await self.recv() ^^^^^^^^^^^^^^^^^ File "D:\Fintaar\livekit\venv\Lib\site-packages\livekit\agents\utils\aio\channel.py", line 106, in recv await g asyncio.exceptions.CancelledError
t
Hey there! The error
asyncio.exceptions.CancelledError
usually pops up when a task or operation gets interrupted or cancelled while it’s running. No worries though—here are some friendly steps to help you sort this out during AI agent conversations: 1. Handle cancellations gracefully: Try wrapping your awaitable operations in
try-except
blocks to catch
asyncio.CancelledError
. Like this:
Copy code
try:
    result = await some_task
except asyncio.CancelledError:
    result = "Task cancelled"
finally:
    await cleanup_tasks()
2. Use `asyncio.shield()`: This helps protect important parts of your code from being cancelled too soon:
await asyncio.shield(asyncio.gather(*tasks, return_exceptions=True))
3. Make sure to clean up properly: Use
finally
blocks to safely cancel and wait for background tasks to finish:
Copy code
finally:
    await utils.aio.cancel_and_wait(*tasks)
4. Handle speech interruptions: You can safely cancel ongoing speech generation with the
interrupt()
method:
self._current_speech.interrupt()
Also, it’s a good idea to keep each agent’s tasks separate so cancellations in one don’t accidentally mess with another. Checking logs for task names and speech IDs can be a big help in spotting where interruptions are coming from. If you’re still running into trouble, take a look at your session management to make sure cancellation signals are only sent when you really want them to be. And hey, if you want to chat more or need a hand, just let me know—I’m here to help! Sources: Handling RAG Delays in Voice Agents | LiveKit Docs | External data and RAG | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | stream_audio.py | External data and RAG | LiveKit Docs
g
can i provide an exissting example of this from github
t
Hey there! Yes, you’ll find some great examples on GitHub showing how to handle
asyncio.exceptions.CancelledError
in LiveKit AI agent conversations. Here are a few handy patterns to keep in mind: 1. Graceful cancellation during function calls:
Copy code
except asyncio.CancelledError:
    if len(tasks) > 0:
        names = [task.get_name() for task in tasks]
        logger.debug(
            "waiting for function call to finish before fully cancelling",
            extra={
                "functions": names,
                "speech_id": speech_handle.id,
            },
        )
        await asyncio.gather(*tasks)
2. Handling cancellations in long-running tasks:
Copy code
try:
    result = await deep_search_task
except asyncio.CancelledError:
    result = "Search cancelled by user"
finally:
    notify_frontend_task.cancel()
    return result
3. Re-raising
CancelledError
after handling other exceptions:
Copy code
except asyncio.CancelledError:
    raise
except Exception as e:
    logger.error(f"Error in content filtering: {str(e)}")
    yield "[Error in content filtering]"
4. Proper cleanup of background tasks:
Copy code
audio_task.cancel()
try:
    await audio_task
except asyncio.CancelledError:
    pass
You can find these examples in LiveKit-related repositories—they really show how to handle cancellations smoothly in conversational workflows. If you want, I’m happy to help you find a specific repo or example. Just let me know! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | External data and RAG | LiveKit Docs | Handling RAG Delays in Voice Agents | LiveKit Docs | External data and RAG | LiveKit Docs | pipeline-llm/llm_powered_content_filter.py
g
can provide an example of a testing agent from github
t
Absolutely! There are GitHub examples you can use to test LiveKit agents. Here are some handy resources to get you started: 1. Drive-Thru and Front-Desk Agent Examples: You’ll find full evaluation suites for these agents in the
livekit/agents
repo, specifically under
examples/drive-thru
and
examples/frontdesk
. They include helpful test files like
test_agent.py
. 2. Starter Project: The
livekit-examples/agent-starter-python
repo is a great foundation if you want to build and test your own custom agents. 3. Agent-to-Agent Testing: There’s a neat evaluation framework where an “evaluation agent” interacts with the agent you’re testing. It uses components like
AgentSession
and
RoomIO
to check responses and create test reports. 4. Testing Practices: You’ll find examples of asynchronous tests using
pytest
and
pytest-asyncio
, assertions to verify agent behavior, and automated testing set up in CI pipelines with GitHub Actions. For a quick check, you can also run basic tests locally in console mode using
python myagent.py console
. If you want help finding a specific repo or example, just let me know—I’m happy to assist! Sources: README.md | Testing and evaluation | LiveKit Docs | Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki
g
how do i run a livekit server locally
t
Hey there! You can easily run a LiveKit server locally by following these simple steps: 1. Install LiveKit Server: ◦ macOS: Just use Homebrew:
brew update && brew install livekit
◦ Linux: Run this install script:
curl -sSL https://get.livekit.io | bash
◦ Windows: Grab the latest release from GitHub. 1. Start the Server in Development Mode: Simply run:
livekit-server --dev
This will get your server up and running with a placeholder API key (
devkey
) and secret (
secret
). 2. Optional: Access from Other Devices: If you want other devices on your network to connect, use:
livekit-server --dev --bind 0.0.0.0
If you have any questions or need a hand, just let me know—I’m here to help! Sources: README.md | Running LiveKit locally | LiveKit Docs
g
/home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.27.5/app.go:307 main.main /home/runner/go/pkg/mod/github.com/livekit/livekit-server@v1.9.0/cmd/server/main.go:185 runtime.main /opt/hostedtoolcache/go/1.23.4/x64/src/runtime/proc.go:272 2025-08-26T122212.187+0530 INFO livekit routing/interfaces.go:175 using single-node routing 2025-08-26T122212.491+0530 INFO livekit service/server.go:265 starting LiveKit server {"portHttp": 7880, "nodeID": "ND_Z6w4hF4X7itR", "nodeIP": "172.31.64.1", "version": "1.9.0", "bindAddresses": ["127.0.0.1", "::1"], "rtc.portTCP": 7881, "rtc.portUDP": {"Start":7882,"End":0}} 2025-08-26T122212.494+0530 INFO livekit service/server.go:267 Windows detected, capacity management is unavailable 2025-08-26T122212.494+0530 DEBUG livekit service/signal.go:119 starting relay signal server {"topic": "ND_Z6w4hF4X7itR"} 2025-08-26T122212.560+0530 WARN livekit service/auth.go:89 error handling request {"status": 401, "method": "GET", "path": "/agent", "error": "invalid API key: APIT4j55JxzoCyW"} 2025-08-26T122214.585+0530 WARN livekit service/auth.go:89 error handling request {"status": 401, "method": "GET", "path": "/agent", "error": "invalid API key: APIT4j55JxzoCyW"} I have enter the api key given by the server these our the credentials
Copy code
LIVEKIT_URL=http://127.0.0.1:7880/
LIVEKIT_API_KEY=APIT4j55JxzoCyW
LIVEKIT_API_SECRET=WyZJf1Qrq9stEXzSVY0TTCq6pPpr4fehKhgq5EoQEK3A
t
That "invalid API key" error usually pops up when the API key and secret don’t quite match what the server expects. If you’re running the LiveKit server in development mode (using
--dev
), just stick with the default credentials: • API Key:
devkey
• API Secret:
secret
Make sure your environment variables look like this:
Copy code
LIVEKIT_URL=ws://localhost:7880
LIVEKIT_API_KEY=devkey
LIVEKIT_API_SECRET=secret
If you’re not in development mode, you’ll want to create and set up your own API key and secret. And hey, if you want a hand with that, just let me know—I’m here to help! Sources: examples/publish-wav/.env.example | pkg/service/auth.go | Running LiveKit locally | LiveKit Docs | Running LiveKit locally | LiveKit Docs
g
2025-08-26 124231,211 - INFO root - ignoring text stream with topic 'lk.transcription', no callback attached 2025-08-26 124232,298 - INFO root - ignoring text stream with topic 'lk.transcription', no callback attached 2025-08-26 124232,304 - INFO root - ignoring text stream with topic 'lk.transcription', no callback attached
t
Hey there! That log message saying "ignoring text stream with topic 'lk.transcription', no callback attached" basically means your app is getting a text stream on the
lk.transcription
topic, but there’s no function set up to handle it yet. To fix this, you just need to register a text stream handler for that topic. Here’s a quick example in Python:
Copy code
room.register_text_stream_handler(topic="lk.transcription", handler=your_callback_function)
And if you’re working with JavaScript, it would look like this:
Copy code
room.registerTextStreamHandler('lk.transcription', async (reader, participantInfo) => {
  const message = await reader.readAll();
  if (reader.info.attributes['lk.transcribed_track_id']) {
    console.log(`New transcription from ${participantInfo.identity}: ${message}`);
  } else {
    console.log(`New message from ${participantInfo.identity}: ${message}`);
  }
});
Just make sure you register the handler early on in your app’s lifecycle and that the topic name matches exactly (
lk.transcription
). That way, your app will be ready to process those incoming transcriptions or text messages smoothly. If you want, I’m here to help you out with any other questions! Sources: src/room/data-stream/incoming/IncomingDataStreamManager.ts | livekit-rtc/livekit/rtc/room.py | Text and transcriptions | LiveKit Docs | examples/other/chat-stream-receiver.py
g
2025-08-26 124230,648 - INFO google_genai.models - AFC is enabled with max remote calls: 10. 2025-08-26 124231,802 - INFO google_genai.models - AFC remote call 1 is done.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!