Skip to content

bug: non-openai mode - fix for gemini content: null, fix 429 to throw before stream - #563

Merged
tibo-openai merged 1 commit into
openai:mainfrom
dnakov:fix_gemini
Apr 23, 2025
Merged

tibo-openai merged 1 commit into
openai:mainfrom
dnakov:fix_gemini

Conversation

@dnakov

@dnakov dnakov commented Apr 22, 2025

Copy link
Copy Markdown
Contributor

Gemini's API is finicky, it 400's without an error when you pass content: null
Also fixed the rate limiting issues by throwing outside of the iterator.
I think there's a separate issue with the second isRateLimit check in agent-loop - turnInput is cleared by that time, so it retries without the last message.

@tibo-openai

Copy link
Copy Markdown
Collaborator

Thanks a bunch, this looks like it took quite a bit of work to get right. There is a lot moving around and changing here and that's not an issue in itself, but I would like to see some new tests to cover the change in behavior here and ensure we don't have subsequent regressions. Could you take a look at that?

@dnakov

dnakov commented Apr 22, 2025

Copy link
Copy Markdown
Contributor Author

@tibo-openai It's mostly formatting changes. i just moved the completion.create call outside, which removed the try/catch block and added an if to check if there is content so its not null. Everything else is the same.

@tibo-openai

Copy link
Copy Markdown
Collaborator

Could you still explain why the test needs to be removed?

}
});

it("should handle errors gracefully", async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you document why we want to remove this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the try/catch wasn't allowing errors to propagate to the agent-loop, which has the rate limit and other handling. I took the error test out because it shouldn't gracefully handle the errors.
I'll write some more tests, I want to record snapshots from the different providers and test against those. Up to you if you want to wait a but for those, but this PR fixes gemini right now that people have been complaining about :)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This makes sense to me, will merge.

@tibo-openai
tibo-openai merged commit 23f0887 into openai:main Apr 23, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants