# language_model: Allow explicit prompt cache keys \(\#64460\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/a8535d86b7c4f8061c35b1802734be33201d815b)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: a8535d86b7c4f8061c35b1802734be33201d815b

Requested commit: a8535d86b7c4f8061c35b1802734be33201d815b

Commit: a8535d86b7c4f8061c35b1802734be33201d815b

Tree: c9795a2a1ba3b5c194f36b1bc3057207482733e5

Author: Agus Zubiaga

Committer: GitHub

## Message

```
language_model: Allow explicit prompt cache keys (#64460)

## Objective

Related conversations can’t share an OpenAI cache key without also
sharing a thread ID. We currently derive `prompt_cache_key` directly
from `thread_id`, tying cache reuse to conversation identity.

## Solution

Add an optional `prompt_cache_key` to `LanguageModelRequest` and use it
in both OpenAI Chat Completions and Responses conversions. We still fall
back to `thread_id` when no key is supplied, so existing callers keep
their current behavior.

This lets callers share a cache key across parent and child
conversations while keeping their conversation and transport identities
separate.

## Testing

Added regression coverage for explicit keys, legacy fallback, provider
capability gating, and serialization compatibility.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
```

## Parents

- [650a8d1bedaca3f841f1c11f89fa786f574c2aab](https://git.cafe/gitcafe/zed/commit/650a8d1bedaca3f841f1c11f89fa786f574c2aab?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/a8535d86b7c4f8061c35b1802734be33201d815b?format=markdown)
