Skip to content

Commit

Permalink
Fix: Gemini Api 400 Invalid Argument Error
Browse files Browse the repository at this point in the history
Skip messages with role 'tool' and no tool_calls attribute while formating messages for gemini

This apparently fixes the error agno-agi#2241
  • Loading branch information
AkhilmsAchu committed Feb 28, 2025
1 parent d3c321f commit 4eb065f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/agno/agno/models/google/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ def _format_messages(self, messages: List[Message]):
system_message = message.content
continue

if role == "tool" and not message.tool_calls:
continue

# Add content to the message for the model
content = message.content
# Initialize message_parts to be used for Gemini
Expand Down

0 comments on commit 4eb065f

Please sign in to comment.