Skip to content

Conversation

@dbschmigelski
Copy link
Member

@dbschmigelski dbschmigelski commented Nov 5, 2025

Description

This is the followup to feat(models): add SystemContentBlock support for provider-agnostic caching strands-agents/sdk-python#1112. It includes documentation to describe the new approach.

After strands-agents/sdk-python#1141 is merged, we will update the LiteLLM section. Then after that as we begin progressing on [FEATURE] Prompt caching support for all models strands-agents/sdk-python#1140 we will update docs to provide a general caching section

Type of Change

  • Content update/revision

Motivation and Context

strands-agents/sdk-python#1112

Areas Affected

http://127.0.0.1:8000/user-guide/concepts/model-providers/amazon-bedrock/#caching

Screenshots

image

Checklist

  • I have read the CONTRIBUTING document
  • My changes follow the project's documentation style
  • I have tested the documentation locally using mkdocs serve
  • Links in the documentation are valid and working
  • Images/diagrams are properly sized and formatted
  • All new and existing tests pass

Additional Notes

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dbschmigelski dbschmigelski marked this pull request as ready for review November 5, 2025 19:19
@dbschmigelski dbschmigelski merged commit 4eaba8d into strands-agents:main Nov 7, 2025
2 checks passed
@rickkk856
Copy link

@dbschmigelski Is there any specific order? Or support to few dynamic SystemContentBlock?

Eg:

# Define system content with cache points
system_content = [
    SystemContentBlock(
        text="You are a helpful assistant that provides concise answers. "
             "This is a long system prompt with detailed instructions..."
             "..." * 1600  # needs to be at least 1,024 tokens
    ),
    SystemContentBlock(cachePoint={"type": "default"}),
    SystemContentBlock(text=f"Some other aditional text, eg; with dynamic {date}")
]

# Create an agent with SystemContentBlock array
agent = Agent(system_prompt=system_content)

or eg:

# Define system content with cache points
system_content = [
    SystemContentBlock(text=f"Some other aditional text, eg; with dynamic {date}"),
    SystemContentBlock(
        text="You are a helpful assistant that provides concise answers. "
             "This is a long system prompt with detailed instructions..."
             "..." * 1600  # needs to be at least 1,024 tokens
    ),
    SystemContentBlock(cachePoint={"type": "default"})
]

# Create an agent with SystemContentBlock array
agent = Agent(system_prompt=system_content)

Or could it even be built like this?

# Define system content with cache points
dynami_system_content = SystemContentBlock(text=f"Some other aditional text, eg; with dynamic {date}")
    
system_content = [
        SystemContentBlock(
        text="You are a helpful assistant that provides concise answers. "
             "This is a long system prompt with detailed instructions..."
             "..." * 1600  # needs to be at least 1,024 tokens
    ),
    SystemContentBlock(cachePoint={"type": "default"})
]

# Create an agent with SystemContentBlock array
agent = Agent(system_prompt=[dynami_system_content , *system_content])

I'm getting strange errors like this:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter system[0].text, value:

Any best recommendation? Tested on versions 1.17.0 and 1.15.0

@dbschmigelski
Copy link
Member Author

Hi,

from strands import Agent
from strands.types.content import SystemContentBlock
import datetime

# Define system content with cache points
system_content = [
    SystemContentBlock(
        text="You are a helpful assistant that provides concise answers. "
             "This is a long system prompt with detailed instructions..."
             "..." * 1600  # needs to be at least 1,024 tokens
    ),
    SystemContentBlock(cachePoint={"type": "default"}),
    SystemContentBlock(text=f"The current time is {datetime.datetime.now()}")
]

# Create an agent with SystemContentBlock array
agent = Agent(system_prompt=system_content)
agent("What time is it")

and

from strands import Agent
from strands.types.content import SystemContentBlock
import datetime

dynami_system_content = SystemContentBlock(text=f"the time is {datetime.datetime.now()}")

system_content = [
        SystemContentBlock(
        text="You are a helpful assistant that provides concise answers. "
             "This is a long system prompt with detailed instructions..."
             "..." * 1600  # needs to be at least 1,024 tokens
    ),
    SystemContentBlock(cachePoint={"type": "default"})
]

# Create an agent with SystemContentBlock array
agent = Agent(system_prompt=[dynami_system_content , *system_content])


agent("What time is it")

appear valid to me.

Can you take a look at the message array? Maybe there is an issue like an invalid character relating to date

@rickkk856
Copy link

Nevermind, problem was in a corrupted environment.

By the way tested again and order didn't influence, although it might be worth documenting that dynamic content-blocks are supported. Also the default TTL of 5 minutes of the system prompt cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants