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:
Ahmed Allam
2026-07-25 23:46:11 +00:00
parent aac59de1e5
commit 95046a6cea
3 changed files with 25 additions and 3 deletions
+5 -1
View File
@@ -69,7 +69,11 @@ class ContextSettings(BaseSettings):
summary_max_tokens: int = Field(default=4_096, gt=0, alias="STRIX_CONTEXT_SUMMARY_TOKENS")
tool_output_max_tokens: int = Field(default=8_000, gt=0, alias="STRIX_TOOL_OUTPUT_MAX_TOKENS")
tool_output_max_lines: int = Field(default=2_000, gt=0, alias="STRIX_TOOL_OUTPUT_MAX_LINES")
tool_output_max_bytes: int = Field(default=50 * 1024, gt=0, alias="STRIX_TOOL_OUTPUT_MAX_BYTES")
# Floor comfortably above the truncation-notice size so a preview
# (head+tail+notice) always fits within the configured ceiling.
tool_output_max_bytes: int = Field(
default=50 * 1024, ge=1024, alias="STRIX_TOOL_OUTPUT_MAX_BYTES"
)
class RuntimeSettings(BaseSettings):
+2 -1
View File
@@ -49,7 +49,8 @@ def bound_text(text: str, *, max_lines: int, max_bytes: int) -> str:
byte size). The removed middle is replaced with a notice recording how
many lines and bytes were dropped so the agent knows output was elided.
``max_bytes`` bounds the *entire* joined result, notice and separators
included.
included, and must be large enough to hold the notice itself (guaranteed by
the ``tool_output_max_bytes`` config floor).
"""
lines = text.split("\n")
total_bytes = _byte_len(text)