LangChain ships a Jev classifier, then parks it on the agent loop
Official LangChain docs add langchain-typesafe, introducing a Runnable for classification alongside experimental middleware hooks for agent loops.
On September 17, LangChain released a tutorial along with langchain-typesafe, a Python integration package providing an input classifier and two experimental middleware classes.
TypeSafeClassifier implements LangChain’s Runnable interface. Callers supply state (such as a string, JSON payload, or message history) along with explicit questions, receiving structured nouls, choices, and scores. The component bypasses chat completion interfaces and integrates with LangSmith tracing.
The package introduces two middleware classes intended for use with create_agent. ModelRouterMiddleware evaluates incoming user messages to select an appropriate chat model for the active session. AutoModeMiddleware intercepts prospective tool calls, blocking actions classified as risky. Both utilities are designated as experimental, with documentation recommending pairing automated gates with human approval workflows for sensitive operations.
The tutorial references TypeSafe’s reported 200x speed and 400x cost benchmarks, which originate from TypeSafe’s own documentation rather than a LangChain comparison.
This site's reading
Editorial notes evaluating claims against primary sources, contextualizing findings alongside related implementations, and defining technical terms.
Verify
The package name, TypeSafeClassifier, ModelRouterMiddleware, and AutoModeMiddleware correspond with LangChain's official documentation. Installation uses uv add langchain-typesafe; the middleware extra is specified as langchain-typesafe[experimental], with docs noting these APIs remain subject to change. The tutorial repeats TypeSafe's reported 200x speed and 400x cost figures, which reflect TypeSafe's published benchmarks rather than an independent LangChain evaluation. AutoModeMiddleware returns an error ToolMessage when a tool call scores as high-risk, without soliciting human approval. Documentation advises against passing sensitive credentials in tool arguments when calling external providers. We did not run the package.
Compare
This represents the first major agent framework providing dedicated primitives for Jev rather than generic HTTP calls. While host gateways list the model directly, LangChain packages it into its workflow model via a classifier and execution hooks. ModelRouterMiddleware serves a similar routing function to community-built routers, integrated with LangChain state. AutoModeMiddleware resembles safety guardrails embedded in closed-source harnesses, formalizing tool refusal rules. Kyle Jeong's Stagehand demo is referenced in the tutorial as prior art rather than as a built-in recipe.
Terms
- TypeSafeClassifier
- A LangChain Runnable that submits state alongside defined Choice, Score, or Noul queries to Jev, returning structured results rather than text generation.
- ModelRouterMiddleware
- An experimental middleware hook where Jev analyzes the latest user input to select which chat model processes the turn.
- AutoModeMiddleware
- An experimental wrap_tool_call hook where Jev evaluates tool call safety, returning an error ToolMessage when an action exceeds risk thresholds.
- Runnable
- LangChain's standard unit of composition that can be executed, batched, or streamed across agent pipelines.