Skip to content

Bedrock prompt caching is not working #4381

@LokeshEka

Description

@LokeshEka

Initial Checks

Description

I am using inference profile arn as model id

@DouweM Am I doing anything wrong here?

Minimal, Reproducible Example

data_agent = Agent(
    BedrockConverseModel(AGENT_SETTINGS.model),
    deps_type=AgentDeps,
    retries=AGENT_SETTINGS.retries,
    instructions=SYSTEM_INSTRUCTIONS,
    tools=[execute_sql, search_tables, clarify_with_user],
    model_settings=BedrockModelSettings(
        bedrock_cache_instructions=True,  # Cache system instructions
        bedrock_cache_tool_definitions=True,  # Cache tool definitions
        bedrock_cache_messages=True,  # Also cache the last message
    ),
)

print(result.usage())
RunUsage(input_tokens=44334, output_tokens=1279, requests=5, tool_calls=4)

Logfire Trace

No response

Python, Pydantic AI & LLM client version

  • Python: 3.13.11
  • Pydantic AI: 1.59.0
  • LLM provider SDK: Bedrock

Metadata

Metadata

Assignees

No one assigned

    Labels

    bedrockbugReport that something isn't working, or PR implementing a fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions