mirror of
https://github.com/usestrix/strix.git
synced 2026-08-24 03:42:37 +02:00
fix(context): clamp shell output cap and count byte-trimmed dropped lines
Treat tool_output_max_tokens as a ceiling so an explicit model-supplied cap can't exceed it, and derive the truncation notice's dropped-line count from the lines actually kept after the byte-trim pass. Also cast the pygments fallback lexer so it satisfies the resolve_lexer return type under the pre-commit mypy hook.
This commit is contained in:
@@ -41,7 +41,7 @@ async def test_wrap_exec_command_defaults_shell_to_bash() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_wrap_exec_command_preserves_explicit_output_cap() -> None:
|
||||
async def test_wrap_exec_command_preserves_smaller_explicit_output_cap() -> None:
|
||||
captured: dict[str, str] = {}
|
||||
wrapped = factory._wrap_exec_command(_capturing_exec_tool(captured))
|
||||
|
||||
@@ -52,6 +52,20 @@ async def test_wrap_exec_command_preserves_explicit_output_cap() -> None:
|
||||
assert json.loads(captured["raw_input"])["max_output_tokens"] == 42
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_wrap_exec_command_clamps_oversized_explicit_output_cap() -> None:
|
||||
captured: dict[str, str] = {}
|
||||
wrapped = factory._wrap_exec_command(_capturing_exec_tool(captured))
|
||||
ceiling = load_settings().context.tool_output_max_tokens
|
||||
|
||||
await wrapped.on_invoke_tool(
|
||||
cast("Any", None),
|
||||
json.dumps({"cmd": "echo hi", "max_output_tokens": ceiling * 100}),
|
||||
)
|
||||
|
||||
assert json.loads(captured["raw_input"])["max_output_tokens"] == ceiling
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("shell", ["/bin/zsh", ""])
|
||||
async def test_wrap_exec_command_preserves_explicit_shell(shell: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user