Skip to content

Conversation

@cagataycali
Copy link
Member

Description

Fixes a ValidationException that occurs when using structured_output_model with SummarizingConversationManager.

Problem

When an agent is configured with structured_output_model, every response contains toolUse blocks for the structured output. The SummarizingConversationManager._generate_summary() method converts the assistant's response to a user message (for context continuity), but this includes the toolUse blocks.

According to AWS Bedrock's Converse API constraints:

  • User messages can only contain: text, toolResult, image, document
  • Assistant messages can contain: text, toolUse, reasoningContent

This mismatch causes:

ValidationException: User messages cannot contain tool uses. Please remove the tool uses and try again.

Solution

Filter out assistant-only content blocks (toolUse, reasoningContent) when converting the summary to a user message. If no valid content remains after filtering (edge case), create a fallback text representation.

Related Issues

Fixes #1160

Documentation PR

No documentation changes required.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Added 3 new unit tests covering:
    • Filtering toolUse blocks from structured output responses
    • Filtering reasoningContent blocks
    • Fallback behavior when response contains only toolUse
  • All 33 existing tests pass
  • Ran ruff format and ruff check

Checklist

  • I have read the CONTRIBUTING document
  • I have added tests that prove my fix is effective
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Created by strands-coder 🦆

When using structured_output_model with SummarizingConversationManager,
the agent's response contains toolUse blocks. When converting this to
a user message for the summary, these blocks must be filtered out because
Bedrock's Converse API only allows text and toolResult in user messages.

Changes:
- Filter toolUse and reasoningContent blocks from summary content
- Add fallback text when no valid content remains after filtering
- Add comprehensive tests for the fix

Fixes strands-agents#1160
@codecov
Copy link

codecov bot commented Jan 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@strands-agent
Copy link
Contributor

🎯 Gentle Ping - Ready for Merge

This PR has been sitting at ALL GREEN (15/15 CI checks passing) since creation. It's a clean bug fix with:

Zero risk - Only filters toolUse blocks from summary messages
Real user impact - Fixes #1160 (ValidationException affecting users)
100% test coverage - Confirmed by codecov
No API changes - check-api passed

Would a maintainer be able to take a look when you have a moment? This is blocking users who combine structured_output with SummarizingConversationManager.

Thank you! 🙏


🤖 This is an experimental AI agent response from the Strands team, powered by Strands Agents. We're exploring how AI agents can help with community support and development. Your feedback helps us improve! If you'd prefer human assistance, please let us know.

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

Labels

Projects

None yet

2 participants