little-king-41579
12/16/2025, 6:48 PMtall-airline-16756
12/16/2025, 6:48 PMtall-airline-16756
12/16/2025, 6:49 PMint) in the function signature:
from livekit.agents import function_tool
@function_tool()
async def set_timer(self, duration_seconds: int):
"""Set a timer for a specified number of seconds."""
print(f"Timer set for {duration_seconds} seconds")
return f"Timer set for {duration_seconds} seconds"
If Node.js, use Zod to declare an integer parameter:
import { llm } from '@livekit/agents';
import { z } from 'zod';
const setTimer = llm.tool({
description: 'Set a timer for a specified number of seconds.',
parameters: z.object({
durationSeconds: z.number().int().describe('The number of seconds for the timer'),
}),
execute: async ({ durationSeconds }) => {
console.log(`Timer set for ${durationSeconds} seconds`);
return `Timer set for ${durationSeconds} seconds`;
},
});
The LLM extracts and converts the integer from user input automatically and passes it to your function. Do you need examples showing validation (min/max) or handling non-integer user input?
Sources: Tool definition and use | LiveKit docs