Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions livekit-agents/livekit/agents/voice/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,33 @@ def _tool_completed(out: ToolExecutionOutput) -> None:
# TODO(theomonnom): assert other tool_choice values

if (function_tool := tool_ctx.function_tools.get(fnc_call.name)) is None:
available_tools = list(tool_ctx.function_tools.keys())
tools_list = ", ".join(available_tools) if available_tools else "none"

error_message = f"Unknown tool '{fnc_call.name}'. Available tools: {tools_list}"

logger.warning(
f"unknown AI function `{fnc_call.name}`",
extra={
"function": fnc_call.name,
"speech_id": speech_handle.id,
},
)

_tool_completed(
ToolExecutionOutput(
fnc_call=fnc_call.model_copy(),
fnc_call_out=llm.FunctionCallOutput(
name=fnc_call.name,
call_id=fnc_call.call_id,
output=error_message,
is_error=True,
),
agent_task=None,
raw_output=None,
raw_exception=None,
)
)
continue

if not is_function_tool(function_tool) and not is_raw_function_tool(function_tool):
Expand Down
Loading