Merge pull request #4404 from pipecat-ai/pk/mitigate-calls-to-missing-tools

Mitigate tool-call-related hallucination
This commit is contained in:
kompfner
2026-05-07 15:05:13 -04:00
committed by GitHub
7 changed files with 933 additions and 15 deletions

1
changelog/4404.added.md Normal file
View File

@@ -0,0 +1 @@
- Added an opt-in `add_tool_change_messages` flag to the LLM aggregators (set via `LLMContextAggregatorPair(..., add_tool_change_messages=True)`) that appends a developer-role message to the context whenever `LLMSetToolsFrame` changes the set of advertised standard tools. Helps the LLM stay coherent across mid-conversation tool changes, mitigating several flavors of tool-call-related hallucination: calling tools that have been removed, avoiding tools that have been re-added, and hallucinating output (made-up answers or tool-call-shaped non-tool-calls) when tools are unavailable.