Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

2.9 KB
Raw Blame
"""Focused tests for the ``llm.request_timeout`` shared default setting."""

from local_deep_research.settings.manager import SettingsManager


def test_llm_request_timeout_default_metadata():
    """The default carries the shared editable numeric contract.

    Given the JSON defaults loaded by SettingsManager with no DB,
    when the ``llm.request_timeout`` entry is selected,
    then its projected metadata dict matches the expected contract.
    """
    # Given
    defaults = SettingsManager(db_session=None).default_settings

    # When
    setting = defaults["llm.request_timeout"]

    # Then
    projected_keys = (
        "category",
        "editable",
        "max_value",
        "min_value",
        "name",
        "options",
        "step",
        "type",
        "ui_element",
        "value",
        "visible",
    )
    projected = {key: setting[key] for key in projected_keys}
    assert projected == {
        "category": "llm_parameters",
        "editable": True,
        "max_value": None,
        "min_value": 1,
        "name": "LLM Request Inactivity Timeout (seconds)",
        "options": None,
        "step": 1,
        "type": "LLM",
        "ui_element": "number",
        "value": 1800,
        "visible": True,
    }


def test_llm_max_retries_default_metadata():
    """``llm.max_retries`` is declared with enforceable bounds.

    Given the JSON defaults loaded by SettingsManager with no DB,
    when the ``llm.max_retries`` entry is selected,
    then it carries numeric bounds on the number of additional attempts.
    Per-operation timeouts and SDK retry delays also affect elapsed time.
    """
    # Given
    defaults = SettingsManager(db_session=None).default_settings

    # When
    setting = defaults["llm.max_retries"]

    # Then
    assert setting["ui_element"] == "number"
    assert setting["min_value"] == 0
    assert setting["max_value"] == 5
    assert setting["value"] == 2
    assert setting["editable"] is True


def test_llm_request_timeout_description_does_not_promise_a_total_bound():
    """The description must describe a per-operation bound, not a total one."""
    # Given
    defaults = SettingsManager(db_session=None).default_settings

    # When
    description = defaults["llm.request_timeout"]["description"]

    # Then
    assert "Per-operation" in description
    assert "it is not a cap on the total duration of a response" in description
    assert "embedding" in description


def test_llm_request_timeout_description_scopes_discovery_limits():
    # Given
    defaults = SettingsManager(db_session=None).default_settings

    # When
    description = defaults["llm.request_timeout"]["description"]

    # Then
    assert (
        "OpenAI-compatible providers and Anthropic use 30 seconds"
        in description
    )
    assert (
        "Google and Ollama retain provider-specific limits of 10 and 5 seconds"
        in description
    )