Skip to content

Commit 1c9765a

Browse files
committed
fix(adaptive): keep string key_strategy inputs serializable
Address CodeRabbit review on #818. - `ResponseCacheConfig.to_dict()` in Python no longer raises `AttributeError` when `key_strategy` is a plain wire string. Enum members serialize through `.value`; strings pass through unchanged so unsupported values reach native validation with the `response_cache.unsupported_key_strategy` diagnostic, matching the Go string alias and the Node.js runtime. - Drop the stale "exact-match" wording from the two `response_cache` doc comments in `crates/adaptive/src/config.rs`. User-facing docs stay deferred to #819. Signed-off-by: Zhongxuan (Daniel) Wang <52872691+ZhongxuanWang@users.noreply.github.com>
1 parent 6c08e10 commit 1c9765a

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

crates/adaptive/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct AdaptiveConfig {
3434
/// Adaptive Cache Governor settings.
3535
#[serde(default, skip_serializing_if = "Option::is_none")]
3636
pub acg: Option<AcgComponentConfig>,
37-
/// Opt-in exact-match LLM response and tool-result cache. When present,
37+
/// Opt-in LLM response and tool-result cache. When present,
3838
/// the adaptive plugin installs the response-cache execution intercept(s).
3939
#[serde(default, skip_serializing_if = "Option::is_none")]
4040
pub response_cache: Option<ResponseCacheConfig>,
@@ -191,7 +191,7 @@ impl Default for AcgComponentConfig {
191191
}
192192
}
193193

194-
/// Configuration for the adaptive plugin's exact-match LLM response and
194+
/// Configuration for the adaptive plugin's LLM response and
195195
/// opt-in tool-result cache feature.
196196
#[derive(Debug, Clone, Serialize, Deserialize)]
197197
#[serde(default)]

python/nemo_relay/adaptive.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,11 @@ def to_dict(self) -> JsonObject:
419419
"priority": self.priority,
420420
"bypass_rate": self.bypass_rate,
421421
"cache_nondeterministic": self.cache_nondeterministic,
422-
"key_strategy": self.key_strategy.value,
422+
"key_strategy": (
423+
self.key_strategy.value
424+
if isinstance(self.key_strategy, ResponseCacheKeyStrategy)
425+
else self.key_strategy
426+
),
423427
"header_allowlist": self.header_allowlist,
424428
"backend": _normalize(self.backend),
425429
"tools": _normalize(self.tools),

0 commit comments

Comments
 (0)