How to stop routing LLM output to TTS when sound is off

This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.

Is there a way to stop routing LLM output to the TTS node entirely (not just mute playback) so that TTS is never invoked when sound is off?

You can hook the tts_node to control this:

async def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
    # Check if sound is enabled (you'll need to track this state)
    if not self.sound_enabled:
        # Return early without invoking TTS
        return None
    
    # Call default TTS node when sound is enabled
    return Agent.default.tts_node(self, text, model_settings)

See the nodes documentation: