I'm getting this error when the function tool is e...
# ask-ai
i
I'm getting this error when the function tool is executed. It is working fine with Azure open ai LLM. But throwing error for groq LLM. I used "llama-3.3-70b-versatile" model of groq. these are my livekit versions: livekit==1.0.13 livekit-agents==1.2.13 livekit-api==1.0.5 livekit-blingfire==1.0.0 livekit-plugins-cartesia==1.2.13 livekit-plugins-deepgram==1.2.13 livekit-plugins-elevenlabs==1.2.13 livekit-plugins-groq==1.2.13 livekit-plugins-noise-cancellation==0.2.5 livekit-plugins-openai==1.2.13 livekit-plugins-silero==1.2.13 livekit-plugins-turn-detector==1.2.13 livekit-protocol==1.0.6 and this is the error that I am getting.
Copy code
2025-10-02 23:16:46,346 - ERROR livekit.agents - Error in _execute_tools_task
Traceback (most recent call last):
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/voice/generation.py", line 425, in _execute_tools_task
    fnc_args, fnc_kwargs = llm_utils.prepare_function_arguments(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/llm/utils.py", line 373, in prepare_function_arguments
    if param_name in args_dict and args_dict[param_name] is None:
       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable {"pid": 2346005, "job_id": "AJ_JxxyZtgChWaR"}
2025-10-02 23:16:47,147 - INFO session.agent - [bb9f3448-e5af-417a-9ba3-ddb2803d3b3e] tts_metrics metrics collected {"pid": 2346005, "job_id": "AJ_JxxyZtgChWaR"}
2025-10-02 23:16:55,113 - INFO session.llm - [bb9f3448-e5af-417a-9ba3-ddb2803d3b3e] LLM genearted Response {"pid": 2346005, "job_id": "AJ_JxxyZtgChWaR"}
2025-10-02 23:16:55,113 - ERROR livekit.agents - Error in _pipeline_reply_task
Traceback (most recent call last):
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 1823, in _pipeline_reply_task
    await exe_task
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/voice/generation.py", line 425, in _execute_tools_task
    fnc_args, fnc_kwargs = llm_utils.prepare_function_arguments(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rashi-aidetic/Documents/Fabrichq/automated_call_notifications/venv/lib/python3.12/site-packages/livekit/agents/llm/utils.py", line 373, in prepare_function_arguments
    if param_name in args_dict and args_dict[param_name] is None:
       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable {"pid": 2346005, "job_id": "AJ_JxxyZtgChWaR"}
2025-10-02 23:16:57,647 - INFO livekit.agents - process exiting
t
Thanks for reaching out, Abdul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please share a bit more about the specific function tool you're using and how it's configured? Also, it would be really helpful to know if there are any differences in how the Azure OpenAI LLM and the Groq LLM are set up in your environment. This information will really help us get to the bottom of the issue together.
i
azure_plugin = openai_plugin.LLM.with_azure( model=cfg.get("model"), azure_deployment=deployment, azure_endpoint=endpoint, api_key=api_key, api_version=api_version, temperature=cfg.get("temperature") ) azure_plugin._opts.max_completion_tokens = cfg.get("maxTokens") return azure_plugin groq_plugin=groq.LLM(api_key="api-key", model="llama-3.3-70b-versatile") this is the function tool that I am trying to execute. @function_tool async def end_call(self, ctx: RunContext): """ Use this tool only after the assistant has spoken the final goodbye to the user by explicitly saying "bye" or "goodbye". Do not execute this tool until the assistant has first generated and delivered a proper concluding message that includes a farewell. This tool should never be called before the assistant has finished answering all of the user's questions and verbally ended the conversation. """ if self._session_logger: self._session_logger.log_info( LogComponent.AGENT, "end_call function tool invoked by model.", call_ended_reason=CallEndedReason.ASSISTANT_SAID_END_CALL_PHRASE ) # Set the call end reason before shutting down if hasattr(self, 'finalization_service'): self.finalization_service._ended_reason = CallEndedReason.ASSISTANT_SAID_END_CALL_PHRASE # Let the agent finish speaking current_speech = ctx.session.current_speech current_speech._allow_interruptions = False await ctx.wait_for_playout() get_job_context().shutdown()
t
I'm sorry to hear you're running into the error
TypeError: argument of type 'NoneType' is not iterable
. This usually happens due to a problem with how the API key is being handled for the Groq LLM. Let’s walk through some steps together to help you resolve this: 1. First, please double-check that your
api_key
parameter or the
GROQ_API_KEY
environment variable is set properly with a valid, non-empty string. For example:
Copy code
import os
os.environ["GROQ_API_KEY"] = "your-valid-groq-api-key"
2. Next, make sure the API key isn’t
None
before you pass it to the Groq LLM initialization. Here’s a quick way to verify:
Copy code
api_key = "your-key-here"
if not api_key:
    raise ValueError("API key is missing or invalid")
llm = groq.LLM(api_key=api_key, model="llama-3.3-70b-versatile")
3. It’s also a good idea to wrap the initialization in a
try-except
block to catch any errors gracefully:
Copy code
from livekit.plugins import groq
try:
    llm = groq.LLM(api_key="your-api-key", model="llama-3.3-70b-versatile")
except ValueError as e:
    print(f"LLM initialization failed: {e}")
    llm = None
4. Lastly, please ensure the
livekit-plugins-groq
package is installed correctly by running:
pip install "livekit-agents[groq]~=1.2"
If you’re still seeing the issue after trying these steps, it might be helpful to check your function tool implementation to make sure no
None
values are accidentally being passed or used where iterables are expected. Feel free to reach out if you want me to take a closer look or if you have any other questions—I’m here to help! Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py | Docs::Agents
i
I am sure that my credential is right. Because i am able to chat with my agent. it throws error only while executing the function tool.
t
Since we’ve confirmed that the credentials are correct and the issue happens only when running the function tool, could you please share a bit more about the inputs or parameters you're using with the function tool? Also, are there any particular conditions or situations when this error pops up? Understanding these details will really help us get to the bottom of this together.
i
sharing the entire assistant code here for your reference. It throws error while executing end call tool. from future import annotations import asyncio import re from typing import Any, Dict, List, Optional from livekit import api from livekit.agents import ( Agent, ChatContext, ChatMessage, RunContext, function_tool, get_job_context, ) from schemas.constants_and_enums import CallStatus, CallEndedReason from services.call_finalization_service import CallFinalizationService from services.session_log_service import SessionLogService, LogComponent from timeout_manager import TimeoutManager from datetime import datetime, timezone from api_client.call_service_client import CallService ###################################################################### # Assistant class # ###################################################################### class CallingAssistant(Agent): """Assistant that supports follow‑ups vs asset‑based new questions.""" def __init__( self, instructions: str, prompt_variable_values: Dict[str, str], finalization_service: CallFinalizationService, timeout_mgr: TimeoutManager, session_logger: Optional[SessionLogService] = None, call_service: CallService = None ) -> None: if prompt_variable_values: instructions = instructions.format(**prompt_variable_values) super().__init__(instructions=instructions) self._prompt_variable_values = prompt_variable_values self._idx = 0 self._tm = timeout_mgr self.finalization_service = finalization_service self._session_logger = session_logger self._call_service = call_service # ------------------------------------------------------------- Pipeline nodes and hooks ------------------------------------------------------------- async def on_enter(self): if self._session_logger: self._session_logger.log_info( LogComponent.AGENT, "Assistant entered room, saying greeting." ) # Say greeting message await self.session.say(f"Hello, Am I talking to {self._prompt_variable_values.get("candidate_name")}?") # Suppose if there is an error from any component and the call is disconnected even before the call is started, # we should not update the call status to in progress, because the call has been ended. # if self.finalization_service._ended_reason is None: # self._call_service.update_call(status=CallStatus.IN_PROGRESS, started_at=datetime.now(timezone.utc)) async def on_exit(self): msg = "Assistant left the room." if self._session_logger: self._session_logger.log_info(LogComponent.AGENT, msg) # --------------------------------------------------------- LLM function tools --------------------------------------------------------- # to hang up the call as part of a function call @function_tool async def end_call(self, ctx: RunContext): """ Use this tool only after the assistant has spoken the final goodbye to the user by explicitly saying "bye" or "goodbye". Do not execute this tool until the assistant has first generated and delivered a proper concluding message that includes a farewell. This tool should never be called before the assistant has finished answering all of the user's questions and verbally ended the conversation. """ if self._session_logger: self._session_logger.log_info( LogComponent.AGENT, "end_call function tool invoked by model.", call_ended_reason=CallEndedReason.ASSISTANT_SAID_END_CALL_PHRASE ) # Set the call end reason before shutting down if hasattr(self, 'finalization_service'): self.finalization_service._ended_reason = CallEndedReason.ASSISTANT_SAID_END_CALL_PHRASE # Let the agent finish speaking current_speech = ctx.session.current_speech current_speech._allow_interruptions = False await ctx.wait_for_playout() get_job_context().shutdown()
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!