Skip to content

fix: prevent title generation from hanging with Gemini 3 models#1602

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:fix-gemini-titles
Feb 5, 2026
Merged

fix: prevent title generation from hanging with Gemini 3 models#1602
dgageot merged 1 commit intodocker:mainfrom
dgageot:fix-gemini-titles

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Feb 5, 2026

When using Gemini 3 models (e.g., gemini-3-flash-preview), title generation would hang because thinking was not being properly disabled. The low max_tokens (20) used for title generation left no room for thinking tokens, causing the API to hang.

Changes:

  • Set ThinkingBudget=0 in Gemini client when ModelOptions.Thinking() is false, which completely disables thinking at the API level
  • Add 30-second timeout to title generation as a safety net
  • Fix FromModelOptions to preserve the thinking setting when cloning providers

Assisted-By: cagent

@dgageot dgageot requested a review from a team as a code owner February 5, 2026 08:16
github-actions[bot]
github-actions bot previously approved these changes Feb 5, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

No bugs found in the changed code.

This PR properly addresses the Gemini 3 model hanging issue by:

  1. Correctly implementing thinking override logic - The new buildConfig() code properly checks if thinking is explicitly disabled via ModelOptions.Thinking() and sets ThinkingBudget=0 before falling back to config-based thinking settings

  2. Proper nil safety - All pointer dereferences are guarded with nil checks (e.g., thinking != nil && !*thinking)

  3. Good context management - The timeout in generator.go correctly wraps the entire title generation operation with proper cleanup via defer cancel()

  4. Complete fix for FromModelOptions - The thinking option is now properly preserved when cloning providers

  5. Comprehensive test coverage - Tests cover all three scenarios: thinking explicitly disabled, explicitly enabled, and not set

The implementation is well-documented and follows Go best practices for pointer handling, context management, and error prevention.

When using Gemini 3 models (e.g., gemini-3-flash-preview), title generation
would hang because thinking was not being properly disabled. The low
max_tokens (20) used for title generation left no room for thinking tokens,
causing the API to hang.

Changes:
- Set ThinkingBudget=0 in Gemini client when ModelOptions.Thinking() is false,
  which completely disables thinking at the API level
- Add 30-second timeout to title generation as a safety net
- Fix FromModelOptions to preserve the thinking setting when cloning providers

Assisted-By: cagent
@dgageot dgageot merged commit ac7961f into docker:main Feb 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants