Skip to content

[BUG] CachePointBlock ttl field dropped by SDK + cache_tools ordering violation with 1h TTL #2121

@namartaknev

Description

@namartaknev

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.35

Python Version

3.12

Operating System

linux

Installation Method

pip

Steps to Reproduce

  1. Create a BedrockModel with cache_tools="default" and a system prompt containing a cachePoint with ttl="1h"
  2. Create an Agent with ConversationCacheHook that sets CACHE_POINT_BLOCK = {"cachePoint": {"type": "default", "ttl": "1h"}}
  3. Invoke the agent with a multi-turn conversation
  4. Observe: (a) ValidationException due to TTL ordering, or (b) cache falls back to 5m TTL silently

Expected Behavior

cachePoint blocks with "ttl": "1h" should be forwarded to Bedrock as-is
cache_tools="default" should allow configuring its TTL to match other cache points
Bedrock should honor 1-hour TTL on all configured cache checkpoints

Actual Behavior

Bug 1: _format_request_message_content in bedrock.py silently drops the ttl field from cachePoint blocks — all cache silently falls back to 5m TTL regardless of what is set
Bug 2: cache_tools="default" hardcodes a 5m TTL on the toolConfig cache point. Since toolConfig is processed before system and messages, a 1h TTL on a subsequent cache point violates Bedrock's decreasing TTL ordering rule → ValidationException

Additional Context

The Bedrock CachePointBlock API supports an optional ttl field with values "5m" or "1h": https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_CachePointBlock.html
Bedrock processes cache checkpoints in order: toolConfig → system → messages, and requires TTLs to be in non-increasing order
Users leveraging ConversationCacheHook (manually injected cache points via hooks) cannot access 1h TTL because the SDK strips the field before the API call

Possible Solution

# Bug 1 fix — bedrock.py _format_request_message_content
if "cachePoint" in content:
    cp = {"type": content["cachePoint"]["type"]}
    if "ttl" in content["cachePoint"]:
        cp["ttl"] = content["cachePoint"]["ttl"]
    return {"cachePoint": cp}
# Bug 2 fix — add cache_tools_ttl param to BedrockModel
# e.g. BedrockModel(cache_tools="default", cache_tools_ttl="1h")
# so toolConfig cache point TTL can be aligned with system/conversation cache points

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions