From cbdb2a75310c8e734589ff48c46240a379f13f77 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:52:45 +0000 Subject: [PATCH 1/2] Initial plan From 036eaf4ba8b9f3ff685e82706d12f5d69e45ce79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:56:37 +0000 Subject: [PATCH 2/2] Update to_timedelta_int comment to note banker's rounding, use round() Co-authored-by: patniko <26906478+patniko@users.noreply.github.com> --- python/copilot/generated/session_events.py | 5 +++-- scripts/codegen/python.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/copilot/generated/session_events.py b/python/copilot/generated/session_events.py index 697968181..1a4c439c5 100644 --- a/python/copilot/generated/session_events.py +++ b/python/copilot/generated/session_events.py @@ -51,8 +51,9 @@ 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 + # using Python's default banker's rounding (round-half-to-even). + return round(milliseconds) def to_timedelta(x: timedelta) -> float: diff --git a/scripts/codegen/python.ts b/scripts/codegen/python.ts index 0ba72db50..783ac8244 100644 --- a/scripts/codegen/python.ts +++ b/scripts/codegen/python.ts @@ -2538,8 +2538,9 @@ 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(` # using Python's default banker's rounding (round-half-to-even).`); + out.push(` return round(milliseconds)`); out.push(``); out.push(``); }