Unexpected Tool Call is not a valid backing for enum

Created on 10 October 2025, 15 days ago

Problem/Motivation

I'm seeing an error related to using Gemini as an AI Provider in Drupal 10.

ValueError: "UNEXPECTED_TOOL_CALL" is not a valid backing value for enum Gemini\Enums\FinishReason in Gemini\Enums\FinishReason::from() (line 60 of /app/vendor/google-gemini-php/client/src/Data/Candidate.php).

Here's the full trace.

Drupal\ai_agents\Form\AiAgentForm->save()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 637)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I've determined that running my chatbot agent is causing the error. This agent is a "project manager" that uses several other agents. I've tested the other agents individually and I don't think they are causing the error.

The chatbot agent connects to a Pinecone vector database which is indexed with site content. The chatbot agent is not functional currently since I switched to Gemini provider. Search API is able to reach the pinecone server.

The chatbot agent is configured to use various sub-agent tools and the content type agent. It is configured to use RAG/Vector Search.

I believe this error is related to something that's preventing this agent from working and stopping the associated chatbot assistant from working.

Steps to reproduce

Currently, I'm using Gemini Flash as my provider for all AI tools. Many of the tools are working fine, though I'm having a connection issue using AI Chatbot.

To reproduce, you would need to use Drupal 10, then set up Drupal AI and AI Chatbot. Configure Gemini AI provider. Configure all AI provider tools with Gemini. Note the exact embeddings model used. Create a Search API vector database and index it with something. Make sure embeddings matches the model in provider settings. Create an agent to use with AI Chatbot, making sure it can use Vector Search. Add an AI Assistant, based on this agent. Configure the chatbot block to use this assistant.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rraney

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024