(
body: dict[str, Any],
*,
selected_model: str,
provider_entry: Any,
session_id: str | None,
step_type: str,
upstream_provider: str,
)
| 2022 | |
| 2023 | |
| 2024 | def _apply_provider_cache_plan( |
| 2025 | body: dict[str, Any], |
| 2026 | *, |
| 2027 | selected_model: str, |
| 2028 | provider_entry: Any, |
| 2029 | session_id: str | None, |
| 2030 | step_type: str, |
| 2031 | upstream_provider: str, |
| 2032 | ) -> CacheRequestPlan: |
| 2033 | family = provider_family_for_model( |
| 2034 | selected_model, |
| 2035 | provider_name=getattr(provider_entry, "name", None), |
| 2036 | upstream_provider=upstream_provider, |
| 2037 | ) |
| 2038 | if family == "openai": |
| 2039 | return apply_openai_cache_hints( |
| 2040 | body, |
| 2041 | model=selected_model, |
| 2042 | session_id=session_id, |
| 2043 | step_type=step_type, |
| 2044 | ) |
| 2045 | if family == "anthropic": |
| 2046 | return CacheRequestPlan(family="anthropic", mode="stable-prefix") |
| 2047 | if family == "deepseek": |
| 2048 | return CacheRequestPlan(family="deepseek", mode="stable-prefix") |
| 2049 | if family == "google": |
| 2050 | _strip_openai_cache_hints_for_google(body) |
| 2051 | return CacheRequestPlan(family="google", mode="cache-bypass") |
| 2052 | return CacheRequestPlan(family=family) |
| 2053 | |
| 2054 | |
| 2055 | def _strip_openai_cache_hints_for_google(body: dict[str, Any]) -> None: |
no test coverage detected