sgl-project/sglang · error · ValueError
Function tools must include a name.
Error message
Function tools must include a name.
What it means
ResponseTool.validate_function_tool requires that a tool of type 'function' has a non-empty name. The Responses-API tool object must carry the function name for the model to call it.
Source
Thrown at python/sglang/srt/entrypoints/openai/protocol.py:1566
"tool_search",
]
class ResponseTool(BaseModel):
"""Tool definition for responses."""
type: RESPONSE_TOOL_TYPES = Field(description="Type of tool to enable")
name: Optional[str] = None
description: Optional[str] = None
parameters: Optional[Dict[str, Any]] = None
strict: bool = False
# Inner schemas for ``namespace`` tools.
tools: Optional[List[Dict[str, Any]]] = None
@model_validator(mode="after")
def validate_function_tool(self) -> ResponseTool:
if self.type == "function" and not self.name:
raise ValueError("Function tools must include a name.")
return self
ResponseInputOutputItem: TypeAlias = Union[
ResponseInputItemParam,
"ResponseReasoningItem",
ResponseFunctionToolCall,
]
class ResponsesRequest(BaseModel):
"""Request body for v1/responses endpoint."""
# Core OpenAI API fields (ordered by official documentation)
background: Optional[bool] = False
include: Optional[
List[
Literal[View on GitHub (pinned to 0132848349)
Solutions
- Use the flat Responses-API tool shape: {"type":"function","name":"get_weather","parameters":{...}}
- If porting from chat completions, hoist function.name and function.parameters to the top level
Example fix
// before
{"tools": [{"type": "function", "function": {"name": "f"}}]}
// after
{"tools": [{"type": "function", "name": "f", "parameters": {...}}]} Defensive patterns
Strategy: type-guard
Validate before calling
for t in tools:
if t.get("type") == "function":
assert t.get("name"), "function tool needs a name" Type guard
def valid_response_tool(t): return t.get('type') != 'function' or bool(t.get('name')) Prevention
- Use the flat Responses-API tool schema, not nested chat-completions shape
- Add a unit test over your tool list
When it happens
Trigger: POST /v1/responses with tools=[{"type": "function"}] where name is missing or empty (older nested {'type':'function','function':{...}} shapes without a name also fail).
Common situations: Using the OpenAI Chat-Completions nested tool schema ({'type':'function','function':{...}}) on the Responses API which expects a flat schema; tools generated from JSON schemas that lack a top-level name.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Cannot combine tool calls with constrained decoding (text.fo
- Assistant tool call function.arguments must be a JSON object
- No browser tool call found
- v_cache must be provided
- q can only be None when only_qv=True
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/1742d69c35158cfd.
Report an issue: GitHub.