white-room-9349
03/09/2026, 1:22 PMtall-airline-16756
03/09/2026, 1:22 PMtall-airline-16756
03/09/2026, 1:22 PMwhite-room-9349
03/09/2026, 1:23 PMtall-airline-16756
03/09/2026, 1:24 PM@function_tool()
async def lookup_weather(location: str) -> dict[str, Any]:
"""Look up weather for a given location. Only call when the user explicitly asks for current weather
or a forecast. Do not call to answer unrelated questions.
Args:
location: City and country (e.g. "London, UK").
Returns:
{ "weather": "...", "temperature_f": ... }
"""
...
1. Node.js (description + parameter schema)
const lookupWeather = llm.tool({
description: 'Look up weather. Call only when user asks about current weather or forecast.',
parameters: z.object({
location: z.string().describe("City and country (e.g., 'New York, US')"),
}),
execute: async ({ location }) => { ... },
});
When to add system-prompt guidance
• Use the system prompt for agent-wide rules such as tone, whether to ask clarifying questions before calling tools, or general ordering (e.g., “collect inputs first”).
• Keep that guidance high level — don’t duplicate parameter-level rules.
Single source of truth recommendation
• Treat the tool definition as the canonical place for tool behavior.
• If you need a central registry for documentation, you can generate docs from the tool definitions (so the registry mirrors the canonical definitions rather than becoming a separate writable source).
If you want, I can:
• Review one of your existing tool definitions and suggest edits to make the usage guidance clearer.
• Show how to generate a human-readable tools registry from your code definitions.
Which would you prefer: a review of a specific tool definition, or an example registry generation approach?
Sources: Tool definition and use | LiveKit Documentation | Prompting guide | LiveKit Documentation | Logic and structure overview | LiveKit Documentation