sgl-project/sglang · error · ValueError

output_format must be 'list' or 'numpy'

Error message

output_format must be 'list' or 'numpy'

What it means

The action endpoint's output_format option controls the returned action representation and only accepts 'list' or 'numpy' (case-insensitive after .lower()). Any other value is rejected before the request is submitted. The value is merged from parameters.output_format and observation.output_format, defaulting to 'list'.

Source

Thrown at python/sglang/multimodal_gen/runtime/entrypoints/action/protocol.py:342

        prefix_cache = observation.get("enable_prefix_cache")
    if prefix_cache is None:
        prefix_cache = observation.get("enable_pi_prefix_cache")
    cuda_graph = runtime.get("cuda_graph")
    if cuda_graph is None:
        cuda_graph = observation.get("enable_cuda_graph")
    if cuda_graph is None:
        cuda_graph = observation.get("enable_pi_cuda_graph")
    output_format = str(
        runtime.get(
            "output_format",
            parameters.get(
                "output_format",
                observation.get("output_format", "list"),
            ),
        )
    ).lower()
    if output_format not in ("list", "numpy"):
        raise ValueError("output_format must be 'list' or 'numpy'")

    sampling_kwargs = {
        "request_id": payload.get("request_id") or payload.get("id"),
        "prompt": prompt,
        "images": images,
        "image_masks": observation.get("image_masks"),
        "camera_order": observation.get("camera_order"),
        "state": state,
        "noise": noise,
        "observation": observation,
        "action_horizon": int(
            parameters.get(
                "action_horizon",
                observation.get("action_horizon", pipeline_config.action_horizon),
            )
        ),
        "action_dim": int(
            parameters.get(

View on GitHub (pinned to 0132848349)

Solutions

  1. Set output_format to 'list' or 'numpy'
  2. Or omit it — the default is 'list'
  3. Convert client-side: np.asarray(result.actions) if you need numpy from list output

Example fix

# before
{"parameters": {"output_format": "tensor"}}
# after
{"parameters": {"output_format": "numpy"}}
Defensive patterns

Strategy: validation

Validate before calling

fmt = str(params.get('output_format','list')).lower()
assert fmt in ('list','numpy'), "output_format must be 'list' or 'numpy'"

Type guard

def is_valid_output_format(f) -> bool:
    return str(f).lower() in ('list', 'numpy')

Prevention

When it happens

Trigger: POST /v1/actions with parameters.output_format='tensor', 'json', or 'torch'.

Common situations: Expecting torch.Tensor passthrough; typo like 'np' or 'Numpy arrays' (spaces are not stripped, only lowercased); stale config from another API.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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