agent_proxy_rust_core/extensions.rs
1//! Well-known extension keys for
2//! [`ConnectionContext::extensions`](crate::types::ConnectionContext::extensions).
3//!
4//! Middleware crates use these constants to read and write data in the
5//! context extensions type-map. Using constants avoids typos and documents
6//! the inter-middleware contract.
7
8/// Key for the [`StatsRecord`] written by the compress middleware.
9///
10/// The value type is `StatsRecord` (to be defined by the compress crate).
11/// Contains `pre_compress_tokens`, `post_compress_tokens`, and `compression_tokens_saved`.
12pub const EXT_STATS_RECORD: &str = "stats_record";
13
14/// Key for the selected [`ChannelConfig`](crate::types::ChannelConfig) written by the model-router
15/// middleware.
16pub const EXT_SELECTED_CHANNEL: &str = "selected_channel";
17
18/// Key for the selected model mapping written by the model-router middleware.
19///
20/// The value type is the model mapping struct defined in the storage or model-router crate.
21pub const EXT_SELECTED_MAPPING: &str = "selected_mapping";
22
23/// Key for the bridge reverse flag.
24///
25/// Set by the bridge middleware to indicate that the response needs reverse
26/// protocol conversion.
27pub const EXT_BRIDGE_REVERSE: &str = "bridge_reverse";
28
29/// Key for [`CompressionStats`](crate::compression::CompressionStats).
30///
31/// Written by `server.rs` from `TOKENLESS_TOKENS` env var,
32/// appended by the compress middleware, and read by the cost module.
33pub const EXT_COMPRESSION_STATS: &str = "compression_stats";