clever-optician-10225
10/29/2025, 8:29 PMtall-airline-16756
10/29/2025, 8:29 PMtall-airline-16756
10/29/2025, 8:30 PMupdate_tools method doesn’t directly remove previous tool calls from the chat context, but its behavior varies depending on the type of LLM you’re working with:
• Standard LLMs: When you call update_tools, it updates the tool list and triggers a context update. If exclude_invalid_function_calls=True (which is the default), any tool calls referring to tools no longer active are automatically excluded. This helps keep things tidy!
• Realtime LLMs: Here, the server takes care of managing the session state and validating tools. While update_tools ensures only valid tools remain on your side, removing outdated tool calls from the chat history usually happens server-side or during context synchronization.
If you want to have explicit control over the chat context and clear out old tool call entries, you can use update_chat_ctx() with exclude_invalid_function_calls=True. This gives you a bit more hands-on management.
Sources: examples/voice_agents/restaurant_agent.py | Agent Session & Client Integration | livekit/livekit_composite | DeepWikiclever-optician-10225
10/29/2025, 8:34 PMtall-airline-16756
10/29/2025, 8:35 PMupdate_tools. No worries—there are a few ways you can manage this smoothly:
• Manual Chat Context Management: Before you call update_tools, try copying the current chat context. Then, after updating your tools, you can bring back those previous tool calls by using update_chat_ctx() with exclude_invalid_function_calls=False. This helps keep things consistent.
• Using `exclude_invalid_function_calls=False`: When updating the chat context, setting exclude_invalid_function_calls=False allows you to retain function calls even for tools that might no longer be available. It’s a handy way to preserve history.
• Agent Handoff Pattern: Another approach is to copy and merge chat contexts carefully, ensuring that function calls from earlier tools stick around without creating duplicates.
These options should help you maintain your chat history with previous tool calls, even if some tools aren’t active anymore. If you'd like, I’m happy to walk you through the details of any of these methods—just let me know!
Sources: examples/voice_agents/restaurant_agent.pyclever-optician-10225
10/29/2025, 8:36 PMtall-airline-16756
10/29/2025, 8:37 PMNone, so it won’t interfere with your workflow.
• If the hallucinated tool call produces output without a matching function, it’s gently flagged with a warning and ignored to keep your data consistent.
This way, any invalid tool calls won’t disrupt your agent’s operation. If you’d like, I’m here to help you set up monitoring for logs or alerts to catch these events early. Just let me know!
Sources: livekit-agents/livekit/agents/llm/mcp.py | agents/src/voice/generation.ts | Docs::Agentsclever-optician-10225
10/29/2025, 8:44 PMtall-airline-16756
10/29/2025, 8:45 PMexclude_invalid_function_calls parameter, which isn't directly adjustable through the update_tools method. But no worries, you can achieve what you need by following these steps:
1. First, use update_tools to update your tools as usual.
2. Then, manually update the chat context with update_chat_ctx, setting exclude_invalid_function_calls=False. This way, you’ll keep function calls even for tools that are no longer available.
Currently, there isn’t a built-in option to override update_tools to disable excluding invalid function calls directly. If you’d like, I’m here to help you implement this approach step-by-step—just let me know!
Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki