Skip to main content

Module router

Module router 

Source
Expand description

Model routes: a ChatProvider that tries a chain of providers in order.

It is a provider rather than a feature of the loop so the loop stays untouched: the runtime still holds one &dyn ChatProvider per run and asks it for a reply. It lives in its own module because it knows nothing about HTTP; provider.rs is about one server, this is about the policy for moving between servers, and each is easier to read without the other.

The policy, in one place:

  • One attempt per route, in chain order. A route that failed is never tried again in the same run, and a route that answered is kept for the turns after it.
  • A hop happens only when the failure says the server was the problem and the request was fine: ProviderFailure::is_retryable (no answer, 408/429/5xx, a cut stream). A wrong key, a refused option or a 400 fails the run and names the route, because moving on would hide a config error behind a slower success.
  • Each route keeps its own retry budget (max_retries, with backoff) before the router moves on. max_retries = 0 on a route makes it hop at once.
  • Streaming: once any text of a turn has reached the caller, a transient failure does not hop. Replaying the turn on another route would print its beginning twice, so the run fails and says why. This is the same rule M10 applies to one route’s cut stream, applied one level up.
  • Every hop is recorded with its reason and can be read back with Router::hops.

Structs§

Hop
One move from a route that failed to the next one, and why.
RoleRoute
Which route one role uses, and whether the config said so.
RouteInfo
What a readout needs to say about one route: its name and what it serves.
Router
A chain of providers behind the ChatProvider interface. Build one per run: its state is the run’s record of which routes have already failed.
RouterEntry
One link of the chain: a name and the provider that talks to it.

Enums§

RouteStop
Why a ProviderFailure::Routed ended the run.

Constants§

ROLES
The jobs the agent does on its own behalf that can be sent to a route of their own.

Functions§

describe_hops
Render hops as one readout line: route: local → big (timeout), or route: local → big → cloud (timeout; HTTP 503) when it hopped twice. Empty when nothing hopped, because silence is the normal case.
role_table
Which route each role uses. The one answer to the question: eclipse config show, /status and the startup panel all print this, so they cannot disagree. aux is [provider] aux and delegate is [provider] delegate; selected is the first route of the chain, which is where a role with no route of its own goes.