Skip to main content

Module mirroring

Module mirroring 

Source
Expand description

Traffic mirroring: fire-and-forget shadow requests to a secondary model.

When enabled, every successful primary call also spawns a background tokio::task that repeats the same request against a configured “mirror” model. The mirror response is not returned to the caller; it is simply logged so operators can compare primary vs. mirror results (e.g. when evaluating a model switch).

§Usage

let mirror = MirrorConfig {
    model: "claude-3-5-sonnet-20241022".to_string(),
    sample_rate: 0.5,   // mirror 50 % of requests
};
client.set_mirror(Some(mirror));

Thread-safety: the config is stored behind an Arc<RwLock<…>> so it can be hot-swapped at runtime without restarting the client.

Structs§

MirrorConfig
Configuration for the traffic mirror.

Functions§

maybe_mirror
Spawn a fire-and-forget background task that sends request to the mirror model. Errors are logged but never propagated.

Type Aliases§

MirrorHandle
Shared, hot-swappable mirror configuration.