Curated history keeps half a user turn when the model turn is invalid
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
chats.py の _extract_curated_history、具体的には 107~108 行目にある単一の curated_history.pop() から始めてください。これは 136 行目の chats.create(history=...) を通じて実行されます。google/genai/tests/chats/test_get_history.py を読み、特に意図された動作の境界を示す test_history_with_consecutive_valid_user_inputs(152 行目)と test_history_with_invalid_turns(401 行目)を確認してください。issue に示された、複数コンテンツを含む user turn と空の model turn の組み合わせで再現してください。完了条件は、無効な model turn によって直前の user の一連の発話全体が削除され、1 つのコンテンツだけが削除されるのではないこと、そして get-history のテストスイートが通ることです。
索引モデルが issue の本文から書いたものです。
説明
Title: _extract_curated_history drops only the last user content when a model turn is invalid
An invalid model turn makes _extract_curated_history call curated_history.pop() once (chats.py:107-108). A user turn of two or more Content objects went in one at a time, so one pop removes part of it. The rest stays in the curated history with no model answer behind it.
The way in is chats.create(history=...), the only caller of that function (chats.py:136): a caller persisting raw exchanges stores one content per function response, and a blocked model turn as an empty content.
At 618f0aa, through the public constructor:
$ /var/tmp/p9bL16/genai/.venv/bin/python probe_hist2.py
import: /var/tmp/p9bL16/genai/google/genai/__init__.py
curated: [('user', 1)]
comprehensive: [('user', 1), ('user', 1), ('model', 0)]
hist = [
C(role="user", parts=[P(text="what is the weather")]),
C(role="user", parts=[P.from_function_response(name="get_weather", response={"c": 21})]),
C(role="model", parts=[]), # invalid model turn
]
chat = client.chats.create(model="gemini-2.0-flash", history=hist)
The question survives and the tool result behind it disappears, so the next send_message sends a user turn the model already failed on, minus its evidence.
$ python -m pytest google/genai/tests/chats/test_get_history.py -q
17 passed, 1 warning in 0.06s
# not run: the replay suites, which need recorded sessions
Two of those tests bracket the gap. test_history_with_consecutive_valid_user_inputs (test_get_history.py:152) makes back-to-back user contents supported input, and test_history_with_invalid_turns (:401) sets the intent that the whole rejected user turn goes. One pop meets that intent only where the turn is a single content.
There is no CODEOWNERS here and every merge on GitHub is the Copybara import, so @jaycee-li, I am going by your last commit on this file. Should the pop walk back over the whole user run? I can write the diff out here if that helps the internal fix.
- 主要言語
- Python
- スター
- 4k
- フォーク
- 1k
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 52
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/python-genai のほかの issue
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC対応中かも @chauvuusvn が 3 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/python-genai#3044 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkers対応中かも @Venkaiahbabuneelam が 8 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
googleapis/python-genai#3013 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
googleapis/python-genai#3056 ·
メンテナーはふだん 1 日以内に返信
-
Vertex batch embeddings (gemini-embedding-001): no way to attach billing labels; job and row labels never reach Cloud Billing対応中かも @Venkaiahbabuneelam が今日担当しました。 オープンpriority: p3 type: question
googleapis/python-genai#3053 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
priority: p2 type: bug
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
googleapis/python-genai#3031 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
googleapis/python-genai の issue をすべて見る
似ている issue
-
needs-human needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
gke-labs/kube-agents#2400 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Device Details tables: FS/SF columns contradict each other (nfet_01v8 Vt row, pfet_01v8 Idsat row)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
google/skywater-pdk#450 ·
-
Drained trajectory arrays are overwritten when the sequence buffer is reused対応中かも @sylvesterkaczmarek が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google-deepmind/bsuite#56 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
LearningCircuit/local-deep-research#7206 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chingu-voyages/V62-tier3-team-33#285 ·
メンテナーはふだん 1 日以内に返信