Skip to content

fix: replace empty user text message as 'blank text'#823

Closed
poshinchen wants to merge 1 commit intostrands-agents:mainfrom
poshinchen:fix/empty-message-2
Closed

fix: replace empty user text message as 'blank text'#823
poshinchen wants to merge 1 commit intostrands-agents:mainfrom
poshinchen:fix/empty-message-2

Conversation

@poshinchen
Copy link
Copy Markdown
Contributor

Description

When user sends empty string as user prompt, the model will fail with empty message exception:

An error occurred: An error occurred (ValidationException) when calling the ConverseStream operation: The text field in the ContentBlock object at messages.xxx.content.0 is blank. Add text to the text field, and try again.

Therefore updating the user text message to [blank text] when it's empty.

Related Issues

#514

Documentation PR

N/A

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare
  • I compared the behaviors before and after the change

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

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

@poshinchen poshinchen requested a review from a team September 8, 2025 20:59
@poshinchen poshinchen marked this pull request as ready for review September 8, 2025 21:01
@poshinchen poshinchen self-assigned this Sep 8, 2025
Copy link
Copy Markdown
Member

@awsarron awsarron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user intentionally sends a blank string (or None), I think we should either pass that through or throw early.

This feels like model provider specific logic too. Do models other than Bedrock fail in this scenario?

@poshinchen
Copy link
Copy Markdown
Contributor Author

We plan to fix it in a better way in our next major release.

@poshinchen poshinchen closed this Sep 22, 2025
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