mirror of
https://github.com/usestrix/strix.git
synced 2026-08-16 09:26:39 +02:00
fix(context): reject tool-output byte ceilings below the notice size
A configured tool_output_max_bytes smaller than the truncation notice itself can't fit a bounded preview, so a persisted result could exceed the ceiling. Enforce a config floor (ge=1024) so nonsensical values are rejected at load time instead of being worked around at runtime.
This commit is contained in:
@@ -6,10 +6,11 @@ import json
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from pydantic import AliasChoices, Field
|
||||
from pydantic import AliasChoices, Field, ValidationError
|
||||
from pydantic.fields import FieldInfo
|
||||
|
||||
from strix.config import loader
|
||||
from strix.config.settings import ContextSettings
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -120,6 +121,22 @@ def test_read_json_overrides_uses_json_when_no_alias_in_environ(tmp_path: Path)
|
||||
assert loader._read_json_overrides(path) == {"llm": {"api_key": "sk-file"}}
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# ContextSettings validation
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
|
||||
def test_tool_output_max_bytes_rejects_sub_notice_values() -> None:
|
||||
# A ceiling below the truncation notice can't fit a bounded preview, so it
|
||||
# is rejected at load time rather than producing over-cap persisted output.
|
||||
with pytest.raises(ValidationError):
|
||||
ContextSettings(STRIX_TOOL_OUTPUT_MAX_BYTES=64)
|
||||
|
||||
|
||||
def test_tool_output_max_bytes_accepts_floor() -> None:
|
||||
assert ContextSettings(STRIX_TOOL_OUTPUT_MAX_BYTES=1024).tool_output_max_bytes == 1024
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# _aliases_for
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user