{"record":{"id":"a59d785c01b9c5cc","repo":"sgl-project/sglang","slug":"action-horizon-must-be-a-positive-integer","errorCode":null,"errorMessage":"action_horizon must be a positive integer","messagePattern":"action_horizon must be a positive integer","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/action/cosmos3.py","lineNumber":153,"sourceCode":"    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            )\n        num_frames = expected_num_frames\n    else:\n        num_frames = int(num_frames)\n        if num_frames <= 1:\n            raise ValueError(\"Cosmos3 action num_frames must be greater than 1\")\n    if (num_frames - 1) % 4 != 0:\n        raise ValueError(\n            \"Cosmos3 action_horizon must be divisible by 4 so num_frames \"\n            \"is compatible with the temporal VAE\"\n        )\n\n    images = _images_from_observation(observation)","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/action/cosmos3.py#L135-L171","documentation":"Cosmos3 requires action_horizon to be a positive integer (>0) when provided (defaulting to 16 if neither action_horizon nor num_frames is given). The value is coerced with int() before validation. Zero or negative horizons are meaningless for action chunk generation and are rejected up front.","triggerScenarios":"Passing parameters.action_horizon=0, -4, or a value that int()-coerces to <=0 (e.g. '-1'); passing num_frames alone doesn't trigger this branch.","commonSituations":"Config templates defaulting numeric fields to 0; arithmetic computing horizon from a window size that collapses to 0; sending floats like 0.0.","solutions":["Set action_horizon to a positive integer (typical valid values are multiples of 4 like 16)","If computing it dynamically, guard: action_horizon = max(1, computed_value)","Remember the default of 16 applies only when both action_horizon and num_frames are absent"],"exampleFix":"# before\n{\"parameters\": {\"action_horizon\": 0}}\n# after\n{\"parameters\": {\"action_horizon\": 16}}","handlingStrategy":"validation","validationCode":"h = params.get('action_horizon')\nif h is not None:\n    assert int(h) > 0, 'action_horizon must be positive'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate positive-integer numeric params client-side","Remember the default of 16 when both horizon and num_frames are omitted"],"tags":["cosmos3","action-horizon","numeric-validation"],"backgroundTag":"invalid-parameter-range","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}