Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f4c314d
feat(librarian): Module C retrieval upgrades (stack base for #1088)
northdpole Sep 29, 2026
8368601
Address review feedback on OIE librarian base.
northdpole Oct 5, 2026
70af687
feat(harvester): requirement extract and GitHub URL ingest
northdpole Sep 29, 2026
583e987
feat(oie): B2 eval harness and CRE neighborhood scorer
northdpole Sep 29, 2026
7fe303e
feat(librarian): LLM SafetyGuard for C.4 adversarial / update flags
northdpole Oct 7, 2026
62d0c4b
Address review feedback on harvester and GitHub URL ingest.
northdpole Oct 5, 2026
25f07e1
Address review feedback on B2 harness scripts.
northdpole Oct 5, 2026
955528d
chore(oie): ASVS 5.0 provisional B2 sources and gold
northdpole Sep 29, 2026
86d320a
chore(oie): NIST 800-53 and remaining B2 sources/gold
northdpole Sep 29, 2026
62cedd4
feat(mappings): promote Related-orphan remaps into canonical fixtures
northdpole Sep 29, 2026
44dc468
chore(oie): trim #1088 for the staging rollout
northdpole Nov 1, 2026
692bc35
Merge remote-tracking branch 'origin/wip/oie-pipeline-eval-harness' i…
northdpole Nov 1, 2026
4074ac7
chore(harvester): trim #1115 for the staging rollout
northdpole Nov 1, 2026
1524c9f
Merge branch 'trim/1115' into trim/1116
northdpole Nov 1, 2026
f694b1c
chore(oie): trim #1116 and guard destructive eval scripts
northdpole Nov 1, 2026
71b6abd
Merge branch 'trim/1116' into trim/1117
northdpole Nov 1, 2026
866b86f
chore(oie): trim #1117 for the staging rollout
northdpole Nov 1, 2026
abe9547
Merge branch 'trim/1117' into trim/1118
northdpole Nov 1, 2026
fb4c782
chore(oie): trim #1118 for the staging rollout
northdpole Nov 1, 2026
adac09b
Merge branch 'trim/1118' into trim/1119
northdpole Nov 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 14 additions & 7 deletions application/prompt_client/litellm_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@

from __future__ import annotations

from cre_logging import get_logger

logger = get_logger(__name__)

import logging
import os
import time
from typing import Any, Callable, List, Optional, Sequence

from application.prompt_client.llm_error_utils import is_rate_limit_error
from application.prompt_client.llm_error_utils import (
is_rate_limit_error,
is_transient_llm_error,
)

logger = logging.getLogger(__name__)

LlmFn = Callable[[str, str], str]

Expand Down Expand Up @@ -47,21 +49,26 @@ def with_rate_limit_retry(
max_retries: Optional[int] = None,
retry_sleep_seconds: Optional[int] = None,
) -> Any:
"""Retry rate limits and transient connection/timeout blips."""
default_retries, default_sleep = retry_policy()
retries = default_retries if max_retries is None else max_retries
sleep_s = default_sleep if retry_sleep_seconds is None else retry_sleep_seconds
for attempt in range(retries + 1):
try:
return fn()
except Exception as err:
if not is_rate_limit_error(err) or attempt >= retries:
retriable = is_transient_llm_error(err) or is_rate_limit_error(err)
if not retriable or attempt >= retries:
raise
kind = "rate/quota" if is_rate_limit_error(err) else "transient"
logger.info(
"rate/quota limited during %s; sleeping %ss (attempt %s/%s)",
"%s error during %s; sleeping %ss (attempt %s/%s): %s",
kind,
context,
sleep_s,
attempt + 1,
retries + 1,
type(err).__name__,
)
time.sleep(sleep_s)
raise RuntimeError("unreachable: retry loop exited unexpectedly")
Expand Down
35 changes: 35 additions & 0 deletions application/prompt_client/llm_error_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,38 @@ def is_rate_limit_error(err: BaseException) -> bool:
if code == 429:
return True
return False


def is_transient_llm_error(err: BaseException) -> bool:
"""Connection / timeout blips that are safe to retry (not model refusal)."""
if is_rate_limit_error(err):
return True
name = type(err).__name__.lower()
if any(
tok in name
for tok in (
"connect",
"timeout",
"apiconnection",
"remoteprotocol",
"network",
)
):
return True
msg = str(err).lower()
return any(
tok in msg
for tok in (
"connection reset",
"connection aborted",
"connection refused",
"temporarily unavailable",
"broken pipe",
"timed out",
"timeout",
"errno 54",
"errno 104",
"server disconnected",
"remote end closed",
)
)
Loading
Loading