Description
When using function_tool decorator on a function with no parameters, the generated JSON schema is rejected by Groq's API (and potentially other strict OpenAI-compatible APIs).
Error Messages
First error:
Invalid schema for function 'django_health': In context=('properties', 'kwargs'),
schema must have a 'type' key.
After removing **kwargs:
invalid JSON schema for tool django_health, tools[4].function.parameters:
'required' present but 'properties' is missing
Root Cause
Groq (and other strict OpenAI-compatible APIs) require this structure even for parameterless tools:
{
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}
But function_tool generates an incomplete schema missing type and/or properties when there are no parameters.
Reproduction
from livekit.agents import function_tool
@function_tool(name="health_check", description="Check system health")
async def health_check() -> str:
return "OK"
# Use with Groq LLM - will fail with schema error
Workaround
Use the raw_schema parameter to explicitly define the schema for parameterless functions:
from livekit.agents import function_tool
async def health_check(raw_arguments: dict) -> str:
return "OK"
raw_schema = {
"name": "health_check",
"description": "Check system health",
"parameters": {
"type": "object",
"properties": {},
"required": [],
},
}
tool = function_tool(raw_schema=raw_schema)(health_check)
This bypasses the automatic schema generation and provides the exact JSON schema that Groq requires.
Note: When using raw_schema, the function receives parameters via a raw_arguments: dict parameter instead of individual arguments.
Expected Behavior
function_tool should generate valid JSON schemas for parameterless functions that work with all LLM providers, including Groq.
Environment
- livekit-agents version: latest
- LLM: Groq (via
livekit.plugins.groq or OpenAI-compatible endpoint)
- Python: 3.13
Description
When using
function_tooldecorator on a function with no parameters, the generated JSON schema is rejected by Groq's API (and potentially other strict OpenAI-compatible APIs).Error Messages
First error:
After removing
**kwargs:Root Cause
Groq (and other strict OpenAI-compatible APIs) require this structure even for parameterless tools:
{ "parameters": { "type": "object", "properties": {}, "required": [] } }But
function_toolgenerates an incomplete schema missingtypeand/orpropertieswhen there are no parameters.Reproduction
Workaround
Use the
raw_schemaparameter to explicitly define the schema for parameterless functions:This bypasses the automatic schema generation and provides the exact JSON schema that Groq requires.
Note: When using
raw_schema, the function receives parameters via araw_arguments: dictparameter instead of individual arguments.Expected Behavior
function_toolshould generate valid JSON schemas for parameterless functions that work with all LLM providers, including Groq.Environment
livekit.plugins.groqor OpenAI-compatible endpoint)