Skip to content

[BUG] AgentSkills plugin destroys cache points in structured system prompts #2133

@mattdai01

Description

@mattdai01

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.34.1

Python Version

3.10.16

Operating System

macOS

Installation Method

pip

Steps to Reproduce

  1. Create an agent with a structured system prompt containing cache points:
from strands import Agent
from strands.vended_plugins.skills import Skill, AgentSkills

skill = Skill(name="my-skill", description="A skill", instructions="Do the thing")
plugin = AgentSkills(skills=[skill])

agent = Agent(
    system_prompt=[
        {"text": "Base instructions."},
        {"cachePoint": {"type": "default"}},
        {"text": "More instructions."},
    ],
    plugins=[plugin],
)

# Before any invocation, check:
print(agent._system_prompt_content)
# [{"text": "Base instructions."}, {"cachePoint": {"type": "default"}}, {"text": "More instructions."}]

# After the agent runs (triggering _on_before_invocation):
agent("hello")

print(agent._system_prompt_content)
# Expected: cache points preserved
# Actual: all structure collapsed into a single text block

Expected Behavior

_system_prompt_content should preserve all structured blocks including cachePoint entries after the AgentSkills hook injects skills XML. Cache points should continue to work for prompt caching optimization.

Actual Behavior

AgentSkills._on_before_invocation reads the system prompt as a string via agent.system_prompt, concatenates the skills XML, and writes it back as a plain string. The setter then converts this to [{"text": full_string}], destroying all cachePoint blocks and any other structured content.

After the hook runs, _system_prompt_content becomes a single flat text block with no cache points.

Additional Context

No response

Possible Solution

No response

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