fix: load paginated run history messages (#3305)

This commit is contained in:
Eilen Shin
2026-06-01 15:50:39 +08:00
committed by GitHub
parent 031d6fbcbe
commit 019bd16a06
9 changed files with 267 additions and 14 deletions
+15
View File
@@ -0,0 +1,15 @@
"""Shared pagination helpers for gateway routers."""
from __future__ import annotations
def trim_run_message_page(rows: list[dict], *, limit: int, after_seq: int | None) -> tuple[list[dict], bool]:
"""Trim a ``limit + 1`` run-message page while preserving page boundaries."""
has_more = len(rows) > limit
if not has_more:
return rows, False
if after_seq is not None:
return rows[:limit], True
return rows[-limit:], True