[PR #3840] docs: Minor change in the sql agent notebook #3498

Closed
opened 2026-02-20 17:48:42 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/3840

State: closed
Merged: No


Description:

This pull request addresses an error encountered when following the SQL agent tutorial cookbook using the Gemini LLM. Specifically, the notebook throws a ChatGoogleGenerativeAIError with the message:

ChatGoogleGenerativeAIError: Invalid argument provided to Gemini: 400 allowed_function_names should be a subset of the provided function_declarations names. Found invalid function names: required

Root Cause:

This error originates from the "Define tools for the agent" cell, where the tool_choice parameter in ChatGoogleGenerativeAI().bind_tools() is set to "required".

Solution:

This PR modifies the problematic cell by changing the tool_choice parameter from "required" to True. The agent worked well with no errors.

Affected Code:

# Before (Error-prone)
query_check = query_check_prompt | ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0).bind_tools(
    [db_query_tool], tool_choice="required"
)

# After (Corrected)
query_check = query_check_prompt | ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0).bind_tools(
    [db_query_tool], tool_choice=True
)

Reference

https://langchain-ai.github.io/langgraph/tutorials/sql-agent/#define-tools-for-the-agent

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/3840 **State:** closed **Merged:** No --- **Description:** This pull request addresses an error encountered when following the SQL agent tutorial cookbook using the Gemini LLM. Specifically, the notebook throws a `ChatGoogleGenerativeAIError` with the message: ` ChatGoogleGenerativeAIError: Invalid argument provided to Gemini: 400 allowed_function_names should be a subset of the provided function_declarations names. Found invalid function names: required ` **Root Cause:** This error originates from the "Define tools for the agent" cell, where the `tool_choice` parameter in `ChatGoogleGenerativeAI().bind_tools()` is set to `"required"`. **Solution:** This PR modifies the problematic cell by changing the `tool_choice` parameter from `"required"` to `True`. The agent worked well with no errors. **Affected Code:** ```python # Before (Error-prone) query_check = query_check_prompt | ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0).bind_tools( [db_query_tool], tool_choice="required" ) # After (Corrected) query_check = query_check_prompt | ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0).bind_tools( [db_query_tool], tool_choice=True ) ``` **Reference** [https://langchain-ai.github.io/langgraph/tutorials/sql-agent/#define-tools-for-the-agent](url)
yindo added the pull-request label 2026-02-20 17:48:42 -05:00
yindo closed this issue 2026-02-20 17:48:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#3498