mirror of
https://github.com/usestrix/strix.git
synced 2026-08-22 02:58:39 +02:00
fix(context): reserve continuation-hint bytes within the retrieval page ceiling
A full non-final retrieval page consumed the entire byte budget and then appended the pagination hint, so the returned result (which bypasses the result-bounding wrapper) exceeded the ceiling. Reserve the hint's bytes out of the page budget so content plus hint always fits.
This commit is contained in:
@@ -6,6 +6,7 @@ import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from strix.tools.output_store import (
|
||||
_PAGE_MAX_BYTES,
|
||||
bound_and_store,
|
||||
bound_text,
|
||||
configure_output_store,
|
||||
@@ -125,6 +126,21 @@ def test_read_stored_output_paginates(tmp_path: Path) -> None:
|
||||
assert "offset=10" in page
|
||||
|
||||
|
||||
def test_read_stored_output_page_including_hint_stays_within_ceiling(tmp_path: Path) -> None:
|
||||
# A full non-final page plus its continuation hint must not exceed the page
|
||||
# ceiling — retrieval bypasses the general result-bounding wrapper.
|
||||
configure_output_store(tmp_path)
|
||||
text = "x" * (_PAGE_MAX_BYTES * 3)
|
||||
output_id = re.search(
|
||||
r'output_id="([0-9a-f]{32})"',
|
||||
bound_and_store(text, max_lines=4, max_bytes=1_000),
|
||||
)
|
||||
assert output_id is not None
|
||||
page = read_stored_output(output_id.group(1), offset=0, limit=_PAGE_MAX_BYTES)
|
||||
assert "more;" in page # a hint was appended (non-final page)
|
||||
assert len(page.encode("utf-8")) <= _PAGE_MAX_BYTES
|
||||
|
||||
|
||||
def test_read_stored_output_pages_long_lines_losslessly(tmp_path: Path) -> None:
|
||||
# A single line far larger than the page budget must be split across pages
|
||||
# (never returned whole), and paging forward must reconstruct the output
|
||||
|
||||
Reference in New Issue
Block a user