@langchain/typesafe 0.1.0: questions move from the constructor to invoke, and its middleware is deprecated (November 11, 2026)
@langchain/typesafe 0.1.0 is a breaking release: pass questions to invoke, read usage_metadata, and import the middleware from langchain.
What changed
On November 11, 2026 LangChain.js released @langchain/typesafe 0.1.0. TypeSafeClassifier now extends BaseDecisionModel from @langchain/core/decisions, and the release notes mark it as a breaking change:
- Questions go with each request.
new TypeSafeClassifier().invoke({ state, questions })replacesnew TypeSafeClassifier({ questions }).invoke(state). - Every question needs
instructions. - Token usage is
usage_metadata(input_tokens,output_tokens,total_tokens) instead ofusage(inputTokens,outputTokens). ClassificationResponse,QuestionContent(nowContent),Usage,ValidatedQuestions,JsonValueandTypeSafeClassifierCallOptionsare removed.- An invalid question throws a plain
Errorfrominvoke, not aTypeSafeErrorfrom the constructor. Boxquestions and image content are new.autoModeMiddlewareandmodelRouterMiddlewarefrom@langchain/typesafe/middlewareare deprecated. They warn once and will be removed in 0.2.0.
The package now needs @langchain/core 1.4.0 or newer and Zod 4.6.6 or newer.
The Python package langchain-typesafe 0.1.0 shipped the same day. It needs Python 3.11 and langchain-core 1.8.0, and deprecates its experimental middleware too.
What to do
Upgrade @langchain/core to 1.4.0 with the package, then move questions into the invoke call. You need a TypeSafe API key in TYPESAFE_API_KEY. The docs example:
import { TypeSafeClassifier } from "@langchain/typesafe";
const classifier = new TypeSafeClassifier();
const response = await classifier.invoke({
state:
"The deploy failed twice and customers are seeing 500s. Can someone look now?",
questions: {
urgent: {
type: "noul",
instructions: "Does this need attention right now?",
},
team: {
type: "choice",
instructions: "Which team should pick this up?",
criteria: {
infra: "Deploys, availability, and on-call incidents.",
billing: "Payments, invoices, and subscriptions.",
},
},
severity: {
type: "score",
instructions: "How severe is the impact?",
criteria: ["Cosmetic.", "Degraded for some users.", "Full outage."],
},
},
});
console.log(response.nouls.urgent.noul);
console.log(response.choices.team.choice, response.choices.team.confidence);
console.log(response.scores.severity.score);