Skip to content

fix: send the thinking level on the interactions API - #7926

Closed
jhackshaw wants to merge 1 commit into
google:mainfrom
jhackshaw:fix/interactions-thinking-level
Closed

jhackshaw wants to merge 1 commit into
google:mainfrom
jhackshaw:fix/interactions-thinking-level

Conversation

@jhackshaw

@jhackshaw jhackshaw commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Send the thinking config on the interactions API. build_generation_config dropped thinking_config and logged nothing. Now thinking_level and include_thoughts are sent, thinking_budget logs a warning, and non-streaming responses keep their thought summaries.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:
With Gemini(use_interactions_api=True), nothing from thinking_config reaches the request:

  • thinking_level is dropped, so the model thinks at its default level, and an unsupported level is accepted instead of returning a 400.
  • include_thoughts is dropped, so summaries never come back.
  • thinking_budget is dropped without the warning that unsupported sampling parameters get.

The non-streaming path also discarded ThoughtStep.summary, so summaries only reached SSE mode.

Solution:

  • thinking_level → generation_config['thinking_level'], lowercased. THINKING_LEVEL_UNSPECIFIED is skipped.
  • include_thoughts → generation_config['thinking_summaries'] (True → "auto", False → "none").
  • thinking_budget has no interactions equivalent, so it gets a one-time warning like the sampling parameters.
  • Non-streaming: each ThoughtStep.summary text becomes a Part(text=..., thought=True), as _handle_thought_summary does for streaming.

No version check is needed: both fields are on interactions.GenerationConfigParam in every supported google-genai release (>= 2.30).

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New tests in tests/unittests/models/test_interactions_utils.py cover the level and summaries mapping, the budget warning, and non-streaming summary parts.

$ pytest tests/unittests/models/test_interactions_utils.py
216 passed

Without the fix, 10 of these fail.

Manual End-to-End (E2E) Tests:

An LlmAgent on gemini-3.8-flash (Vertex AI) with use_interactions_api=True and thinking_level=HIGH. ADK's DEBUG request log:

Generation Config thought tokens (reasoning prompt, 3 runs)
main {} 136, 138, 120
this branch {"thinking_level": "high"} 350, 358, 309

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

build_generation_config skipped thinking_config, so an agent's
thinking_level was dropped without a warning whenever
use_interactions_api was on. Map types.ThinkingLevel onto the
interactions API's generation_config.thinking_level, which every
supported google-genai release declares. An unspecified level is left
out, leaving the choice to the model.
@jhackshaw
jhackshaw force-pushed the fix/interactions-thinking-level branch from 315e77b to f24a937 Compare November 2, 2026 19:43
copybara-service Bot pushed a commit that referenced this pull request Nov 2, 2026
Merge #7926

With use_interactions_api, thinking_config.thinking_level is now sent as the interactions generation_config thinking_level (minimal, low, medium or high) instead of being dropped; THINKING_LEVEL_UNSPECIFIED is still left out. As on the generate_content path, a level the model does not support now gets the API's 400 instead of being silently ignored.

Fixes #7924

PiperOrigin-RevId: 1012342059
@adk-bot

adk-bot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you @jhackshaw for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit c20b90a.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Nov 2, 2026
@adk-bot adk-bot closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

thinking_config is silently dropped with use_interactions_api=True

3 participants