fix: handle None or empty contents in Gemini token counter (#17020)

Adds null/empty check before processing contents in GoogleAIStudioTokenCounter
to prevent errors when contents is None or empty.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Haiyi 2025-11-25 12:40:00 +11:00 committed by GitHub
parent 629404a100
commit 84e8b9a7bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,6 +30,10 @@ class GoogleAIStudioTokenCounter:
from google.genai.types import FunctionResponse
# Handle None or empty contents
if not contents:
return contents
cleaned_contents = copy.deepcopy(contents)
for content in cleaned_contents: