square-yacht-21107
11/09/2025, 4:25 PMtall-airline-16756
11/09/2025, 4:25 PMtall-airline-16756
11/09/2025, 4:25 PMAgentTask class! You can simply call the complete() method on your task instance. This method lets you indicate that the task has finished by passing either a result or an exception.
Here’s a quick example:
if not self.done():
self.complete(GetEmailResult(email_address=self._current_email))
If you need to exit due to an error, you can do it like this:
if not self.done():
self.complete(Exception("Task terminated early due to an error"))
Just a few important things to keep in mind:
• You can only call complete() once; calling it more than once will raise a RuntimeError.
• Use complete(result) when the task succeeds, or complete(Exception(...)) if there’s an error.
• This method is designed for Python and isn’t available in Node.js.
If anything isn’t clear or if you’d like me to walk you through a full example, please don’t hesitate to ask — I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Workflows | LiveKit Docs | agents/src/voice/agent_activity.ts