Christian Gick 7087fbf733
Some checks failed
Build & Deploy / test (push) Successful in 10s
Tests / test (push) Successful in 8s
Build & Deploy / build-and-deploy (push) Failing after 2m55s
fix(bot): prevent dangling preamble + force final summary on tool-loop exhaustion
Two compounding streaming bugs caused the bot to render only a
'Gute Frage — lass mich' preamble when claude-haiku spent all
MAX_TOOL_ITERATIONS=5 on tool calls without producing final text.

1. Preamble leak: stream posted first content delta as soon as it
   crossed MIN_CHARS_BEFORE_POST=20, before tool_calls deltas had
   arrived. Added 1.2s TOOL_GRACE_SECONDS buffer so the suppression
   path catches the upcoming tool_calls before we go visible.

2. No final synthesis: when the loop exhausted iterations while still
   requesting tools, reply was empty and the orphaned preamble stayed
   on screen. Added a forced tools=None final call to make the model
   summarize accumulated tool results before send/edit.
2026-04-18 05:25:12 +00:00
Description
Matrix AI voice agent - LiveKit + LiteLLM
5.7 MiB
Languages
Python 99.1%
Dockerfile 0.8%
Shell 0.1%