Pass through Anthropic cache configuration when using Zed provider (cherry-pick #16685) (#16688)

gcp-cherry-pick-bot[bot] and Marshall Bowers created

Cherry-picked Pass through Anthropic cache configuration when using Zed
provider (#16685)

This PR makes it so the model's cache configuration gets passed through
from the base model when using the Zed provider.

Release Notes:

- Fixed caching for Anthropic models when using the Zed provider.

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>

Change summary

crates/language_model/src/provider/cloud.rs | 15 +++++++++++++++
1 file changed, 15 insertions(+)

Detailed changes

crates/language_model/src/provider/cloud.rs 🔗

@@ -444,6 +444,21 @@ impl LanguageModel for CloudLanguageModel {
         self.model.max_token_count()
     }
 
+    fn cache_configuration(&self) -> Option<LanguageModelCacheConfiguration> {
+        match &self.model {
+            CloudModel::Anthropic(model) => {
+                model
+                    .cache_configuration()
+                    .map(|cache| LanguageModelCacheConfiguration {
+                        max_cache_anchors: cache.max_cache_anchors,
+                        should_speculate: cache.should_speculate,
+                        min_total_token: cache.min_total_token,
+                    })
+            }
+            CloudModel::OpenAi(_) | CloudModel::Google(_) | CloudModel::Zed(_) => None,
+        }
+    }
+
     fn count_tokens(
         &self,
         request: LanguageModelRequest,