Previously, the test created a user first (without team_id), then added them
to a team. This caused the API key to have team_id=None, which broke team
budget tracking and enforcement.
The fix:
- Create team first, then create user with team_id parameter
- This ensures the API key gets team_id set from creation time
- Team budget tracking and enforcement now work correctly
Added comprehensive comments explaining why the order is critical and should
not be changed, as it tests the intended flow where keys are associated with
teams at creation time.
Also added extensive debugging output to help diagnose future issues.
The Responses API expects tool results to use input_text/input_image types,
not output_text. This fix ensures consistent list format for all tool results:
- String content → [{"type": "input_text", "text": "..."}]
- Image content → [{"type": "input_image", "image_url": "..."}]
This resolves the conflict between tests that expected different formats
and aligns with OpenAI's Responses API requirements.
Fixes the regression introduced in #18226.
Fixes#18282
This PR fixes two issues with Gemini context window error handling:
1. **Pattern matching for Gemini 2.0 Flash**: The previous pattern
'input token count exceeds the maximum number of tokens allowed'
doesn't match Gemini 2.0 Flash errors which include dynamic token
counts like '(2800010)' in the message. Split into shorter patterns
that work with both formats.
2. **Add context window check to Gemini block**: The
is_error_str_context_window_exceeded() check was only called for
OpenAI-compatible providers, not for Gemini/Vertex AI. Added the
check to the Gemini-specific error handling block.
Test cases added for both Gemini 2.0 Flash and 2.5/3 error formats.