{"record":{"id":"492fdd3ae264e112","repo":"sgl-project/sglang","slug":"unknown-cacheagnostic-policy-policy","errorCode":null,"errorMessage":"Unknown CacheAgnostic Policy: {policy=}","messagePattern":"Unknown CacheAgnostic Policy: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/schedule_policy.py","lineNumber":288,"sourceCode":"                SchedulePolicy._sort_by_dfs_weight(waiting_queue, self.tree_cache)\n            else:\n                raise ValueError(f\"Unknown CacheAware Policy: {policy=}\")\n        else:\n            if policy == CacheAgnosticPolicy.FCFS:\n                pass\n            elif policy == CacheAgnosticPolicy.LOF:\n                SchedulePolicy._sort_by_longest_output(\n                    waiting_queue,\n                    self.enable_priority_scheduling,\n                    self.priority_sign,\n                )\n            elif policy == CacheAgnosticPolicy.RANDOM:\n                SchedulePolicy._sort_randomly(waiting_queue)\n            elif policy == CacheAgnosticPolicy.ROUTING_KEY:\n                if running_batch is not None:\n                    SchedulePolicy._sort_by_routing_key(waiting_queue, running_batch)\n            else:\n                raise ValueError(f\"Unknown CacheAgnostic Policy: {policy=}\")\n\n    def _determine_active_policy(self, waiting_queue: List[Req]) -> Policy:\n        if self.policy == CacheAwarePolicy.LPM and len(waiting_queue) > 128:\n            # Turn off the expensive prefix matching and sorting when the #queue is large.\n            return CacheAgnosticPolicy.FCFS\n        return self.policy\n\n    def waiting_queue_prefix_matched(self, waiting_queue: List[Req]) -> bool:\n        policy = self._determine_active_policy(waiting_queue)\n        return (\n            isinstance(policy, CacheAwarePolicy)\n            or self.tree_cache.supports_fast_match_prefix()\n        )\n\n    def _validate_and_adjust_policy(\n        self, policy: str, tree_cache: BasePrefixCache\n    ) -> Policy:\n        \"\"\"","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/schedule_policy.py#L270-L306","documentation":"The cache-agnostic branch of SchedulePolicy.calc_priority failed to match the policy against FCFS, LOF, RANDOM, or ROUTING_KEY, so the waiting-queue sort dispatch aborts.","triggerScenarios":"A policy that is neither a CacheAwarePolicy nor one of the known CacheAgnosticPolicy values reaches calc_priority; e.g. a new or misspelled policy string passed via schedule_policy.","commonSituations":"Version drift between the policy list accepted by _validate_and_adjust_policy / CLI and the branches handled here; custom forks adding policies without updating the dispatch.","solutions":["Verify --schedule-policy against CacheAgnosticPolicy members (fcfs, lof, random, routing-key)","Check that _validate_and_adjust_policy correctly maps the string to an enum","Add the missing elif branch if you extended the enum in a fork"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from sglang.srt.managers.schedule_policy import CacheAgnosticPolicy\nvalid = {p.value for p in CacheAgnosticPolicy} | {p.value for p in CacheAwarePolicy}\nassert policy in valid","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize allowed schedule-policy values in one config constant","Log the effective enum set on startup"],"tags":["scheduling","config","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}