freezing-psychiatrist-35330
10/01/2025, 2:30 PMtall-airline-16756
10/01/2025, 2:30 PMtall-airline-16756
10/01/2025, 2:31 PMpytest and pytest-asyncio installed:
pip install pytest pytest-asyncio
1. Configure Text-Only Mode: Next, set up the AgentSession to enable text input/output and disable audio:
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(text_enabled=True, audio_enabled=False),
room_output_options=RoomOutputOptions(transcription_enabled=True, audio_enabled=False),
)
1. Send Text Input: You can then use generate_reply() or a TextStream to send text input to your agent:
result = await session.run(user_input="Hello")
1. Receive Agent Responses: To capture responses, listen to the conversation_item_added event like this:
@session.on("conversation_item_added")
def on_conversation_item_added(event):
print(f"Agent response: {event.item.text}")
1. Write and Run Tests: Finally, use pytest to structure and validate your test cases.
This method is perfect for focusing on your agent's logic without the need to set up voice or telephony infrastructure. If you have any questions or need a hand with anything, please don’t hesitate to ask—I’m here to help!
Sources: Testing and evaluation | LiveKit Docs | Docs::Agents | examples/other/text_only.py | README.md | livekit/tests/data_stream_test.rs