5-08-19 16:32:41,530 - ERROR livekit.agents - unha...
# ask-ai
w
2025-08-19 163241,530 - ERROR livekit.agents - unhandled exception while running the job task. What is causing this error when running?
t
Thanks for reaching out, Arthur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! The error "unhandled exception while running the job task" pops up when something unexpected happens in your job entrypoint function and it’s not caught. This can be caused by a few things like: • API call hiccups, maybe with LiveKit API or other external services • Issues during processing tasks, like audio/video handling or data manipulation • Resource troubles, such as running out of memory or network glitches • Logic slip-ups, like trying to use undefined variables or invalid operations Here are some friendly tips to help you avoid this error: 1. Make sure you’re handling exceptions properly in your job entrypoint function. For example:
Copy code
async def entrypoint(ctx: JobContext):
    try:
        await ctx.connect()
        # Your agent logic here
    except Exception as e:
        logger.error(f"Error in job: {e}")
        await ctx.shutdown("error occurred")
1. Keep the job lifecycle smooth by calling
ctx.connect()
and managing shutdowns carefully. 2. Use logging to catch and understand issues early before they become bigger problems. Also, the error message usually includes a stack trace (
exc_info=t.exception()
) which is super helpful for pinpointing what went wrong. If you want, I’m here to help you dig deeper or clarify anything—just let me know! Sources: livekit-agents/livekit/agents/__init__.py
w
what is the decorator.py module?
t
Hey there! Just a heads-up: LiveKit doesn’t have a single, centralized
decorator.py
module. Instead, decorators pop up in different parts of the system, each serving its own special purpose. Here are some handy examples to give you a feel for how they’re used: • Function Tools: The
@function_tool
decorator is your go-to in LiveKit Agents when you want to define tools that LLMs can access. Check this out:
Copy code
from livekit.agents import function_tool

class MyAgent(Agent):
    @function_tool()
    async def lookup_weather(self, context: RunContext, location: str) -> dict:
        return {"weather": "sunny", "temperature_f": 70}
Event Handling: You’ll see decorators like
@emitter.on
used to register event listeners. • RPC Method Registration: The
@room.local_participant.register_rpc_method
decorator helps define those handy RPC methods. • Storybook Decorators: These are great for testing and development within the components library. If you’re hunting for a particular decorator or want to dive deeper into how something works, just give me a shout—I’m here to help! Sources: Tool definition and use | LiveKit Docs | Agents v0.x migration guide | LiveKit Docs | livekit-rtc/livekit/rtc/event_emitter.py | docs/storybook/.storybook/lk-decorators/MockParticipantContext.tsx | mcp_client/agent_tools.py