Configuration options for the middleware
Options for configuring the Tool Emulator middleware.
Optionalmodel?: anyModel to use for emulation.
Optionaltools?: any[]List of tool names (string) or tool instances to emulate.
undefined (default), ALL tools will be emulated.import { toolEmulatorMiddleware } from "@langchain/langchain/agents/middleware";
import { createAgent } from "@langchain/langchain/agents";
const middleware = toolEmulatorMiddleware();
const agent = createAgent({
model: "openai:gpt-4o",
tools: [getWeather, getUserLocation, calculator],
middleware: [middleware],
});
const middleware = toolEmulatorMiddleware({
tools: ["get_weather", "get_user_location"]
});
Middleware that emulates specified tools using an LLM instead of executing them.
This middleware allows selective emulation of tools for testing purposes. By default (when
toolsis undefined), all tools are emulated. You can specify which tools to emulate by passing a list of tool names or tool instances.