fix(llm): configurable call timeout; one failed triage call is not "model down" #588

Merged
sharang merged 1 commits from fix/llm-timeout-triage-retry into main 2026-11-04 08:10:48 +00:00
Owner

Found in the first Prüfwerk round on our own repos (bp-smoketest on prod, backlog t49).

Problem

  • Timeout mismatch. LlmClient had a fixed 300 s total timeout; LiteLLM's request timeout is 600 s (its 408s end at exactly 600 s). On prod on 03.11., with two scans running, successful calls took 57 s at the median and 235 s at p95, and 22 calls took over 240 s. Calls past 300 s were dropped by Prüfwerk while the gateway kept generating them, which kept the model busy for the next calls.
  • One failed triage call counted as "model down". ask_in_chunks stopped every further try when all calls in a group failed. A scan with 10 or fewer findings sends one call per try, so a single timeout skipped the retries, including the one-by-one try for critical and high findings. On prod: factory-intake 1 and travelpwa 3 critical/high findings were left with "skipped: no answer".

Change

  • LLM_TIMEOUT_SECS (default 600): total time per LLM call, set via LlmClient::with_timeout. Documented in .env.example.
  • Triage takes the model as down only when at least two calls in flight fail at once (MODEL_DOWN_AFTER). With a model that is really down, a small scan now costs up to two more timed-out calls before the one-by-one try. A large scan still stops after the first group.

Tests

  • New: one_failed_call_still_asks_the_severe_findings_one_by_one.
  • a_model_that_is_down_… now uses 15 findings (two calls fail together).
  • …goes_down_midway… expects one more call: the lone failed fifth chunk is asked once more.
  • cargo test -p compliance-agent --lib llm:: and -p compliance-core --lib pass; clippy for core and agent is clean.

Deploy note

After the merge, pruefwerk-prod gets the 600 s default without any config change.

🤖 Generated with Claude Code

Found in the first Prüfwerk round on our own repos (bp-smoketest on prod, backlog t49). ## Problem - **Timeout mismatch.** `LlmClient` had a fixed 300 s total timeout; LiteLLM's request timeout is 600 s (its 408s end at exactly 600 s). On prod on 03.11., with two scans running, successful calls took 57 s at the median and 235 s at p95, and 22 calls took over 240 s. Calls past 300 s were dropped by Prüfwerk while the gateway kept generating them, which kept the model busy for the next calls. - **One failed triage call counted as "model down".** `ask_in_chunks` stopped every further try when all calls in a group failed. A scan with 10 or fewer findings sends one call per try, so a single timeout skipped the retries, including the one-by-one try for critical and high findings. On prod: factory-intake 1 and travelpwa 3 critical/high findings were left with "skipped: no answer". ## Change - `LLM_TIMEOUT_SECS` (default 600): total time per LLM call, set via `LlmClient::with_timeout`. Documented in `.env.example`. - Triage takes the model as down only when at least two calls in flight fail at once (`MODEL_DOWN_AFTER`). With a model that is really down, a small scan now costs up to two more timed-out calls before the one-by-one try. A large scan still stops after the first group. ## Tests - New: `one_failed_call_still_asks_the_severe_findings_one_by_one`. - `a_model_that_is_down_…` now uses 15 findings (two calls fail together). - `…goes_down_midway…` expects one more call: the lone failed fifth chunk is asked once more. - `cargo test -p compliance-agent --lib llm::` and `-p compliance-core --lib` pass; clippy for core and agent is clean. ## Deploy note After the merge, pruefwerk-prod gets the 600 s default without any config change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-03 14:43:45 +00:00
fix(llm): configurable call timeout; one failed triage call is not "model down"
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 3m49s
CI / Check (pull_request) Successful in 17m58s
c61368e8ff
Prüfwerk gave up on every LLM call after a fixed 300 s while LiteLLM keeps a
request for 600 s: under load (two scans, median 57 s, p95 235 s per call on
prod) calls were dropped that the gateway was still working on, and the
abandoned work kept the model busy.

- LLM_TIMEOUT_SECS (default 600, the gateway's request timeout) sets the total
  time per call; LlmClient::with_timeout.
- Triage takes the model as down only when at least two calls in flight fail
  at once. A small scan sends one call per try, so one timeout used to skip
  the retries, including the one-by-one try for critical and high findings
  (prod 03.11.: 4 critical/high findings left without a verdict).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang closed this pull request 2026-11-04 08:09:53 +00:00
sharang deleted branch fix/llm-timeout-triage-retry 2026-11-04 08:09:53 +00:00
sharang reopened this pull request 2026-11-04 08:10:20 +00:00
sharang merged commit 7d73893485 into main 2026-11-04 08:10:48 +00:00
Sign in to join this conversation.