{"record":{"id":"04d1265981c48137","repo":"sgl-project/sglang","slug":"cosmos3-action-endpoint-supports-action-mode-poli","errorCode":null,"errorMessage":"Cosmos3 action endpoint supports action_mode='policy' or 'inverse_dynamics'","messagePattern":"Cosmos3 action endpoint supports action_mode='policy' or 'inverse_dynamics'","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/action/cosmos3.py","lineNumber":141,"sourceCode":"        )\n    return prompts[0] if batch_size == 1 else prompts\n\n\ndef build_cosmos3_action_sampling_params(\n    payload: dict[str, Any],\n    observation: dict[str, Any],\n    server_args: ServerArgs,\n    sampling_params_cls: type[Cosmos3SamplingParams],\n) -> Cosmos3SamplingParams:\n    parameters = dict(payload.get(\"parameters\") or {})\n    options = {**observation, **parameters}\n    action_mode = str(options.get(\"action_mode\", \"policy\")).strip().lower()\n    if action_mode == \"forward_dynamics\":\n        raise ValueError(\n            \"Cosmos3 forward_dynamics produces video; use /v1/videos instead\"\n        )\n    if action_mode not in (\"policy\", \"inverse_dynamics\"):\n        raise ValueError(\n            \"Cosmos3 action endpoint supports action_mode='policy' or \"\n            \"'inverse_dynamics'\"\n        )\n\n    action_horizon = options.get(\"action_horizon\")\n    num_frames = options.get(\"num_frames\")\n    if action_horizon is None and num_frames is None:\n        action_horizon = 16\n    if action_horizon is not None:\n        action_horizon = int(action_horizon)\n        if action_horizon <= 0:\n            raise ValueError(\"action_horizon must be a positive integer\")\n        expected_num_frames = action_horizon + 1\n        if num_frames is not None and int(num_frames) != expected_num_frames:\n            raise ValueError(\n                \"Cosmos3 requires num_frames == action_horizon + 1, got \"\n                f\"num_frames={num_frames}, action_horizon={action_horizon}\"\n            )","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/action/cosmos3.py#L123-L159","documentation":"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.","triggerScenarios":"action_mode set to 'random', 'policy_v2', '', or a typo like 'polcy' in parameters or observation of a /v1/actions request.","commonSituations":"Typos in configs; new/unsupported modes expected from other robot foundation models; empty string default leaking from a config template.","solutions":["Set action_mode to 'policy' or 'inverse_dynamics' (or omit it — default is 'policy')","Check for typos and stray whitespace/case (the code strips and lowercases, so 'Policy ' works but 'polcy' does not)"],"exampleFix":"# before\n{\"parameters\": {\"action_mode\": \"polcy\"}}\n# after\n{\"parameters\": {\"action_mode\": \"policy\"}}","handlingStrategy":"validation","validationCode":"mode = str(params.get('action_mode','policy')).strip().lower()\nassert mode in ('policy','inverse_dynamics'), f'bad action_mode: {mode!r}'","typeGuard":"def is_valid_action_mode(m) -> bool:\n    return str(m).strip().lower() in ('policy', 'inverse_dynamics')","tryCatchPattern":null,"preventionTips":["Validate enums against the allowed set before sending","Omit action_mode when the default 'policy' is intended"],"tags":["cosmos3","action-mode","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}