Skip to content

fix: preserve Gemini thinking blocks#5713

Open
he-yufeng wants to merge 2 commits into
google:mainfrom
he-yufeng:fix/gemini-thinking-block-signatures
Open

fix: preserve Gemini thinking blocks#5713
he-yufeng wants to merge 2 commits into
google:mainfrom
he-yufeng:fix/gemini-thinking-block-signatures

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • recognize Gemini-shaped thinking_blocks even when blocks do not carry Anthropic-style per-block signatures
  • merge LiteLLM's parallel provider_specific_fields.thought_signatures into those blocks before converting them to ADK thought parts
  • add regression coverage for Gemini blocks with and without signatures, plus the generated response conversion path

Fixes #5712.

To verify

  • python -m pytest tests/unittests/models/test_litellm.py -q -k "thinking_blocks or thought_signature" --basetemp .tmp/pytest
  • python -m pytest tests/unittests/models/test_litellm.py -q --basetemp .tmp/pytest
  • python -m py_compile src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • python -m pyink --check src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py

@he-yufeng he-yufeng force-pushed the fix/gemini-thinking-block-signatures branch from bee917c to 51542ce Compare May 16, 2026 09:07
@he-yufeng
Copy link
Copy Markdown
Author

Rebased this onto current upstream/main and force-pushed the branch. The PR diff is still limited to the LiteLLM Gemini thinking-block handling and its unit coverage.

Local validation after the rebase:

  • .venv\Scripts\python.exe -m pytest tests/unittests/models/test_litellm.py -q -k "thinking_blocks or thought_signature" (18 passed)
  • .venv\Scripts\python.exe -m py_compile src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • .venv\Scripts\pyink.exe --check src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • .venv\Scripts\isort.exe --check-only src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • git diff --check upstream/main..HEAD

The remaining visible failure is still the repository triage bot, not a code test failure.

@rohityan rohityan self-assigned this May 18, 2026
@rohityan rohityan added models [Component] Issues related to model support needs review [Status] The PR/issue is awaiting review from the maintainer labels May 18, 2026
@rohityan rohityan requested a review from sasha-gitg May 18, 2026 19:11
@rohityan
Copy link
Copy Markdown
Collaborator

Hi @he-yufeng , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan
Copy link
Copy Markdown
Collaborator

Hi @sasha-gitg , can you please review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] Issues related to model support needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LiteLLM] _is_thinking_blocks_format drops Gemini thinking_blocks (only matches Anthropic 'signature' key)

2 participants