-
Notifications
You must be signed in to change notification settings - Fork 801
remove extra usage additions during yielding in gemini agent #1577
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
base: main
Are you sure you want to change the base?
remove extra usage additions during yielding in gemini agent #1577
Conversation
hmm failing tests, it may be a more complex fix? is it gemini side with the issue? looks like this may not be a perfect fix but i wanted to highlight the issue |
For reference, printing each of the
Clearly, the However, testing with 2.0 and 1.5 it looked like this:
(removed text for easier reading, but it was quite clear that the number of tokens in each chunk was not the amount reported) Not reporting the candidates_token_count at all (but the prompt_token_count would still be off here). Not sure if this is an issue from google reporting different things on different models? |
https://ai.google.dev/api/generate-content#UsageMetadata indeed the candidates_token_count is summing across all candidates, so summing them again here does not make sense |
@almeidaalajoel Thank you, makes sense if this is documented by Google. Can you see if you can rebase on main and update the failing tests? |
The gemini Agent is overcounting tokens by adding the usage for each chunk returned from the gemini client. Each chunk has the total usage data up to that chunk.
Instead of summing the usage, we should just track what the response said the usage was at each point.