refactor(backend): move _BOUNDARY_SCAN_LIMIT to module level, logger.info -> debug

Move _BOUNDARY_SCAN_LIMIT from function body to module level to avoid
redefining it on every backward-pagination call. Downgrade GET_SESSION
per-request log from INFO to DEBUG to reduce noise at scale.
This commit is contained in:
Zamil Majdy
2026-04-15 20:57:46 +07:00
parent df3c4b381c
commit f9a33f2aa6
2 changed files with 3 additions and 2 deletions

View File

@@ -543,7 +543,7 @@ async def get_session(
_strip_injected_context(message.model_dump()) for message in page.messages
]
logger.info(
logger.debug(
"[GET_SESSION] session=%s, active=%s, from_start=%s, forward_paginated=%s, "
"msg_count=%d, last_role=%s",
session_id,

View File

@@ -30,6 +30,8 @@ from .model import get_chat_session as get_chat_session_cached
logger = logging.getLogger(__name__)
_BOUNDARY_SCAN_LIMIT = 10
class PaginatedMessages(BaseModel):
"""Result of a paginated message query."""
@@ -124,7 +126,6 @@ async def get_chat_messages_paginated(
# expand backward to include the preceding assistant message that
# owns the tool_calls, so convertChatSessionMessagesToUiMessages
# can pair them correctly.
_BOUNDARY_SCAN_LIMIT = 10
if results and results[0].role == "tool":
boundary_where: dict[str, Any] = {
"sessionId": session_id,