From bca08476def89773aba7e50b43db51de6c4d5486 Mon Sep 17 00:00:00 2001 From: Ed Zynda Date: Sun, 29 Mar 2026 14:32:28 +0300 Subject: [PATCH] chore: fix remaining linting issues in caching code - Use max() built-in instead of if statement (modernize) - Remove unused buildAnthropicCacheOptions function - Remove unused anthropic import --- internal/agent/cache_control.go | 5 +---- internal/models/cache_options.go | 11 ----------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/internal/agent/cache_control.go b/internal/agent/cache_control.go index f19069bd..825549d0 100644 --- a/internal/agent/cache_control.go +++ b/internal/agent/cache_control.go @@ -45,10 +45,7 @@ func applyCacheControlToMessages(messages []fantasy.Message) []fantasy.Message { } // Apply cache control to the last 2 messages - startIdx := len(result) - 2 - if startIdx < 0 { - startIdx = 0 - } + startIdx := max(len(result)-2, 0) for i := startIdx; i < len(result); i++ { // Only apply if not already set (avoid double-setting system message) if i != lastSystemIdx { diff --git a/internal/models/cache_options.go b/internal/models/cache_options.go index 1f271867..9ca7fc11 100644 --- a/internal/models/cache_options.go +++ b/internal/models/cache_options.go @@ -7,7 +7,6 @@ import ( "os" "charm.land/fantasy" - "charm.land/fantasy/providers/anthropic" "charm.land/fantasy/providers/openai" ) @@ -44,16 +43,6 @@ func buildCacheProviderOptions(modelInfo *ModelInfo, config *ProviderConfig) fan } } -// buildAnthropicCacheOptions enables ephemeral caching for Anthropic models. -// Used for message-level caching to avoid provider-level type conflicts. -func buildAnthropicCacheOptions() fantasy.ProviderOptions { - return anthropic.NewProviderCacheControlOptions(&anthropic.ProviderCacheControlOptions{ - CacheControl: anthropic.CacheControl{ - Type: "ephemeral", - }, - }) -} - // buildOpenAICacheOptions enables prompt caching for OpenAI models. // Uses a deterministic cache key based on system prompt and model ID. func buildOpenAICacheOptions(config *ProviderConfig, modelID string) fantasy.ProviderOptions {