sgl-project/sglang · error · ValueError
name must be provided
Error message
name must be provided
What it means
process_name_for_reasoning builds a '<name>_reasoning_content' output key from a generation expression's name and requires a non-empty name. When expr.name is None/empty (e.g. sgen called without name=), ValueError is raised because there is no key to attach reasoning output to.
Source
Thrown at python/sglang/lang/ir.py:630
def __init__(self):
super().__init__()
def __repr__(self):
return "CommitLazy()"
class SglSeparateReasoning(SglExpr):
def __init__(self, model_type: str, expr: SglExpr):
super().__init__()
self.model_type = model_type
self.expr = expr
self.name = None
self._process_expr(expr)
def process_name_for_reasoning(self, name):
if not name:
raise ValueError("name must be provided")
return f"{name}_reasoning_content"
def _process_expr(self, expr):
if isinstance(expr, SglGen):
self.name = self.process_name_for_reasoning(expr.name)
elif isinstance(expr, SglSelect):
self.name = self.process_name_for_reasoning(expr.name)
elif isinstance(expr, SglExprList):
for x in expr.expr_list:
self._process_expr(x)
def __repr__(self):
return f"SeparateReasoning(model_type={self.model_type}, name={self.name})"
View on GitHub (pinned to 0132848349)
Solutions
- Pass an explicit name to the generation call: sgen(..., name="answer")
- Check that every gen/select inside the function that reasoning applies to has a unique non-empty name
Example fix
# before
gen("...", temperature=0.7)
# after
gen("...", name="answer", temperature=0.7) Defensive patterns
Strategy: validation
Validate before calling
if not getattr(gen_expr, "name", None):
gen_expr.name = "answer" # or raise early with context
result = separate_reasoning(gen_expr) Try / catch
try:
out = separate_reasoning(expr)
except ValueError as e:
if "name must be provided" in str(e):
expr.name = expr.name or "answer"
out = separate_reasoning(expr)
else:
raise Prevention
- Always pass name= to every gen()/select() that reasoning will read from
- Write a test asserting all named generations before enabling reasoning separation
When it happens
Trigger: Using separate reasoning (e.g. _execute_separate_reasoning path) with a SglGen/SglSelect expression that was created without a name parameter, so process_name_for_reasoning receives a falsy name.
Common situations: Adding sgen(...) calls without name="..." in an SGL function and then enabling reasoning separation; relying on older code where names were auto-generated.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- invalid reasoning effort: {effort!r}
- invalid Inkling reasoning_effort: {value!r}
- v_cache must be provided
- q can only be None when only_qv=True
- q must be provided unless qv is provided with only_qv=True
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6e980e03b4743d4b.
Report an issue: GitHub.