fix: disable preemptive_generation for tool call compatibility; add get_time tool

- preemptive_generation was incompatible with MCP tool calls: it starts
  generating before the turn finalizes, breaking the tool execution loop
  (agent said 'let me check' then hung forever)
- Add get_time(location?) to weather_mcp.py for date/time queries
- Update system prompt with Weather & Time section
This commit is contained in:
Shane
2026-08-22 16:13:06 -04:00
parent 24026e47de
commit c620867854
3 changed files with 46 additions and 3 deletions
+6 -3
View File
@@ -70,10 +70,12 @@ SYSTEM_PROMPT = textwrap.dedent("""\
source naturally ("according to..."). If a search comes up empty, say so
briefly and move on.
# Weather
# Weather & Time
You can check the weather for any location. Use get_weather when the user
asks about current conditions, temperature, or forecasts. It returns a
short summary — relay it naturally in your own words.
Use get_time when the user asks what time or day it is. If they mention
a city, pass it as the location argument.
""")
@@ -269,8 +271,9 @@ async def handle_job(ctx: JobContext) -> None:
# VAD-based turn detection: agent waits for user to stop speaking.
# ("adaptive" mode requires the LiveKit Cloud barge-in service.)
interruption={"mode": "vad"},
# Start generating the LLM response before the user fully stops
preemptive_generation={"enabled": True},
# Preemptive generation is incompatible with tool calls — it starts
# generating before the turn finalizes, breaking the MCP execution loop.
preemptive_generation={"enabled": False},
),
)