sgl-project/sglang · error · ValueError

Cosmos3 action endpoint supports action_mode='policy' or 'in

Error message

Cosmos3 action endpoint supports action_mode='policy' or 'inverse_dynamics'

What it means

The Cosmos3 action endpoint only supports action_mode values 'policy' and 'inverse_dynamics'. After lowercasing/trimming the merged action_mode option, any other value (except forward_dynamics which gets its own message) raises this error. It guards the downstream dispatch that assumes one of the two action modes.

Source

Thrown at python/sglang/multimodal_gen/runtime/entrypoints/action/cosmos3.py:141

        )
    return prompts[0] if batch_size == 1 else prompts


def build_cosmos3_action_sampling_params(
    payload: dict[str, Any],
    observation: dict[str, Any],
    server_args: ServerArgs,
    sampling_params_cls: type[Cosmos3SamplingParams],
) -> Cosmos3SamplingParams:
    parameters = dict(payload.get("parameters") or {})
    options = {**observation, **parameters}
    action_mode = str(options.get("action_mode", "policy")).strip().lower()
    if action_mode == "forward_dynamics":
        raise ValueError(
            "Cosmos3 forward_dynamics produces video; use /v1/videos instead"
        )
    if action_mode not in ("policy", "inverse_dynamics"):
        raise ValueError(
            "Cosmos3 action endpoint supports action_mode='policy' or "
            "'inverse_dynamics'"
        )

    action_horizon = options.get("action_horizon")
    num_frames = options.get("num_frames")
    if action_horizon is None and num_frames is None:
        action_horizon = 16
    if action_horizon is not None:
        action_horizon = int(action_horizon)
        if action_horizon <= 0:
            raise ValueError("action_horizon must be a positive integer")
        expected_num_frames = action_horizon + 1
        if num_frames is not None and int(num_frames) != expected_num_frames:
            raise ValueError(
                "Cosmos3 requires num_frames == action_horizon + 1, got "
                f"num_frames={num_frames}, action_horizon={action_horizon}"
            )

View on GitHub (pinned to 0132848349)

Solutions

  1. Set action_mode to 'policy' or 'inverse_dynamics' (or omit it — default is 'policy')
  2. Check for typos and stray whitespace/case (the code strips and lowercases, so 'Policy ' works but 'polcy' does not)

Example fix

# before
{"parameters": {"action_mode": "polcy"}}
# after
{"parameters": {"action_mode": "policy"}}
Defensive patterns

Strategy: validation

Validate before calling

mode = str(params.get('action_mode','policy')).strip().lower()
assert mode in ('policy','inverse_dynamics'), f'bad action_mode: {mode!r}'

Type guard

def is_valid_action_mode(m) -> bool:
    return str(m).strip().lower() in ('policy', 'inverse_dynamics')

Prevention

When it happens

Trigger: action_mode set to 'random', 'policy_v2', '', or a typo like 'polcy' in parameters or observation of a /v1/actions request.

Common situations: Typos in configs; new/unsupported modes expected from other robot foundation models; empty string default leaking from a config template.

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/04d1265981c48137. Report an issue: GitHub.