Tool calling doesn't work for new gemini-3.6-flash and gemini-3.5-flash-lite models on Vertex AI (Enterprise Agents Platform) via OpenAI compatibility API

I’m using OpenAI SDK and OpenAI compatibility API (chat-completions) to work with Gemini models on both Gemini API and Vertex AI (Enterprise Agents Platform).

Newly released gemini-3.6-flash and gemini-3.5-flash-lite models work perfectly fine on Gemini API - both text responses and tool calling.

However on Vertex AI (Enterprise Agents Platform) text responses work fine, but tool calls fail whenever I return tool response to the model. The error is really vague and looks like this:

"Error code: 400 - [{'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}]."

My request contains proper “thought_signature” in tool call’s “extra_content” and looks like this:
CHAT COMPLETIONS: {'model': 'google/gemini-3.6-flash', 'messages': [{'role': <Role.SYSTEM: 'system'>, 'content': 'You are a helpful assistant'}, {'role': <Role.USER: 'user'>, 'content': 'London'}, {'role': <Role.ASSISTANT: 'assistant'>, 'content': ' ', 'tool_calls': [{'id': 'HZRaIv7r', 'type': 'function', 'function': {'name': 'check_weather', 'arguments': '{"city": "London", "request": "check_weather"}'}, 'extra_content': {'google': {'thought_signature': 'AY89a18jrq7yvtKtBC/rzD4FOHNRkobskAkss1gEoT4NxHS2yPVVlFMqlS9N6RKMvqQ2IoVqNMn5kVneaChZX0JDYfjfn+N/QbtSpajzuReKpcfX3vBFSSebTugII5Tb6LMO1V81WlxFSTneNa/gge+1mY6YZFNMjoZj+U8c+o+zbL/F6dvty6QXlQ3vPN+PuuFAM1PfJrUcnVWF22QDJHsEeavvWbVYBT/hH1ZJwskWzKKXaf1Z8PZgLDS4k/1aseVMj9JKM0WT4l1MIvcUImtF0SexwiFA50V1JkcEJPGNJDKEpYyIFme5bd1UD2/qa8ZxgQqt55Ol60xuew9hmbFOW2KBmiR9rnMDadNJn4+JPgQcvp1M9NVCOxHsCAOQx5ok0CIf5CNW1p/AgYtvJK8MazupY0pvo4xfY4/NvU3LJuUP+QvKBkIJ4pTeoPGMhetxvWzBDK8MVUNdkki7QnZIskj1sZCpTb49KhAQLpianeKp05bqS/BWDwvxtSQV0U67L0UX0uWRDsBTLJG6SIhT1OayUBHC5h3BQWI8LaY36KyucVhtWXsgWFGhvZmJB+Kybo0vl7P7kLZ2v5IIP/2yRLYh5+G56SBU/TbHIENTdMc5QG68khuweydVqbbJZBq+fE6FZyxTkZtGf0DESl56BTLLNWpjjTX7Bhc='}}}]}, {'role': <Role.TOOL: 'tool'>, 'tool_call_id': 'HZRaIv7r', 'content': '{"city": "London", "temperatureC": "26", "condition": "Cloudy ", "source": "worldweatheronline", "forecast": [{"date": "2026-07-23", "minTempC": "18", "maxTempC": "26", "avgTempC": "21", "condition": "Partly Cloudy ", "maxWindKmph": 12, "maxChanceOfRain": 14, "totalPrecipMM": 0.0}, {"date": "2026-07-24", "minTempC": "17", "maxTempC": "31", "avgTempC": "24", "condition": "Clear ", "maxWindKmph": 15, "maxChanceOfRain": 8, "totalPrecipMM": 0.0}, {"date": "2026-07-25", "minTempC": "18", "maxTempC": "29", "avgTempC": "22", "condition": "Clear ", "maxWindKmph": 27, "maxChanceOfRain": 11, "totalPrecipMM": 0.0}], "cached": false}'}], 'max_completion_tokens': 1000, 'stream': True, 'stream_options': {'include_usage': True}, 'temperature': 0.6, 'extra_body': {'google': {'thinking_config': {'includeThoughts': True, 'thinkingLevel': 'MEDIUM'}, 'thought_tag_marker': 'think'}}, 'tools': [{'type': 'function', 'function': {'name': 'check_weather', 'description': 'Get weather forecast for specific city', 'parameters': {'properties': {'city': {'description': 'City name', 'type': 'string'}}, 'required': ['city'], 'type': 'object'}, 'strict': False}}, {'type': 'function', 'function': {'name': 'end_call', 'description': 'Terminate the conversation or hang up the call.\nUSAGE INSTRUCTIONS:\n- If you want to say something prior to ending the conversation, use the "termination_message" field.\n- Never output termination message or tool name as plain text.\n', 'parameters': {'properties': {'termination_message': {'default': '', 'description': 'Optional message to be said while terminating the conversation / hanging up the call.', 'type': 'string'}}, 'type': 'object', 'required': []}, 'strict': False}}], 'tool_choice': 'auto'}

Older models - e.g. gemini-3.5-flash and gemini-3.1-flash-lite - work perfectly fine on both Gemini API and Vertex AI.

Any idea of what is the exact reason for this failure? And how to work around it?

Cheers,
Alex

Nevermind - found the root cause - it’s non-empty “content” in tool call that my framework inserted by mistake