Automatic function calling rejects `datetime` and `UUID` arguments
Mantenedores costumam responder em até 1 dia
@Venkaiahbabuneelam já está trabalhando nisso.
Desde 11/11/2026.
- #3333 de @copybara-service — aberto
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 75/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- python
- Domínio
- backend-api-design
Direção de pesquisa
Start by reading convert_if_exist_pydantic_model, which the issue identifies as the point rejecting JSON strings for datetime and UUID, and compare its validation with the pydantic schema generation. Check the automatic function calling tests for argument conversion and add coverage for both types. Done when valid schema-compatible strings reach the tool as converted arguments and the tests pass.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Environment details
- Programming language: Python
- OS: macOS
- Language runtime version: Python 3.12.13
- Package version: google-genai 3.0.0 (same on 2.24.0 and
main)
Steps to reproduce
With automatic function calling, a tool that takes a datetime or a UUID never runs. The declaration tells the model to send a date-time (or uuid) string, the model does, and google-genai rejects it.
This fakes the Gemini API, so no key is needed:
import datetime, json, uuid
import httpx
from google import genai
from google.genai import types
ran, sent = [], []
def schedule(when: datetime.datetime, job_id: uuid.UUID) -> str:
"""Schedule a job."""
ran.append(True)
return "ok"
def fake_gemini(request):
sent.append(json.loads(request.content))
args = {"when": "2026-11-10T09:30:00Z", "job_id": "12345678-1234-5678-1234-567812345678"}
part = {"functionCall": {"name": "schedule", "args": args}} if len(sent) == 1 else {"text": "done"}
return httpx.Response(200, json={"candidates": [{"content": {"role": "model", "parts": [part]}}]})
client = genai.Client(
api_key="fake",
http_options=types.HttpOptions(httpx_client=httpx.Client(transport=httpx.MockTransport(fake_gemini))),
)
client.models.generate_content(
model="gemini-2.5-flash", contents="Schedule it.", config=types.GenerateContentConfig(tools=[schedule])
)
print("declared:", sent[0]["tools"][0]["functionDeclarations"][0]["parameters_json_schema"]["properties"])
print("ran:", bool(ran))
print("sent back:", sent[1]["contents"][-1]["parts"][0]["functionResponse"]["response"])
uv run --no-project --python 3.12 --with "google-genai[httpx]==3.0.0" python repro.py prints:
declared: {'when': {'format': 'date-time', 'type': 'string'}, 'job_id': {'format': 'uuid', 'type': 'string'}}
ran: False
sent back: {'error': "Failed to parse parameter when for function schedule from function call part because function call argument value 2026-11-10T09:30:00Z is not compatible with parameter annotation <class 'datetime.datetime'>."}
job_id fails the same way once when is gone. The call still completes, so nothing says the tool never ran.
The cause: the schema comes from pydantic, but convert_if_exist_pydantic_model ends with isinstance(value, annotation), and a JSON string is never a datetime or UUID. Validating with pydantic too, e.g. pydantic.TypeAdapter(annotation).validate_python(value), would make them agree.
Related, for other types: #2013 (set[str] and other generics, fix in #3295) and #2199 (IntEnum, fix in #3288). From their diffs, neither PR covers datetime or UUID.
Thanks!
- Linguagem predominante
- Python
- Estrelas
- 4.1k
- Forks
- 1.1k
- Merge médio
- 1d 20h
- PRs com merge (30d)
- 90
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleapis/python-genai
-
Interactions retries ignore the documented `initial_delay` and `max_delay` defaultsTalvez já em andamento @Venkaiahbabuneelam assumiu há 5 dias. Abertapriority: p2 status:awaiting user response type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
googleapis/python-genai#3317 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Test import module that doesn't existTalvez já em andamento @Venkaiahbabuneelam assumiu há 31 dias. Abertapriority: p2 type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
googleapis/python-genai#3122 · 6 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Curated history keeps half a user turn when the model turn is invalidTalvez já em andamento @Venkaiahbabuneelam assumiu há 40 dias. Abertapriority: p2 type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
googleapis/python-genai#3051 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFCTalvez já em andamento @Venkaiahbabuneelam assumiu há 40 dias. Abertapriority: p2 type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
googleapis/python-genai#3044 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Structured-output continuation merge raises AttributeError: __pydantic_generic_metadata__ when a hop has parsed JSONTalvez já em andamento @Venkaiahbabuneelam assumiu há 3 dias. Abertapriority: p2 type: bug
googleapis/python-genai#3350 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de googleapis/python-genai
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
OCA/account-invoicing#2529 ·
Mantenedores costumam responder em até 1 dia
-
area/ci
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
ImageGen generate-batch aborts valid JSONL jobs containing a Unicode line separator in poster textAbertabug imagen skills
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Email validation accepts a trailing newlineTalvez já em andamento @marcello-pichini assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia