[BUGS] Prevent NullPointerException for Gemini models with empty AIMessage content #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using Google Gemini models with tool calling,
AIMessageswith empty content (content="") cause aTransientServiceError(HTTP 500) due to a NullPointerException in the OCI backend when converting messages to Google's format.Issue link: #78
Solution
Check for empty content in AIMessages with tool calls before processing, and provide a minimal placeholder (
.) to prevent null serialization. This follows the same pattern used by the Cohere provider.Testing
Tested with
google.gemini-2.5-flashmodel using AIMessage with empty content and tool calls - error is now resolved.Model response:
content='The weather in Rome is currently sunny with a temperature of 20 degrees Celsius.' additional_kwargs={'finish_reason': 'stop'} response_metadata={'finish_reason': 'stop'} id='run--68c2e374-d8eb-43be-aec2-de2815789dc4-0'