Skip to content

learn: stop retrying into a provider outage with a shared circuit breaker - #126

Open
Mattbusel wants to merge 1 commit into
open-gitagent:mainfrom
tensorust-ai:deps/llm-resilience-provider-retry
Open

Mattbusel wants to merge 1 commit into
open-gitagent:mainfrom
tensorust-ai:deps/llm-resilience-provider-retry

Conversation

@Mattbusel

Copy link
Copy Markdown

Problem

distill::propose retries each learning unit on its own: up to 3 calls, sleeping 2 s then 4 s between them. Nothing carries over from one unit to the next, so when the provider is down a learn pass over N units makes 3N calls and waits about 6 s per unit before giving up on each one.

Change

One CircuitBreaker (from llm-resilience) is now shared by every model call in a learning pass (learn() and learn_from_run() each create one with distill::breaker()).

  • Each attempt takes a permit from the breaker. A success closes it; a Transient or RateLimited error counts as a failure.
  • After 6 failures in a row (two units that used up all their retries) the breaker opens, and later units return ProviderDown at once without calling the provider. Their trials stay unlearned, so the next run picks them up, the same as any other failed call today.
  • After 60 s one call is let through to probe the provider again.
  • Fatal errors and context overflows say nothing about whether the provider is up, so they are not recorded.
  • LearnReport gets a provider_down_skips count (these units are also counted in model_errors).

Tests

Two new tests in crates/learn/src/tests.rs, using the existing ScriptedProvider and paused tokio time:

  • a_provider_outage_stops_the_pass_after_two_units: with three learnable units and a provider that always fails, the pass makes 6 requests instead of 9, and the third unit is reported as a provider-down skip.
  • a_recovered_call_keeps_the_pass_going: a rate limit and a transient error followed by a good reply still adds the lesson, with no skips.

cargo test -p gitagent-learn passes (17/17).

Dependency

llm-resilience 0.2.1 with default-features = false, in crates/learn only. It adds parking_lot (with lock_api and parking_lot_core, plus redox_syscall, which is only built on Redox) to Cargo.lock. tokio and tracing, which it also uses, are already in the tree.

Disclosure: I maintain llm-resilience.

…aker

The learn pass retried every unit three times with 2s/4s sleeps even when the
provider was down, so an outage cost every unit's retries. A breaker from
llm-resilience shared across the pass opens after two units in a row use up
their retries; later units are skipped without a call and stay unlearned for
the next run. Fatal errors and context overflows do not count.

Adds llm-resilience 0.2.1 (default features off), which brings in
parking_lot plus lock_api and parking_lot_core; tokio and tracing are
already in the tree.

Disclosure: I maintain llm-resilience.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant