Force schema inspection
A workflow stage must retrieve database schema before generating a query.
AI Agents · Const
tool_choice controls whether a model must call a bound tool. In the JavaScript workflow, tool_choice: "any" forces a tool call for a dedicated agent step.
Tool choice configures how a model uses bound tools. In the documented JavaScript workflow, passing tool_choice: "any" to bindTools forces the model to select a tool, which is useful when a workflow step must perform a tool operation before continuing.
model.bindTools(tools, { tool_choice: "any" })| Name | Type | Description |
|---|---|---|
tool_choice | string | Tool-choice policy passed to the model binding; the documented JavaScript example uses "any" to force a tool call. |
A model response produced after applying the selected tool-choice policy; with "any", the invocation requires a tool call.
any value to require that the model call a tool.const llmWithTools = model.bindTools([getSchemaTool], {
tool_choice: "any",
});
const response = await llmWithTools.invoke(state.messages);Binds a model to a tool and requires a tool call when invoking it.
A workflow stage must retrieve database schema before generating a query.
A multi-stage agent needs mandatory tool operations at selected points.
Different steps require different instructions while using tools.
tool_choice: "any" do?tool_choice controls whether and how a model selects among tools bound to it. In the JavaScript example, "any" requires a tool call for that invocation.
Follow-up: How can a workflow guarantee a particular operation? Use a dedicated node with only the required tool bound, then invoke the model with an appropriate forced tool-choice setting.
The model is first bound to the relevant tool with bindTools, and the resulting model is then invoked with the current message state. This keeps tool selection inside the workflow node.
Follow-up: Why use a dedicated node? It lets the workflow force tool calls at specific stages and customize the prompt for each stage.
Dedicated nodes can force tool calls when needed and customize prompts associated with each step. The search result documents this pattern for listing tables, retrieving schema, generating a query, and checking it.
Follow-up: What is the broader design benefit? Explicit stages provide finer control than leaving the entire sequence to one unconstrained agent loop.
bindToolsToolNodetool callingdedicated nodes