# language_models: Avoid sending Bedrock cache-point-only messages \(\#59436\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 6eaad52c29a026591b18acfc0ef6f35bce85d676

Requested commit: 6eaad52c29a026591b18acfc0ef6f35bce85d676

Commit: 6eaad52c29a026591b18acfc0ef6f35bce85d676

Tree: d3f349d77b6cbc8f7a26c99d8fbc52fcdffd85bb

Author: Yi Liu

Committer: GitHub

## Message

```
language_models: Avoid sending Bedrock cache-point-only messages (#59436)

When prompt caching is enabled, `into_bedrock` pushes a `CachePoint`
block
onto a message's content whenever `message.cache && supports_caching` is
true.
This push happens before the `if bedrock_message_content.is_empty() {
continue; }`
guard. As a result, a message whose content filters down to empty (for
example,
a message that contained only content stripped during conversion) still
gets
appended to the request carrying nothing but a `cachePoint`. Bedrock
rejects such
a message with a `ValidationException`, breaking the whole request.

The Anthropic path is already internally consistent here: in
`crates/language_models/src/provider/anthropic.rs` (around the message
assembly
in `completion.rs`) the empty-content check runs first, so an empty
message is
dropped before any cache marker is attached. The Bedrock path should
behave the
same way.

This change gates the `CachePoint` push on non-empty content
(`&& !bedrock_message_content.is_empty()`), so an empty message is left
empty and
then skipped by the existing `continue`, exactly mirroring the Anthropic
ordering.
The fix is minimal and touches only the cache-point condition.

Release Notes:

- Fixed Bedrock requests failing with ValidationException when the last
message filtered to empty content while prompt caching was enabled.

---------

Signed-off-by: Yi LIU <yi@quantstamp.com>
Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
```

## Parents

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

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