Curated history keeps half a user turn when the model turn is invalid
Los mantenedores suelen responder en 1 día
@Venkaiahbabuneelam ya está trabajando en esto.
Desde el 5/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
Línea de trabajo
Comienza en _extract_curated_history en chats.py, específicamente en el único curated_history.pop() en las líneas 107-108, al que se llega mediante chats.create(history=...) en la línea 136. Lee google/genai/tests/chats/test_get_history.py, especialmente test_history_with_consecutive_valid_user_inputs (línea 152) y test_history_with_invalid_turns (línea 401), que delimitan el comportamiento previsto. Reproduce con el turno de usuario multi-content más el turno de modelo vacío mostrados en el issue. Hecho significa que un turno de modelo no válido descarta todo el user run precedente, no un solo content, y que la suite get-history pasa.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 4k
- Forks
- 1k
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 54
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de googleapis/python-genai
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFCPosiblemente ocupada @chauvuusvn la tomó hace 4 días. Abiertopriority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
googleapis/python-genai#3044 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkersPosiblemente ocupada @Venkaiahbabuneelam la tomó hace 8 días. Abiertopriority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
googleapis/python-genai#3013 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Callable tools: optional scalar parameters (`int | None`) get `"type": "object"` in `parameters_json_schema`, so Gemini sends `{}`Posiblemente ocupada @Venkaiahbabuneelam la tomó hoy. Abiertopriority: p2 type: bug
googleapis/python-genai#3060 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Gemini API latency has recently increased significantly, especially with store=truePosiblemente ocupada @Venkaiahbabuneelam la tomó hoy. Abiertopriority: p3 status:awaiting user response type: question
googleapis/python-genai#3059 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
live.connect() (Vertex AI) resolves ADC and refreshes the OAuth token synchronously on the event loop on every connectPosiblemente ocupada @Venkaiahbabuneelam la tomó hoy. Abiertopriority: p2 type: bug
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
googleapis/python-genai#3056 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de googleapis/python-genai
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 3 días
-
Negation with "not" and "no" is ignored during sentiment analysisPosiblemente ocupada @vivek-3728 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
techcsispit/mess-mood#11 · 1 comentario ·
-
changelog investigate
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ramnes/notion-sdk-py#408 ·
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
btclib-org/btclib-wallet#267 ·
Los mantenedores suelen responder en 1 día
-
good first issue tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
knnmelprop/YAADO#111 ·