ai.clients.RoundRobin

Rotates invocations across members. Replaces the legacy round-robin provider: distribution is a client-boundary concern, exactly like Retry and Fallback. The counter mutates on the shared value, so every call site holding this client participates in one rotation. A streaming call selects and advances the counter exactly once; a failure from that selected stream never rotates again within the same call.

Reference version

Signature

class ai.clients.RoundRobin

Rotates invocations across members. Replaces the legacy round-robin provider: distribution is a client-boundary concern, exactly like Retry and Fallback. The counter mutates on the shared value, so every call site holding this client participates in one rotation. A streaming call selects and advances the counter exactly once; a failure from that selected stream never rotates again within the same call.

Source:<builtin>/ai/ns_clients/clients.bamlbytes 17018–21181

Fields

counter

int

Static methods

Implementations

ai.Client for ai.clients.RoundRobin

Instance methods

function

default_cache_args

(self) -> baml.json.json throws never

The args this client uses for a ${cache()} written with none (or with null): the object its wire's cache marker carries. Null when the client has no cache marker on its wire, or when the model it is configured for would reject one; a ${cache()} then sends nothing.

A client that sends cache markers passes this to ai.wire.prompt_parts(message, default_cache_args).

function

id

(self) -> string throws never
function

render

(
self,
) -> baml.http.Request throws baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure

Rendering is deterministic and side-effect free: preview the first member rather than mutating the invocation rotation counter.

Source:<builtin>/ai/ns_clients/clients.bamlbytes 17483–19773