I want to create an agent that only gets text in a...
# ask-ai
c
I want to create an agent that only gets text in and output text out. How can I do that?
t
Thanks for reaching out, Guillaume. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to make an agent that only accepts text input and returns text output. Here’s how to do that. 1) Disable audio input and output • Python (when starting the session):
Copy code
from livekit.agents import AgentSession
from livekit.agents.voice import room_io

session = AgentSession(...)
await session.start(
  agent=my_agent,
  room=ctx.room,
  room_options=room_io.RoomOptions(
    audio_input=False,
    audio_output=False,
  ),
)
• Node.js:
Copy code
import { voice } from '@livekit/agents';

const session = new voice.AgentSession({...});

await session.start({
  agent,
  room: ctx.room,
  inputOptions: { audioEnabled: false },
  outputOptions: { audioEnabled: false },
});
2) Send text input • Clients send text on the lk.chat topic:
Copy code
await room.localParticipant.sendText("Hello", { topic: 'lk.chat' });
• You can add a
text_input_cb
(TextInputOptions) to filter or preprocess incoming chat messages before the agent handles them. 3) Receive text output • With audio disabled, the agent replies via the
lk.transcription
text stream (no audio track or STT/TTS used). • Client example to read responses:
Copy code
room.registerTextStreamHandler('lk.transcription', async (reader, participant) => {
  const text = await reader.readAll();
  console.log('Agent response:', text);
});
Summary • Turn off audio input/output in your session options. • Send user messages to
lk.chat
. • Read agent replies from
lk.transcription
. Would you like a minimal working example for your language (Python or Node.js) or help adding message filtering/commands? Sources: Text and transcriptions | LiveKit docs | How to Set Up Speech-to-Text Input with Text-Only Output in LiveKit Agents
c
a minimal working example would be great
t
Below are two minimal working examples (Python and Node.js) to start a text-only LiveKit agent session that accepts text on
lk.chat
and sends replies on
lk.transcription
. Replace placeholders (API keys, room, agent) with your values. Python (async):
Copy code
import asyncio
from livekit.agents import AgentSession
from livekit.agents.voice import room_io
# import or define your agent instance as `my_agent`
# from my_agent_module import my_agent

async def main():
    session = AgentSession()  # configure your agent as needed
    await session.start(
        agent=my_agent,
        room="your-room-name-or-object",
        room_options=room_io.RoomOptions(
            audio_input=False,
            audio_output=False,
        ),
    )
    print("Text-only agent session started. Waiting for messages...")
    # keep running
    await asyncio.Event().wait()

if __name__ == "__main__":
    asyncio.run(main())
Client-side (send text to
lk.chat
):
Copy code
// in your web client using LiveKit SDK
await room.localParticipant.sendText("Hello agent", { topic: 'lk.chat' });
Listen for agent replies (client):
Copy code
room.registerTextStreamHandler('lk.transcription', async (reader, participant) => {
  const reply = await reader.readAll();
  console.log('Agent reply:', reply);
});
Node.js (server-side session):
Copy code
import { voice } from '@livekit/agents';
// import or define your agent instance as `agent`

async function startTextOnlySession() {
  const session = new voice.AgentSession({
    // agent config if required
  });

  await session.start({
    agent,
    room: "your-room-name-or-object",
    inputOptions: { audioEnabled: false },
    outputOptions: { audioEnabled: false },
  });

  console.log("Text-only agent session started. Waiting for messages...");
  // keep process alive
  await new Promise(() => {});
}

startTextOnlySession().catch(console.error);
If you want, I can: • Expand either example to show a minimal agent definition, • Show how to add a
text_input_cb
to preprocess or filter messages, • Provide a complete runnable repo-style example for your chosen language. Which would you like?
c
I’m getting this error 2025-12-02 175044,950 - ERROR livekit.agents - Error in _tts_inference_task Traceback (most recent call last): File “/home/guillaume/projects/tutor-prototype/agent/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py”, line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/guillaume/projects/tutor-prototype/agent/.venv/lib/python3.12/site-packages/opentelemetry/util/_decorator.py”, line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/guillaume/projects/tutor-prototype/agent/.venv/lib/python3.12/site-packages/livekit/agents/voice/generation.py”, line 222, in _tts_inference_task async for audio_frame in tts_node: File “/home/guillaume/projects/tutor-prototype/agent/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent.py”, line 411, in tts_node assert activity.tts is not None, “tts_node called but no TTS node is available” AssertionError: tts_node called but no TTS node is available {“pid”: 93565, “job_id”: “AJ_t4NQqkXMcJxy”}
t
You're seeing an AssertionError because the agent's TTS pipeline is being run but no TTS node is configured. That happens when TTS is expected but not provided. To keep a text-only agent you must disable audio/tts so the TTS task never runs — or supply a TTS implementation if you want speech. What to change (Python): • When starting the session, disable audio input/output so TTS/STT won't be used:
Copy code
from livekit.agents import AgentSession
from livekit.agents.voice import room_io

session = AgentSession(...)

await session.start(
    agent=my_agent,
    room=ctx.room,
    room_options=room_io.RoomOptions(
        audio_input=False,
        audio_output=False,
    ),
)
• Ensure your agent configuration (where you create
my_agent
) does not include a
tts
node or any voice-generation pipeline. If your agent code sets a
tts
attribute, remove or set it to
None
. Quick checklist to stop this error: • Confirm
audio_output=False
(or
outputOptions.audioEnabled=false
in Node). • Remove or avoid any `tts`/TTS provider configuration in the agent definition. • Restart the session after making changes. If you actually want TTS instead of text-only, let me know and I’ll show how to attach a TTS node/provider to avoid this assertion. Would you like me to inspect the part of your agent config that defines
tts
?