LangChain adds Gemini-powered decisions for routing AI agents and screening tool calls
The beta integration returns probabilities rather than written answers. Its tool-call checks can reject destructive actions even when a user explicitly requests them.
LangChain’s beta GoogleGenAIClassifier brings Google’s Gemini Decisions API into agent workflows, turning probability-based answers into decisions application code can use. Its middleware can route runs among developer-selected models or block calls to selected tools that it judges risky. That gives developers a way to make routing and tool checks explicit, but not a guarantee of agent safety: results depend on the classifier and the tools placed behind the check. The integration requires specific LangChain and Google package versions and uses the Gemini Developer API.
01
Gemini Decision 1 evaluates predefined options in one processing pass; the API supports up to 1,000 questions against shared text or multimodal input.
02
Choice returns probabilities and confidence; Score gives a probability-weighted average, while yes/no probabilities near 0.5 indicate uncertainty.
03
AutoModeMiddleware can block a requested file deletion, but only for tools developers list and only when the classifier judges the call risky.
LangChain developers can now use Gemini to choose a model or screen an agent’s proposed tool call without asking for a written response. The beta GoogleGenAIClassifier integration is rolling out alongside Google’s November 11, 2026 launch of the Gemini Decisions API, connecting its probability-based answers to decisions that application code can act on.
Define the choices before asking
The underlying model, Gemini Decision 1, evaluates supplied options instead of composing an answer one token at a time. Google says it scores those options in a single processing pass. The API accepts up to 1,000 independent questions against shared input containing text, images, audio, video or PDFs.
LangChain exposes that service as a Runnable: a component developers can call individually, run in batches or combine with other components. Each invocation pairs the material to examine, called state, with named questions. Questions sharing that state are answered together in one request, and results retain the names supplied by the developer.
Three question types translate the result into something code can use. LangChain’s customer-support example combines all three: checking whether an item arrived damaged, choosing the responsible department and rating the customer’s frustration.
Noul handles yes/no questions. It returns the probability that a condition is true, rather than a separate confidence field.
Choice selects a label from defined options and returns probabilities and confidence. An other option can catch inputs the named categories do not cover.
Score evaluates an ordered scale. Its result is a probability-weighted average, so it can land between levels rather than selecting only a whole-number rating.
Choosing a model is different from permitting an action
Two beta middleware components put the classifier into an agent’s workflow. ModelRouterMiddleware chooses among developer-named models for each agent run, using the latest human message. LangChain’s example distinguishes simple tasks from complex ones and instructs the router to choose the least costly model capable of completing the task.
AutoModeMiddleware instead checks calls to tools the developer lists and blocks those the classifier judges risky. Its default instructions treat destructive actions as risky even when the user asks for them. In the documented file-deletion example, an explicit request to delete a file still results in a blocked call.
The middleware returns an error message to the agent instead of executing the tool, and the agent reports the block. This is a check on selected tools, not a promise that every agent action is safe: the decision depends on the classifier’s judgment and which tools the developer places behind it.
Beta requirements and boundaries
LangChain’s integration guide requires langchain-google-genai 4.5.0 or later and google-genai 3.2.0 or later. The middleware also requires LangChain 1.5.0 or later. Developers need a Google API key; requests use the Gemini Developer API, not the Gemini Enterprise Agent Platform. The beta interface may change without notice.
The classifier accepts strings, structured JSON objects and arrays, LangChain messages, and standard media blocks as state. Questions themselves have a narrower format: instructions and criteria must be text, with structured JSON sent as text. Putting media in those question fields raises an error. The integration also rejects Box, LangChain’s question type for locating objects in images.
For inspection, classifier runs appear in LangSmith under the google_genai provider and the answering model’s name. Developers can examine the decisions and token usage alongside the rest of the application’s activity.
Reader comments
Newest comments first. Replies stay oldest first.