The name of the middleware instance.
Logic to run before the agent execution starts.
Async logic to run before the agent execution starts.
Logic to run before the model is called.
Async logic to run before the model is called.
Logic to run after the model is called.
Async logic to run after the model is called.
Intercept and control model execution via handler callback.
Intercept and control async model execution via handler callback.
Logic to run after the agent execution completes.
Async logic to run after the agent execution completes.
| Name | Type | Description |
|---|---|---|
tools | list[str | BaseTool] | None | Default: NoneList of tool names ( If If empty list, no tools will be emulated. |
model | str | BaseChatModel | None | Default: None |
| Name | Type |
|---|---|
| tools | list[str | BaseTool] | None |
| model | str | BaseChatModel | None |
Emulates specified tools using an LLM instead of executing them.
This middleware allows selective emulation of tools for testing purposes.
By default (when tools=None), all tools are emulated. You can specify which
tools to emulate by passing a list of tool names or BaseTool instances.
Model to use for emulation.
Defaults to 'anthropic:claude-sonnet-4-5-20250929', which requires
langchain-anthropic to be installed.
Relying on the implicit default is deprecated and will be
removed in a future release, since it makes this middleware
depend on langchain-anthropic even when unspecified. Pass
model explicitly instead.
Can be a model identifier string or BaseChatModel instance.