fix(skills): preserve cache points in system prompt during skills inj…#2134
Conversation
|
this is very critical bug can someone please merge it, strands + bedrock agents are getting stuck. |
|
/strands review |
|
Assessment: Comment The fix correctly addresses the cache point destruction bug by branching into content-block-level manipulation when Review Details
|
…ection AgentSkills._on_before_invocation was reading the system prompt as a string, appending skills XML, and writing it back as a string. This caused the setter to collapse structured SystemContentBlock lists (including cachePoint blocks) into a single flat text block. The hook now operates on the content block list when available, appending skills XML as a separate block and leaving cache points untouched. Falls back to the original string path when _system_prompt_content is None. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7bd74d4 to
290b46d
Compare
|
/strands review |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Assessment: Comment The bug fix correctly preserves structured system prompt blocks (including Review Details
The previous review feedback on private attribute access has been properly addressed. Nice work on the fix. |
Return defensive copy from system_prompt_content getter, add Returns docstring section, and add dedicated unit tests in test_agent.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Assessment: Comment All prior review feedback has been addressed. The fix is solid — one minor test accuracy issue remains. Review Details
The implementation is clean and the core bug is well-fixed. Nice iteration on the feedback. |
Fix invalid cache_control key to match SystemContentBlock TypedDict, and add tests for the string-path branch in skills injection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Assessment: Approve All prior review feedback has been addressed across 4 iterations. The fix is clean, well-tested, and ready to merge. Review Details
|
|
@mattdai01 thank you for your contribution! |
AgentSkills._on_before_invocation was reading the system prompt as a string, appending skills XML, and writing it back as a string. This caused the setter to collapse structured SystemContentBlock lists (including cachePoint blocks) into a single flat text block.
The hook now operates on the content block list when available, appending skills XML as a separate block and leaving cache points untouched. Falls back to the original string path when _system_prompt_content is None.
Description
AgentSkills._on_before_invocationwas reading the system prompt as a string, appending skills XML, and writing it back as a string. This caused the setter to collapse structuredSystemContentBlocklists (includingcachePointblocks) into a single flat text block.The hook now operates on the content block list when available, appending skills XML as a separate block and leaving cache points untouched. Falls back to the original string path when
_system_prompt_contentisNone.Related Issues
Fixes #2133
Type of Change
Bug fix
Testing
Created new unit test
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.