Interactions API: HTTP 400 “Model generated too many tool calls” with built-in Google Search and tool_choice="any" on Gemini 3.7/3.8 Flash

Hello Google AI team,

I am trying to determine whether this is an unsupported combination, an intended limitation of tool_choice=“any”, or a problem in the Interactions API’s server-side tool execution.

Using the built-in google_search tool together with generation_config.tool_choice=“any”, I observed HTTP 400 responses from both gemini-3.7-flash and gemini-3.8-flash, even with a very short factual question and no structured-output constraint.

In a separate controlled comparison, gemini-3.8-flash completed a short request and actually executed Google Search when generation_config was omitted. The same question with tool_choice=“any” had previously reached the 300-second client timeout.

I am reporting the observations below, not claiming that an infinite internal tool loop has been proven.

Environment and settings

Item Configuration
Observation date October 8, 2026, KST
API Gemini Developer API
Endpoint POST https://generativelanguage.googleapis.com/v1beta/interactions
Client Node.js native fetch, without a model SDK or agent framework
Revision header Api-Revision: 2026-05-20
Execution Sequential, one request per case
Automatic retries / fallback None
Client timeout 300 seconds
Response mode Non-streaming
Storage store: false
Thinking level / output limit / sampling parameters Not explicitly set
Conversation history / system instruction None
JSON Schema / response_format None in the minimal reproduction
Tools Built-in google_search only; no user-defined functions

The same API credential was used within each comparison. Credentials and account/project identifiers are omitted from this report.

The revision header is included here to preserve the actual request configuration; I am not assuming that it pins the provider’s internal runtime.

1. Minimal failing request

The exact input was:

대한민국의 수도는 서울인가? Y/N

English translation for reference only:

Is Seoul the capital of South Korea? Y/N

The requests used the Korean text, not the translation.

{
  "model": "gemini-3.7-flash",
  "input": "대한민국의 수도는 서울인가? Y/N",
  "tools": [
    {
      "type": "google_search"
    }
  ],
  "generation_config": {
    "tool_choice": "any"
  },
  "store": false
}

For the second request, the only request-body change was the model ID:

"model": "gemini-3.8-flash"

Equivalent REST reproduction: save the request body as UTF-8 request.json and submit it once using your own API key. The observations below were collected with native fetch; this cURL command expresses the same request.

curl --request POST \
  'https://generativelanguage.googleapis.com/v1beta/interactions' \
  --header 'Content-Type: application/json' \
  --header "x-goog-api-key: ${GEMINI_API_KEY}" \
  --header 'Api-Revision: 2026-05-20' \
  --max-time 300 \
  --data-binary @request.json

2. Observed results

Requested model HTTP result Elapsed time
gemini-3.7-flash 400 75.940 seconds
gemini-3.8-flash 400 77.886 seconds

Both returned identical error response bodies. Extracted error fields:

error.code:
Model generated function call(s).

error.message:
Model generated too many tool calls. Please retry the request. If the issue persists, include this error message in the retry prompt to allow the model to call a valid number of tools.

No usable final output, usage statistics, or execution steps were returned with these errors.

Consequently, I cannot determine the actual number of internal tool calls. A local diagnostic value of zero must not be interpreted as evidence that Google Search was never executed.

The question is deliberately simple. The purpose is to test required-search behavior, not whether the model already knows the answer from training data.

3. Separate control: Search enabled without explicit tool_choice

For this comparison, all cases used gemini-3.8-flash and the following exact input:

특정 단체 A가 데뷔했는가? yes/no

English translation for reference:

Has a new A debuted? yes/no

Tools Generation config Observed result Elapsed time
Omitted Omitted HTTP 200, status=“completed” 18.163 seconds
google_search Omitted HTTP 200, status=“completed”, with actual Search steps 33.147 seconds
google_search {“tool_choice”:“any”} Client timeout; final provider outcome unknown 300.009 seconds

The successful Search-enabled request contained:

google_search_call steps: 1
google_search_result steps: 1

Its usage object also reported:

"grounding_tool_count": [
  {
    "type": "google_search",
    "count": 2,
    "search_query_count": 2
  }
]

I am keeping visible call-step counts and search-query usage counts separate.

The timeout is not being reported as an HTTP 400.

This is a separate prompt from the capital-city reproduction above. Within this control group, the input and other request settings were held fixed. These were individual diagnostic runs, not a statistical reliability study.

4. Additional model comparison

In an earlier, separate test, a longer research prompt and its JSON Schema were held fixed across three sequential requests, with only the requested model ID changed:

Requested model Result
gemini-3.1-pro-preview HTTP 200, completed
gemini-3-flash-preview HTTP 200, completed
gemini-3.8-flash HTTP 400 with the same “too many tool calls” message

Those requests also used built-in Google Search and tool_choice=“any”.

This is supporting context, not a claim that the longer test is identical to the minimal reproduction above. HTTP success also does not establish factual accuracy or source quality. Thinking settings were omitted, so model-specific defaults may differ.

5. Intended behavior

Our application must not accept a response based solely on model memory when current web research is required.

We need an actual Google Search invocation and inspectable grounding/source evidence before accepting a research result. Merely enabling Search without verifying that it ran would not satisfy that requirement.

I understand that forcing a tool call may not mean:

Search at least once, then automatically release the constraint and generate a final answer.

That distinction is exactly what I would like clarified.

6. Questions for the Google team

  1. Is generation_config.tool_choice=“any” supported with the built-in google_search tool on Gemini 3.7/3.8 Flash? Or is its documented function-calling behavior not applicable to this server-managed tool?

  2. If supported, what is its scope within one Interaction? Does it constrain only the initial tool selection, or every internally managed model turn after Search results are returned? How is a final text response supposed to be produced?

  3. Is there a documented way to require at least one actual Google Search execution and then allow normal completion? If no such option is supported, please confirm that explicitly so we can design appropriate application-side acceptance checks.

  4. Are these 400 responses a known limitation or issue? Is there a relevant model-specific configuration, or a documented difference between /v1beta/interactions and /v1/interactions, that should be tested? The results above are from /v1beta/interactions only.

  5. Would an SSE trace be useful for diagnosis, and which fields should be included? A possible next test is to keep the failing request unchanged except for stream: true and record tool-step types, timestamps, and terminal status/errors. That streaming test has not yet been performed.

I have not observed the internal execution sequence of the failing requests, so I cannot distinguish a model repeatedly selecting Search from an orchestration or termination issue.

I would appreciate clarification of the supported contract before changing the production search requirement or adding more retries.

Thank you.

gemini_interactions_search_any_bug_report.md문서

Interactions API: HTTP 400 “Model generated too many tool calls” with built-in Google Search and tool_choice=“any” on Gemini 3.7/3.8 Flash

Hello Google AI team,

I am trying to determine whether this is an unsupported combination, an intended limitation of tool_choice=“any”, or a problem in the Interactions API’s server-side tool execution.

Using the built-in google_search tool together with generation_config.tool_choice=“any”, I observed HTTP 400 responses from both gemini-3.7-flash and gemini-3.8-flash, even with a very short factual question and no structured-output constraint.

In a separate controlled comparison, gemini-3.8-flash completed a short request and actually executed Google Search when generation_config was omitted. The same question with tool_choice=“any” had previously reached the 300-second client timeout.

I am reporting the observations below, not claiming that an infinite internal tool loop has been proven.

Environment and request settings

  • Observed on October 8, 2026 (KST).
  • Gemini Developer API, direct REST requests using Node.js native fetch; no model SDK, agent framework, or client-managed tool loop.
  • Endpoint: POST https://generativelanguage.googleapis.com/v1beta/interactions.
  • Header included in all requests: Api-Revision: 2026-05-20.
  • Same API credential for each comparison; API keys and account/project identifiers are omitted from this report.
  • One sequential request per case, with no automatic retry or fallback and a 300-second client timeout.
  • store: false; non-streaming; no previous_interaction_id, conversation history, or system instruction.
  • No response_format, JSON Schema, explicit thinking level, output-token limit, or sampling parameters in the minimal reproduction.
  • google_search was the only tool. No user-defined functions were supplied.

The legacy revision header is shown to preserve the actual request configuration. I am not assuming that it pins the provider’s internal runtime or model behavior.

1. Minimal failing request

The exact input was:

대한민국의 수도는 서울인가? Y/N

English translation for reference only: “Is Seoul the capital of South Korea? Y/N”. The requests used the Korean text above, not the translation.

Request body:

{
"model": "gemini-3.7-flash",
"input": "대한민국의 수도는 서울인가? Y/N",
"tools": [{ "type": "google_search" }],
"generation_config": {
"tool_choice": "any"
},
"store": false
}

For the second request, the only request-body change was:

"model": "gemini-3.8-flash"

Equivalent REST reproduction: save the body as UTF-8 request.json and submit it once using your own API key. The observations below were collected with native fetch; this cURL command expresses the same request.

curl --request POST \
'https://generativelanguage.googleapis.com/v1beta/interactions' \
--header 'Content-Type: application/json' \
--header "x-goog-api-key: ${GEMINI_API_KEY}" \
--header 'Api-Revision: 2026-05-20' \
--max-time 300 \
--data-binary @request.json

Observed results

Requested model HTTP result Elapsed time Returned provider message
gemini-3.7-flash 400 75.940 seconds Model generated too many tool calls
gemini-3.8-flash 400 77.886 seconds Model generated too many tool calls

Both returned identical error response bodies. Extracted error fields:

error.code:
Model generated function call(s).

error.message:
Model generated too many tool calls. Please retry the request. If the issue persists, include this error message in the retry prompt to allow the model to call a valid number of tools.

No usable final output, usage statistics, or execution steps were returned with these errors. Consequently, I cannot determine the actual number of internal tool calls. A local diagnostic value of zero must not be interpreted as evidence that Google Search was never executed.

The question is deliberately simple. The purpose is to test required-search behavior, not whether the model already knows the answer from training data.

2. Separate control: Search enabled without explicit tool_choice

For this comparison, all cases used gemini-3.8-flash and the following exact input:

홀로라이브의 신유닛이 데뷔했는가? yes/no

English translation for reference: “Has a new Hololive unit debuted? yes/no”.

Tools Generation config Observed result Elapsed time
Omitted Omitted HTTP 200, status=“completed” 18.163 seconds
[{“type”:“google_search”}] Omitted HTTP 200, status=“completed”, with actual Search steps 33.147 seconds
[{“type”:“google_search”}] {“tool_choice”:“any”} Client timeout; final provider outcome unknown 300.009 seconds

The successful Search-enabled request contained one google_search_call step and one google_search_result step. Its usage object also reported search_query_count: 2 under grounding_tool_count. I am keeping visible call-step counts and search-query usage counts separate.

The timeout is not being reported as an HTTP 400.

This is a separate prompt from the capital-city reproduction above. Within this control group the input and the other request settings were held fixed; the runs were not a statistical reliability study.

3. Additional model comparison

In an earlier, separate test, a longer research prompt and its JSON Schema were held fixed across three sequential requests, with only the requested model ID changed:

Requested model Result
gemini-3.1-pro-preview HTTP 200, completed
gemini-3-flash-preview HTTP 200, completed
gemini-3.8-flash HTTP 400 with the same “too many tool calls” message

Those requests also used built-in Google Search and tool_choice=“any”. This is supporting context, not a claim that the longer test is identical to the minimal reproduction above. HTTP success also does not establish factual accuracy or source quality. Thinking settings were omitted, so model-specific defaults may differ.

Intended behavior and questions

Our application must not accept a response based solely on model memory when current web research is required. We need an actual Google Search invocation and inspectable grounding/source evidence before accepting a research result. Merely enabling Search without verifying that it ran would not satisfy that requirement.

I understand that forcing a tool call may not mean “search at least once, then automatically release the constraint and generate a final answer.” That distinction is exactly what I would like clarified.

  1. Is generation_config.tool_choice=“any” supported with the built-in google_search tool on Gemini 3.7/3.8 Flash? Or is its documented function-calling behavior not applicable to this server-managed tool?
  2. If supported, what is its scope within one Interaction? Does it constrain only the initial tool selection, or every internally managed model turn after Search results are returned? How is a final text response supposed to be produced?
  3. Is there a documented way to require at least one actual Google Search execution and then allow normal completion? If no such option is supported, please confirm that explicitly so we can design appropriate application-side acceptance checks.
  4. Are the reported 400 responses a known limitation or issue? Is there a relevant model-specific configuration, or a documented difference between /v1beta/interactions and /v1/interactions, that should be tested? The results above are from /v1beta/interactions only.
  5. Would an SSE trace be useful for diagnosis, and which fields should be included? A possible next test is to keep the failing request unchanged except for stream: true and record tool-step types, timestamps, and terminal status/errors. That streaming test has not yet been performed.

I have not observed the internal execution sequence of the failing requests, so I cannot distinguish a model repeatedly selecting Search from an orchestration or termination issue. I would appreciate clarification of the supported contract before changing the production search requirement or adding more retries.

Documentation consulted

Thank you.

Hello @BL_ANK ,

Thank you for the detailed report. We are looking into this issue.