refactor(sessions): accurate scope wording for tip-only resume rejections

SessionResumeTooLargeError said 'across its lineage' even when the CLI
mid-setup path counted only the tip segment; the exception now takes a
scope phrase.
This commit is contained in:
kshitij
2026-08-08 13:28:04 +05:30
parent edf2cb4bf8
commit a8ccd52123
2 changed files with 10 additions and 3 deletions
+3 -1
View File
@@ -617,7 +617,9 @@ class CLIAgentSetupMixin:
try:
tip_check(self.session_id, max_messages=limit)
except SessionExportTooLargeError as exc:
raise SessionResumeTooLargeError(exc.message_count, limit) from exc
raise SessionResumeTooLargeError(
exc.message_count, limit, scope="in its tip segment"
) from exc
else:
safety_check = getattr(self._session_db, "assert_resume_safe", None)
if not callable(safety_check):
+7 -2
View File
@@ -126,11 +126,16 @@ def resolved_max_export_messages() -> int:
class SessionResumeTooLargeError(ValueError):
def __init__(self, message_count: int, limit: int = MAX_SAFE_RESUME_MESSAGES):
def __init__(
self,
message_count: int,
limit: int = MAX_SAFE_RESUME_MESSAGES,
scope: str = "across its lineage",
):
self.message_count = message_count
self.limit = limit
super().__init__(
f"session has at least {message_count} active messages across its lineage; "
f"session has at least {message_count} active messages {scope}; "
f"safe resume limit is {limit}. Export the session instead, or set "
"sessions.max_resume_messages: 0 in config.yaml to disable the guard."
)