feat(rag): retry a failed LLM request before the first token lands — BOR_LLM_RETRIES/BOR_LLM_RETRY_DELAY with a live 'retrying' status
This commit is contained in:
@@ -112,6 +112,41 @@ def test_max_output_tokens_env_override(monkeypatch) -> None:
|
||||
assert s.max_output_tokens == 1234
|
||||
|
||||
|
||||
def test_llm_retry_defaults(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Phase 67: a failed LLM request is retried by default — 3 retries
|
||||
with a flat 5 s delay (the TODO-locked values, no backoff)."""
|
||||
monkeypatch.delenv("BOR_LLM_RETRIES", raising=False)
|
||||
monkeypatch.delenv("BOR_LLM_RETRY_DELAY", raising=False)
|
||||
s = _settings()
|
||||
assert s.llm_retries == 3
|
||||
assert s.llm_retry_delay == 5.0
|
||||
|
||||
|
||||
def test_llm_retry_env_overrides(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""``BOR_LLM_RETRIES`` / ``BOR_LLM_RETRY_DELAY`` override the defaults;
|
||||
``0`` retries is the no-retry kill switch (pre-phase-67 behavior)."""
|
||||
monkeypatch.setenv("BOR_LLM_RETRIES", "0")
|
||||
monkeypatch.setenv("BOR_LLM_RETRY_DELAY", "1.5")
|
||||
s = _settings()
|
||||
assert s.llm_retries == 0
|
||||
assert s.llm_retry_delay == 1.5
|
||||
|
||||
|
||||
def test_llm_retries_rejects_negative(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""``0`` is the kill switch — a negative value is a typo, so the
|
||||
validator fails loudly at startup (the ``agent_max_rounds`` pattern)."""
|
||||
monkeypatch.setenv("BOR_LLM_RETRIES", "-1")
|
||||
with pytest.raises(ValidationError, match="llm_retries"):
|
||||
_settings()
|
||||
|
||||
|
||||
def test_llm_retry_delay_rejects_negative(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""A negative delay is a typo — fail loudly at startup."""
|
||||
monkeypatch.setenv("BOR_LLM_RETRY_DELAY", "-0.5")
|
||||
with pytest.raises(ValidationError, match="llm_retry_delay"):
|
||||
_settings()
|
||||
|
||||
|
||||
def test_agent_max_rounds_default_and_env_override(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Phase 45: the per-tool budgets are gone — ``BOR_AGENT_MAX_ROUNDS``
|
||||
(default 10) is the single agent-loop knob; ``0`` is the no-tools
|
||||
|
||||
Reference in New Issue
Block a user