calm-optician-60209
03/06/2026, 1:12 PMtall-airline-16756
03/06/2026, 1:12 PMtall-airline-16756
03/06/2026, 1:13 PMAgentSession constructor does not accept a parameter named before_tts_cb. The AgentSession options include things like stt, llm, tts, vad, and turn_detection, but before_tts_cb is not a supported init argument.
What you can do instead
• Override the TTS node in a custom Agent subclass to run preprocessing before text is sent to the TTS engine. This is the supported way to inject logic before TTS runs.
• Example pattern to override `tts_node`:
async def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings) -> AsyncIterable[rtc.AudioFrame]:
# custom text preprocessing can go here
async for frame in Agent.default.tts_node(self, text, model_settings):
# custom audio postprocessing can go here
yield frame
Next steps for me to help further
• If you want, paste the code where you construct AgentSession (the init call) and the Agent subclass you’re using.
• Tell me whether you intended before_tts_cb to modify the text before TTS, or to change audio after TTS — that will determine whether to put logic in tts_node (pre/post) or another node.
If you share the snippet, I can show exactly how to move your callback logic into tts_node or another appropriate hook.
Sources: Agent session | LiveKit Documentation | Pipeline nodes and hooks | LiveKit Documentation