sgl-project/sglang · error · ValueError

Unknown input type: {response_msg['type']}

Error message

Unknown input type: {response_msg['type']}

What it means

parse_response_input only understands response input item types 'message', 'reasoning', and 'function_call'; anything else falls through to this ValueError. The type field of each response_msg dict is used as the dispatch key, so unsupported or misspelled types are rejected.

Source

Thrown at python/sglang/srt/entrypoints/harmony_utils.py:199

                call_response = prev_response
                break
        if call_response is None:
            raise ValueError(f"No call message found for {call_id}")
        msg = Message.from_author_and_content(
            Author.new(Role.TOOL, f"functions.{call_response.name}"),
            response_msg["output"],
        )
    elif response_msg["type"] == "reasoning":
        content = response_msg["content"]
        assert len(content) == 1
        msg = Message.from_role_and_content(Role.ASSISTANT, content[0]["text"])
    elif response_msg["type"] == "function_call":
        msg = Message.from_role_and_content(Role.ASSISTANT, response_msg["arguments"])
        msg = msg.with_channel("commentary")
        msg = msg.with_recipient(f"functions.{response_msg['name']}")
        msg = msg.with_content_type("json")
    else:
        raise ValueError(f"Unknown input type: {response_msg['type']}")
    return msg


def parse_response_output(output: ResponseOutputItem) -> Message:
    if isinstance(output, ResponseOutputMessage):
        role = output.role
        contents = [TextContent(text=c.text) for c in output.content]
        msg = Message.from_role_and_contents(role, contents)
        return msg
    elif isinstance(output, ResponseFunctionToolCall):
        msg = Message.from_role_and_content(Role.ASSISTANT, output.arguments)
        msg = msg.with_channel("commentary")
        msg = msg.with_recipient(output.name)
        msg = msg.with_content_type("json")
        return msg
    else:
        raise ValueError(f"Unknown output type: {type(output)}")

View on GitHub (pinned to 0132848349)

Solutions

  1. Filter or transform input items to only the supported types ('message', 'reasoning', 'function_call') before calling the API
  2. Fix the typo in the type discriminator field
  3. Upgrade sglang — newer parsers may accept additional item types

Example fix

# before
items = [{"type": "web_search_call", ...}, ...]
# after
items = [i for i in items if i["type"] in {"message", "reasoning", "function_call"}]
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED_INPUT_TYPES = {"message", "reasoning", "function_call"}
items = [i for i in items if i.get("type") in SUPPORTED_INPUT_TYPES]

Type guard

def is_supported_response_input(item) -> bool:
    return isinstance(item, dict) and item.get("type") in {"message", "reasoning", "function_call"}

Try / catch

try:
    msg = parse_response_input(item)
except ValueError:
    msg = None  # skip or log unsupported item

Prevention

When it happens

Trigger: Feeding _construct_input_messages_with_harmony a response item whose ['type'] is e.g. 'function_call_output' handled elsewhere, 'web_search_call', 'image', or a typo like 'FunctionCall'.

Common situations: Forwarding raw OpenAI Responses API item lists that include newer item types the parser doesn't handle; client-side typos in the discriminator field; version drift between the client's item schema and sglang's harmony parser.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/9c64251fd719c19f. Report an issue: GitHub.