Skip to content

Don't send whitespace-only assistant message back to Bedrock #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

celeriev
Copy link

Fixes #1678

@celeriev celeriev changed the title fix: fix empty content block with pydantic ai fix: prevent empty content block with bedrock May 13, 2025
@celeriev celeriev marked this pull request as draft May 14, 2025 07:57
@celeriev celeriev marked this pull request as ready for review May 16, 2025 13:24
@celeriev celeriev marked this pull request as draft May 16, 2025 13:50
@celeriev celeriev marked this pull request as ready for review May 16, 2025 14:41
else:
assert isinstance(item, ToolCallPart)
content.append(self._map_tool_call(item))
content: list[ContentBlockOutputTypeDef] = self._map_model_response(message)
bedrock_messages.append({'role': 'assistant', 'content': content})
Copy link
Contributor

Choose a reason for hiding this comment

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

It's now possible for content to be an empty list, in which case we should not append message at all, right?

@DouweM DouweM self-assigned this May 19, 2025
@DouweM DouweM changed the title fix: prevent empty content block with bedrock Don't send whitespace-only assistant message back to Bedrock May 19, 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.

Issue with Bedrock and Claude Model: ValidationException on Blank Text Field
2 participants