Documentation
¶
Overview ¶
Command function-calling-missing-handler demonstrates, on purpose, a tool the LLM is told about but that has no handler.
When a tool is advertised to the LLM in the context but has no handler (neither set on its frames.Tool nor registered with RegisterFunction), the LLM still emits a tool call, and nothing would answer it, leaving the conversation stuck. The LLM service recovers:
- It logs an error telling a developer error (a tool advertised with no handler) apart from a hallucination (a tool not advertised), naming the tool.
- It answers with a neutral terminal tool result ("The function `X` is not currently available."), so the call still ends with a normal tool result.
The weather tool here deliberately has no handler. Ask the bot about the weather and observe:
- The LLM emits a tool call for get_current_weather.
- An error is logged: "tool is advertised to the model but has no handler".
- The terminal tool result is fed back to the LLM.
- The LLM answers in voice from that result (typically something like "the weather function isn't available right now").
It uses the OpenAI LLM service with defaults. Swap in another provider to check the behavior elsewhere. Speech-to-text is Deepgram and text-to-speech Cartesia.
DEEPGRAM_API_KEY=… OPENAI_API_KEY=… CARTESIA_API_KEY=… \ go run ./examples/function-calling/function-calling-missing-handler
Then open http://localhost:7860, connect, and ask about the weather.