diff --git a/python/copilot/generated/session_events.py b/python/copilot/generated/session_events.py index f2e155f49..604a165c3 100644 --- a/python/copilot/generated/session_events.py +++ b/python/copilot/generated/session_events.py @@ -51,8 +51,8 @@ def from_timedelta(x: Any) -> timedelta: def to_timedelta_int(x: timedelta) -> int: assert isinstance(x, timedelta) milliseconds = x.total_seconds() * 1000.0 - assert milliseconds.is_integer() - return int(milliseconds) + # Durations can carry sub-millisecond precision; round to the nearest whole ms. + return round(milliseconds) def to_timedelta(x: timedelta) -> float: diff --git a/scripts/codegen/python.ts b/scripts/codegen/python.ts index 0ba72db50..280e185cb 100644 --- a/scripts/codegen/python.ts +++ b/scripts/codegen/python.ts @@ -2538,8 +2538,8 @@ export function generatePythonSessionEventsCode(schema: JSONSchema7): string { out.push(`def to_timedelta_int(x: timedelta) -> int:`); out.push(` assert isinstance(x, timedelta)`); out.push(` milliseconds = x.total_seconds() * 1000.0`); - out.push(` assert milliseconds.is_integer()`); - out.push(` return int(milliseconds)`); + out.push(` # Durations can carry sub-millisecond precision; round to the nearest whole ms.`); + out.push(` return round(milliseconds)`); out.push(``); out.push(``); }