Skip to content

Conversation

@caesarnine
Copy link
Contributor

Fixes this error that occurs with VertexAI Gemini models fairly often in my experience.

Issue that's open with the same error: #2032

ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit
request because it must include at least one parts field, which describes the prompt
input. Learn more:
https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini', 'status':
'INVALID_ARGUMENT'}}

Due to the last message being something like:

    {
        "parts": [{ "content": "", "part_kind": "text" }],
        "usage": {
            "requests": 1,
            "request_tokens": 25308,
            "response_tokens": 0,
            "total_tokens": 25308,
            "details": {
                "cached_content_tokens": 15171,
                "text_cache_tokens": 15171,
                "text_prompt_tokens": 25308
            }
        },
        "model_name": "gemini-2.5-pro",
        "timestamp": "2025-07-14T17:33:52.568858Z",
        "kind": "response",
        "vendor_details": { "finish_reason": "STOP" },
        "vendor_id": "fz91aPDpJYienvgP757VgQ0"
    }

Tested the change against a session that was previously hard crashing and it works fine now.

@DouweM
Copy link
Collaborator

DouweM commented Jul 16, 2025

@caesarnine Thanks! Can you please add a test for the scenario that this fixes, to ensure it doesn't accidentally break again in the future?

@caesarnine
Copy link
Contributor Author

caesarnine commented Jul 17, 2025

@DouweM Done - let me know if it looks ok (never used pytest-vcr anymore, so feel free to let me know if I did something wrong there).

@Kludex Kludex merged commit 420166d into pydantic:main Jul 17, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants