function-calling-missing-handler

command
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: BSD-2-Clause Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:

  1. The LLM emits a tool call for get_current_weather.
  2. An error is logged: "tool is advertised to the model but has no handler".
  3. The terminal tool result is fed back to the LLM.
  4. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL