# agent: Fix bug with double-counting tokens in Gemini \(\#31885\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/ae219e9e99f47b6bd23f1c7557af449897d49847)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: ae219e9e99f47b6bd23f1c7557af449897d49847

Requested commit: ae219e9e99f47b6bd23f1c7557af449897d49847

Commit: ae219e9e99f47b6bd23f1c7557af449897d49847

Tree: 3406e9676cd58aec35428b1feeee67852936baa3

Author: Oleksiy Syvokon

Committer: GitHub

## Message

```
agent: Fix bug with double-counting tokens in Gemini (#31885)

We report the total number of input tokens by summing the numbers of
1. Prompt tokens
2. Cached tokens

But Google API returns prompt tokens (1) that already include cached
tokens (2), so we were double counting tokens in some cases.

Release Notes:

- Fixed bug with double-counting tokens in Gemini
```

## Parents

- [6d99c127967b1e7455458cb36aca298b4f679b7a](https://git.cafe/gitcafe/zed/commit/6d99c127967b1e7455458cb36aca298b4f679b7a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/ae219e9e99f47b6bd23f1c7557af449897d49847?format=markdown)
