An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.
Rust
fix: cover merged prompt cache behavior
YeonGyu-Kimffb133851ed9
diff --git a/rust/crates/api/src/prompt_cache.rs b/rust/crates/api/src/prompt_cache.rsindex be7cb834..ec9b0b40 100644--- a/rust/crates/api/src/prompt_cache.rs+++ b/rust/crates/api/src/prompt_cache.rs@@ -500,15 +500,22 @@ fn stable_hash_bytes(bytes: &[u8]) -> u64 {#[cfg(test)]mod tests {+ use std::sync::{Mutex, OnceLock};use std::time::{Duration, SystemTime, UNIX_EPOCH};use super::{detect_cache_break, read_json, request_hash_hex, sanitize_path_segment, PromptCache,PromptCacheConfig, PromptCachePaths, TrackedPromptState, REQUEST_FINGERPRINT_PREFIX,};- use crate::test_env_lock;use crate::types::{InputMessage, MessageRequest, MessageResponse, OutputContentBlock, Usage};+ fn test_env_lock() -> std::sync::MutexGuard<'static, ()> {+ static LOCK: OnceLock<Mutex<()>> = OnceLock::new();+ LOCK.get_or_init(|| Mutex::new(()))+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ }+#[test]fn path_builder_sanitizes_session_identifier() {let paths = PromptCachePaths::for_session("session:/with spaces");diff --git a/rust/crates/api/tests/client_integration.rs b/rust/crates/api/tests/client_integration.rsindex f2359807..01addefe 100644--- a/rust/crates/api/tests/client_integration.rs+++ b/rust/crates/api/tests/client_integration.rs@@ -4,9 +4,10 @@ use std::sync::{Mutex as StdMutex, OnceLock};use std::time::Duration;use api::{- ApiClient, ApiError, AuthSource, ContentBlockDelta, ContentBlockDeltaEvent,+ AnthropicClient, ApiClient, ApiError, AuthSource, ContentBlockDelta, ContentBlockDeltaEvent,ContentBlockStartEvent, InputContentBlock, InputMessage, MessageDeltaEvent, MessageRequest,- OutputContentBlock, ProviderClient, StreamEvent, ToolChoice, ToolDefinition,+ OutputContentBlock, PromptCache, PromptCacheConfig, ProviderClient, StreamEvent, ToolChoice,+ ToolDefinition,};use serde_json::json;use telemetry::{ClientIdentity, MemoryTelemetrySink, SessionTracer, TelemetryEvent};@@ -562,10 +563,10 @@ async fn send_message_tracks_unexpected_prompt_cache_breaks() {let request = sample_request(false);let client = AnthropicClient::new("test-key").with_base_url(server.base_url())- .with_prompt_cache(PromptCache::with_config(api::PromptCacheConfig {+ .with_prompt_cache(PromptCache::with_config(PromptCacheConfig {session_id: "break-session".to_string(),completion_ttl: Duration::from_secs(0),- ..api::PromptCacheConfig::default()+ ..PromptCacheConfig::default()}));client