PDF text increases prompt usage but not count_tokens on gemini-4-hydrogen
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- google-cloud, python
調査の方向性
Start with the attached pdf_token_repro.py reproduction and compare the SDK's count_tokens request and response with generate_content usage for the two PDF inputs. The report does not isolate whether the discrepancy comes from the SDK or Gemini backend, so first check whether raw REST reproduces it and review the earlier linked report. Done means identifying the responsible layer and documenting or fixing how PDF text is accounted for.
索引モデルが issue の本文から書いたものです。
説明
Description
Adding embedded text to a 10-page PDF substantially increases gemini-4-hydrogen's reported input usage, but its count_tokens estimate is unchanged. The comparison below uses a blank PDF with the same page count and dimensions as a control.
Observed through google-genai; I have not isolated whether the cause is in the SDK or backend, or tested raw REST. Please redirect me if another tracker is more appropriate.
Environment details
- Python 3.12.13
- macOS 26.5.2 (arm64)
google-genai==3.3.0, Gemini Developer APIthinking_level=LOW; no system instruction, tools, or response schema
Steps to reproduce
- Extract the attached pdf-token-repro.zip.
- Set
GEMINI_API_KEY, then run:
pip install google-genai==3.3.0
python pdf_token_repro.py --pages 10
The script generates both synthetic PDFs and calls count_tokens and generate_content with identical contents for each model. No real documents or sensitive data are included.
Actual result
One run on 2026-11-16:
| Model | count_tokens | prompt_token_count | TEXT | |
|---|---|---|---|---|
| text.pdf | gemini-3.8-flash | 5,609 | 5,329 | 9 |
| text.pdf | gemini-4-hydrogen | 5,638 | 14,642 | 9,322 |
| blank.pdf | gemini-3.8-flash | 5,609 | 5,329 | 9 |
| blank.pdf | gemini-4-hydrogen | 5,638 | 5,704 | 384 |
All four requests report 5,320 IMAGE tokens. On Hydrogen, adding PDF text increases reported usage by 8,938 TEXT tokens without changing the estimate.
Expected behavior
count_tokens should account for PDF text included in prompt usage, or document the difference and provide a supported way to estimate input usage before generation.
Earlier report with additional Gemini API and Vertex AI observations.
- 主要言語
- Python
- スター
- 4.1k
- フォーク
- 1.1k
- 平均マージ
- 2日 15時間
- マージ済み PR(30日)
- 97
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/python-genai のほかの issue
-
Interactions retries ignore the documented `initial_delay` and `max_delay` defaults対応中かも @Venkaiahbabuneelam が 8 日前に担当しました。 オープンpriority: p2 status:awaiting user response type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
googleapis/python-genai#3317 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Test import module that doesn't exist対応中かも @Venkaiahbabuneelam が 34 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
googleapis/python-genai#3122 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Curated history keeps half a user turn when the model turn is invalid対応中かも @Venkaiahbabuneelam が 43 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
googleapis/python-genai#3051 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC対応中かも @Venkaiahbabuneelam が 43 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/python-genai#3044 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Structured-output continuation merge raises AttributeError: __pydantic_generic_metadata__ when a hop has parsed JSON対応中かも @Venkaiahbabuneelam が 6 日前に担当しました。 オープンpriority: p2 type: bug
googleapis/python-genai#3350 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
googleapis/python-genai の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
readthedocs/readthedocs-builder#73 ·
メンテナーはふだん 1 日以内に返信
-
area: ci bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
hffgzktbcc-blip/ounce-core#484 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
vllm-project/vllm-torchtpu#3395 ·
メンテナーはふだん 1 日以内に返信
-
Hermes plugin: MITM-domain discovery misses the model: block (provider/base_url nested under model:) — traffic blind-tunnels silently, zero compression対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
ranxianglei/billion-context#7063 ·
メンテナーはふだん 1 日以内に返信