diff --git a/python/sglang/srt/function_call/utils.py b/python/sglang/srt/function_call/utils.py index f36179a9f..072bf50a2 100644 --- a/python/sglang/srt/function_call/utils.py +++ b/python/sglang/srt/function_call/utils.py @@ -209,6 +209,15 @@ def _partial_json_loads(input_str: str, flags: Allow) -> Tuple[Any, int]: obj, end = JSONDecoder().raw_decode(input_str, start) return obj, end raise + except AssertionError as e: + # partial_json_parser.fix_fast() asserts on some partial/ambiguous inputs + # (e.g. trailing non-whitespace after an otherwise-fixable prefix) instead + # of signaling "incomplete". Convert to JSONDecodeError so streaming + # callers treat it as not-yet-complete (wait for more tokens) rather than + # raising and failing the request. + raise JSONDecodeError( + "partial_json_parser assertion (treat as incomplete)", input_str, 0 + ) from e def _is_complete_json(input_str: str) -> bool: