fix(compression): reject boolean fast caps
This commit is contained in:
@@ -8515,8 +8515,9 @@ def _compression_config_claims_fast_lane(config: Dict[str, Any]) -> bool:
|
||||
provider = str(config.get("provider") or "").strip().lower()
|
||||
model = str(config.get("model") or "").strip().lower()
|
||||
effort = str(config.get("reasoning_effort") or "").strip().lower()
|
||||
raw_cap = config.get("max_output_tokens")
|
||||
try:
|
||||
cap = int(config.get("max_output_tokens") or 0)
|
||||
cap = 0 if isinstance(raw_cap, bool) else int(raw_cap or 0)
|
||||
except (TypeError, ValueError):
|
||||
cap = 0
|
||||
return (
|
||||
|
||||
@@ -219,6 +219,39 @@ def test_uncertified_effective_primary_route_does_not_receive_fast_cap():
|
||||
assert "reasoning" not in request.get("extra_body", {})
|
||||
|
||||
|
||||
def test_boolean_cap_drift_stays_uncapped_and_preserves_existing_reasoning():
|
||||
from agent.auxiliary_client import call_llm
|
||||
|
||||
config = {
|
||||
"provider": "ollama",
|
||||
"model": "qwen3:8b",
|
||||
"reasoning_effort": "none",
|
||||
"max_output_tokens": True,
|
||||
}
|
||||
client = MagicMock()
|
||||
client.base_url = "http://127.0.0.1:11434/v1"
|
||||
response = object()
|
||||
client.chat.completions.create.return_value = response
|
||||
|
||||
with (
|
||||
patch("agent.auxiliary_client._get_auxiliary_task_config", return_value=config),
|
||||
patch(
|
||||
"agent.auxiliary_client._get_cached_client",
|
||||
return_value=(client, "server-selected-model"),
|
||||
),
|
||||
patch("agent.auxiliary_client._validate_llm_response", return_value=response),
|
||||
):
|
||||
assert call_llm(
|
||||
task="compression",
|
||||
messages=[{"role": "user", "content": "summary request"}],
|
||||
) is response
|
||||
|
||||
request = client.chat.completions.create.call_args.kwargs
|
||||
assert "max_tokens" not in request
|
||||
assert "max_completion_tokens" not in request
|
||||
assert request["extra_body"]["reasoning"] == {"enabled": False}
|
||||
|
||||
|
||||
def test_bedrock_converse_ttfp_waits_for_the_nonstreaming_response():
|
||||
from agent.auxiliary_client import BedrockAuxiliaryClient, call_llm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user