Curated history keeps half a user turn when the model turn is invalid
Maintainer thường phản hồi trong vòng 1 ngày
@Venkaiahbabuneelam đang làm issue này rồi.
Từ ngày 5/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
Bắt đầu tại _extract_curated_history trong chats.py, cụ thể là lệnh curated_history.pop() duy nhất ở dòng 107-108, được truy cập thông qua chats.create(history=...) ở dòng 136. Đọc google/genai/tests/chats/test_get_history.py, đặc biệt là test_history_with_consecutive_valid_user_inputs (dòng 152) và test_history_with_invalid_turns (dòng 401), những test này bao quanh hành vi dự kiến. Tái hiện với lượt người dùng multi-content cộng với lượt model trống được hiển thị trong issue. Hoàn thành nghĩa là một lượt model không hợp lệ loại bỏ toàn bộ user run phía trước, không phải một content, và get-history suite vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 4k
- Fork
- 1k
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 54
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/python-genai
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFCCó thể đã có người làm @chauvuusvn đã nhận 4 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
googleapis/python-genai#3044 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkersCó thể đã có người làm @Venkaiahbabuneelam đã nhận 9 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleapis/python-genai#3013 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Callable tools: optional scalar parameters (`int | None`) get `"type": "object"` in `parameters_json_schema`, so Gemini sends `{}`Có thể đã có người làm @Venkaiahbabuneelam đã nhận hôm nay. Đang mởpriority: p2 type: bug
googleapis/python-genai#3060 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gemini API latency has recently increased significantly, especially with store=trueCó thể đã có người làm @Venkaiahbabuneelam đã nhận hôm nay. Đang mởpriority: p3 status:awaiting user response type: question
googleapis/python-genai#3059 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
live.connect() (Vertex AI) resolves ADC and refreshes the OAuth token synchronously on the event loop on every connectCó thể đã có người làm @Venkaiahbabuneelam đã nhận hôm nay. Đang mởpriority: p2 type: bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
googleapis/python-genai#3056 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/python-genai
Issue tương tự
-
defect from-review v0.9.2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
khuisman/mcp-gee-sweet#926 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 84/100
EtanHey/brainlayer#1164 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
yunaremaia/vibeguard#141 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
PrismorSec/prismor#599 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
iii-hq/iii#2278 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày