5-08-11 15:06:38,850 - DEBUG livekit.plugins.googl...
# ask-ai
b
25-08-11 150638,850 - DEBUG livekit.plugins.google - connecting to Gemini Realtime API... {“pid”: 92696, “job_id”: “AJ_rZ67PF3FcYfP”} 2025-08-11 150638,851 - DEBUG livekit.agents - start reading stream {“participant”: “human”, “source”: “SOURCE_MICROPHONE”, “pid”: 92696, “job_id”: “AJ_rZ67PF3FcYfP”} 2025-08-11 150638,851 - DEBUG livekit.agents - start reading stream {“participant”: “human”, “source”: “SOURCE_CAMERA”, “pid”: 92696, “job_id”: “AJ_rZ67PF3FcYfP”} 2025-08-11 150638,852 - ERROR livekit.agents - unhandled exception while running the job task Traceback (most recent call last): File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/opentelemetry/util/_decorator.py”, line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/ipc/job_proc_lazy_main.py”, line 240, in _traceable_entrypoint await self._job_entrypoint_fnc(job_ctx) File “/Users/madhavsharma/uplevel-livekit-worker/app.py”, line 71, in entrypoint await run_multimodal_agent(ctx, participant) File “/Users/madhavsharma/uplevel-livekit-worker/app.py”, line 105, in run_multimodal_agent await session.start( ...<6 lines>... ) File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/opentelemetry/util/_decorator.py”, line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/voice/agent_session.py”, line 502, in start await asyncio.gather(*tasks) File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/voice/agent_session.py”, line 844, in _update_activity await self._activity.start() File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/voice/agent_activity.py”, line 378, in start await self._start_session() File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/voice/agent_activity.py”, line 453, in _start_session await self._rt_session.update_tools(self.tools) File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py”, line 437, in update_tools self._tools = llm.ToolContext(tools) ~~~~~~~~~~~~~~~^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/llm/tool_context.py”, line 219, in init self.update_tools(tools) ~~~~~~~~~~~~~~~~~^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.13/site-packages/livekit/agents/llm/tool_context.py”, line 247, in update_tools raise ValueError(f”duplicate function name: {info.name}“) ValueError: duplicate function name: clear_user_codepad {“pid”: 92696, “job_id”: “AJ_rZ67PF3FcYfP”} 2025-08-11 150641,001 - INFO google_genai.live - b’{\n “setupComplete”: {}\n}\n’ {“pid”: 92696, “job_id”: “AJ_rZ67PF3FcYfP”} What’s the issue
t
Thanks for reaching out, Madhav. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! This error popped up because the LiveKit ToolContext found a duplicate function name—specifically, "clear_user_codepad". This usually happens when the same function name is registered more than once, which isn’t allowed. Here’s how you can fix it: 1. Take a look through your code for any duplicate function registrations. Each function name should be unique. 2. If you’re using the
@function_tool
decorator, double-check that the
name
parameter is unique for every function. 3. Review your function definitions to make sure there aren’t any accidental duplicates from copy-pasting or importing multiple times. 4. Make sure
update_tools()
isn’t being called multiple times with the same function. If you want a hand figuring this out or need any more help, just let me know—I’m here for you! Sources: livekit-agents/livekit/agents/llm/tool_context.py
b
Copy code
class Assistant(Agent):

    @function_tool()
    async def read_user_code(
        self,
        context: RunContext,)->str:
        """Read the current code written by the user in the editor.

        This tool allows the agent to access and analyze the code that the user
        has written in their editor during the interview session. Use this tool
        when you need to:
        - Review the user's code implementation
        - Provide feedback on their coding approach
        - Help debug issues in their code
        - Understand their solution to continue the interview
        - Analyze code quality and suggest improvements

        Returns:
            The current code content from the user's editor as a string.
            Returns an empty string if no code has been written yet.
        """
        try:
            # Get the current editor content from session storage
            code_content = get_session_editor_content()

            if not code_content or code_content.strip() == "":
                <http://logger.info|logger.info>("No code found in editor")
                return "The editor is currently empty. The user hasn't written any code yet."

            <http://logger.info|logger.info>(f"Retrieved code from editor (length: {len(code_content)} characters)")

            # Return the code with some formatting for better LLM understanding
            return f"""Here is the current code from the user's editor:
{code_content}
Copy code
"""

        except Exception as e:
            logger.error(f"Error reading user code: {e}")
            return f"Error reading user code: {str(e)}. The editor content might not be available."

    @function_tool
    async def clear_user_codepad(self,context: RunContext,)->str:
        try:
            # Access the Room instance
            room = get_job_context().room
            if not room:
                raise Exception("Room not available")

            # Define the destination participant identity
            participant_identity = next(iter(room.remote_participants.keys()))

            # Perform the RPC call
            response = await room.local_participant.perform_rpc(
                destination_identity=participant_identity,
                method="clear_user_codepad",
                payload="",
                response_timeout=5.0
            )

            return response
        except Exception as e:
            raise ToolError(f"RPC clear_user_codepad call failed: {e}")

    def __init__(self, instructions, chat_ctx=None) -> None:
        super().__init__(instructions=instructions, chat_ctx=chat_ctx,tools=[self.clear_user_codepad, self.read_user_code])
can you tell me what’s isssue
t
Hey there! The hiccup in your code is happening because the function name
clear_user_codepad
is getting registered twice in the LiveKit ToolContext, and that’s a no-go. Here’s how you can fix it: 1. Make sure every function you register with
@function_tool
has its own unique name. You can do this by setting a unique name using the
name
parameter in the decorator, like this:
Copy code
@function_tool(name="unique_clear_user_codepad")
async def clear_user_codepad(...):
    # Function implementation
1. Take a quick look at the
tools
list in the
__init__
method to double-check that you’re not adding any duplicate functions there. If you want, I’m here to help you walk through these changes—just let me know!
Hi Madhav. I'm reviewing the AI responses. In case it wasn't clear, you do not need to add the functions to both
tools=
and decorate with
@function_tool
. the decorator will automatically add them to the tools. Try removing the
tools=
line in your
_init__
.
b
figured out already @tall-belgium-91876 Thanks for mentioning
🙏 1
🙌 1