astonishing-smartphone-66046
12/22/2025, 12:03 PMtall-airline-16756
12/22/2025, 12:03 PMtall-airline-16756
12/22/2025, 12:04 PMBVC() / BVCTelephony() / <http://noise_cancellation.NC|noise_cancellation.NC>().)
4. Do you have any session logs, transcripts, or an example call where the agent made an unintended tool call or hallucinated? Observability traces help pinpoint whether the LLM or the tool logic triggered the behavior.
While you gather that, here are targeted actions you can try immediately:
• Reduce hallucinations / keep agent on script
◦ Make the system prompt explicit and restrictive: instruct the agent to answer only from provided facts and to respond “I don’t know” when information isn’t available.
◦ Ground responses by requiring tool use for factual lookups and returning only tool outputs (e.g., enforce tool_choice='required' or restrict to tool_choice='none' when you want no tools).
◦ Add behavioral tests (use LiveKit’s testing) that assert the agent stays on script for common prompts.
• Stop unintended tool calls
◦ Tighten tool descriptions and set clear invocation conditions so the agent only calls a tool when necessary.
◦ Use tool_choice settings to disable or require explicit conditions for tool invocation.
◦ Encapsulate sensitive flows as discrete `AgentTask`s so those actions happen only when explicitly triggered.
• Fix noise cancellation sensitivity and fast speech
◦ Try a less aggressive noise model: switch from BVC() to BVCTelephony() or <http://noise_cancellation.NC|noise_cancellation.NC>() if voice is being dropped.
◦ Increase endpointing delays: raise min_endpointing_delay from 0.5s and/or max_endpointing_delay from 6.0s to avoid premature cutoffs.
◦ Slow TTS speed via provider settings:
▪︎ Cartesia: set speed in extra_kwargs.
▪︎ ElevenLabs: set speed.
▪︎ Rime: set speed_alpha.
◦ Check CPU/instance throttling: low CPU (burstable instances) can cause timeouts and erratic turn detection.
If you prefer, paste a short system prompt, the tool description of the tool that’s being mis-invoked, and the TTS/noise settings you’re using — I’ll give exact parameter changes and example snippets to apply.
Sources: External data and RAG | LiveKit docs | Testing and evaluation | LiveKit docs | Collect recording consent with tasks | LiveKit docs | Enhanced noise cancellation | LiveKit docs | Turns overview | LiveKit docsastonishing-smartphone-66046
12/22/2025, 12:27 PMtall-airline-16756
12/22/2025, 12:27 PMtool_choice when creating the agent (values like required, auto, or none)? If yes, which value?
If you want immediate fixes, apply these changes:
1) Reduce hallucinations / keep agent on script
• Make the system prompt stricter and explicit about allowed knowledge and failure modes. Add these lines near the top of your master prompt:
◦ “Answer only using provided organization data and tool outputs. If the information is not present, respond: ‘I don’t have that information; would you like me to look it up?’”
◦ “Do not invent details or assume facts.”
• Move any policy or factual content into structured, short bullet lists in the prompt so the LLM can reference facts easily.
• Shorten the persona content that isn’t needed at runtime (keep only the essentials: name, goal, tone).
• Add a short guardrail section that forbids off-script behaviors, for example:
◦ “Tool outputs must be quoted exactly when used in responses.”
◦ “Do not mention internal logs, tool call mechanics, or that a function was called.”
• Add automated behavioral tests (use your test framework) that assert responses for sample prompts remain within script and return “I don’t know” when appropriate.
2) Prevent unintended tool calls
• Set tool_choice='required' if you want the model to only call tools when explicitly needed, or tool_choice='none' to disable tools in voice flows. (Please confirm what you currently use.)
• Make every tool description short and conditional. Example pattern for tool description:
◦ “Use this only when the user explicitly asks to book, change, or cancel an appointment. Do not invoke for clarifying questions.”
• For calendar-like actions, require a confirmation step before calling the calendar tool:
◦ After parsing an appointment, have the agent ask one brief confirmation: “I’m about to create an event for [date/time]. Should I proceed?” Only call the tool after a positive confirmation.
• Encapsulate destructive or external actions in explicit AgentTask calls so they happen in isolation and are easier to audit.
• Add a rule in the prompt: “If the user’s intent is ambiguous, do not call tools; ask a clarifying question first.”
3) Reduce noise-cancellation aggressiveness & slow TTS
• Switch noise model or reduce its aggressiveness:
◦ Try BVCTelephony() or <http://noise_cancellation.NC|noise_cancellation.NC>() instead of BVC() if you currently use BVC() and voice gets cut or words repeat.
• Increase endpointing delays:
◦ Raise min_endpointing_delay above 0.5s (try 0.8–1.2s) and max_endpointing_delay to 8s if calls are getting cut off or words repeat.
• Adjust Cartesia TTS speed:
◦ In Cartesia extra_kwargs, set speed to a lower value (e.g., 0.85 or 0.9) to slow speech. Test incrementally until pacing sounds natural.
• Verify instance CPU/latency:
◦ If you’re on burstable instances (t3/t4), try a non-burstable instance or increase CPU allocation—poor CPU can cause erratic endpointing and fast/garbled TTS.
Observability & debugging
• Use Agent Observability to inspect transcripts, tool-call traces, and timing for problematic sessions. Look for:
◦ LLM tokens immediately before function calls (shows why it triggered).
◦ Timestamps for endpointing events (shows premature cutoffs).
◦ Confidence scores from Deepgram on low-confidence segments.
• Capture a short problematic call and share the transcript + timestamps if you want me to point out exactly where behavior deviates and what to change.
If you confirm your current tool_choice and the TTS speed value you’re using, I’ll provide exact prompt text and example parameter snippets you can drop into your agent config.astonishing-smartphone-66046
12/22/2025, 12:31 PMtall-airline-16756
12/22/2025, 12:32 PMtool_choice isn't set anywhere, the agent is running with the framework default (likely auto), which explains the unintended tool calls. Below are concise, actionable steps and example snippets to explicitly set tool_choice and reduce hallucinations, plus the prompt/timing/TTS changes we discussed.
Quick confirmation: do you want tools allowed only when explicitly required (tool_choice='required') or fully disabled for voice flows (tool_choice='none')? If unsure, pick 'required' to keep tools but prevent accidental calls.
1) Where to add tool_choice
• Add it to the LLM config and propagate into Agent initialization so it’s consistently applied.
2) Example change for config/config_llm.py
• Add a tool_choice parameter in your LLM config. Example:
LLM_CONFIG = {
# existing LLM settings...
"model": "cerebras",
"temperature": 0.2,
"max_tokens": 512,
"tool_choice": "required", # or "none"
}
3) Example change for agent/agent.py (Agent initialization)
• Accept and forward tool_choice into the LLM/agent client:
class Assistant:
def __init__(self, session, logger, instructions, call_context, call_logger, tool_choice=None):
self.session = session
self.logger = logger
self.instructions = instructions
self.call_context = call_context
self.call_logger = call_logger
self.tool_choice = tool_choice
# when creating the LLM/agent client:
self.llm_client = create_llm_client(
model="cerebras",
temperature=0.2,
max_tokens=512,
tool_choice=self.tool_choice,
)
4) Example change for AgentSession creation (agent/session.py)
• Pass tool_choice from higher-level config into session/assistant:
from config.config_llm import LLM_CONFIG
def create_agent_session(...):
tool_choice = LLM_CONFIG.get("tool_choice", None)
assistant = Assistant(session, logger, instructions, call_context, call_logger, tool_choice=tool_choice)
return assistant
5) Recommended values and rationale
• `tool_choice = "required"`: Best balance — tools can be used but only when the model determines they are necessary (and with stricter prompt rules they’ll be rarer).
• `tool_choice = "none"`: Use for safe voice-only flows where no external actions should occur.
• If you need some tools but not others, keep tool_choice='required' and tighten individual tool descriptions and add confirmation steps before calling sensitive tools (calendar, transfers).
6) Prompt & behavioral guard changes to pair with tool_choice
• Add to top of master prompt:
◦ "Answer only using provided data and explicit tool outputs. If not available, say 'I don’t have that information; would you like me to look it up?' Do not call tools for clarification."
◦ "Do not reveal tool calls or internal logs in responses."
• Require explicit confirmation before destructive/external tools:
◦ Agent: “I’m ready to create an appointment for [date/time]. Should I proceed?” Call calendar tool only after user confirms.
7) Audio/TTS quick settings (apply alongside above)
• Noise cancellation: switch to BVCTelephony() or <http://noise_cancellation.NC|noise_cancellation.NC>() and increase endpointing delays:
◦ `min_endpointing_delay`: try 0.8–1.2
◦ `max_endpointing_delay`: try 8.0
• Cartesia TTS speed: set extra_kwargs["speed"] = 0.85 and test.
8) Observability
• After changes, watch agent observability traces to confirm fewer unintended function calls and that endpointing/timing improved.
If you confirm which tool_choice value you'd like and paste the minimal spot where you instantiate the LLM client (a few lines from where create_llm_client or similar is called), I’ll produce the exact patch/diff you can apply.