# resolve_prompt_cache_policy

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/cold_cache/resolve_prompt_cache_policy)

Resolve a documented cache policy for one effective model invocation.

Policies apply only when the endpoint is the provider's official API or a
user-declared trusted endpoint (see `load_trusted_cache_endpoints`).

A route that crosses wire formats (e.g. an OpenAI-format request routed to
an Anthropic model, spelled `openai:anthropic/claude-...`) resolves nothing,
because the translation such a hop requires rewrites or drops the caching
fields the policy assumes. See `_effective_model_name`. Cross-format routing
that is *not* spelled in the model name cannot be detected -- declaring an
endpoint trusted asserts that it does not do this.

## Signature

```python
resolve_prompt_cache_policy(
    model_spec: str,
    model_params: dict[str, Any] | None = None,
    *,
    base_url: str | None = None,
    trusted_endpoints: AbstractSet[str] | None = None,
) -> PromptCachePolicy | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_spec` | `str` | Yes | `provider:model` identifier for the invocation. |
| `model_params` | `dict[str, Any] \| None` | No | Request params that affect retention, if any. (default: `None`) |
| `base_url` | `str \| None` | No | Resolved endpoint, or `None` for the provider default. (default: `None`) |
| `trusted_endpoints` | `AbstractSet[str] \| None` | No | Hostnames the user has declared trusted, as returned by `load_trusted_cache_endpoints`. Full http(s) URLs are accepted too and reduced to their host; entries that are not a usable hostname are dropped, exactly as the loader drops them. Matching is per exact host -- a trusted `example.com` does not cover `gw.example.com`. (default: `None`) |

## Returns

`PromptCachePolicy | None`

Matching policy, or `None` when retention cannot be resolved safely.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/caaa7e7c12d214afa5cf0a1afed8eb6232aa6f7b/libs/code/deepagents_code/cold_cache.py#L815)