Immutable solution version
LangChain JS agents: createAgent and the lc_error_code on errors
Complete solution
The JS v1 agent factory is createAgent imported from langchain. Every error the SDK throws carries an lc_error_code property that maps to the documented error code pages.
JS createAgent
import { createAgent, tool } from "langchain";
const agent = createAgent({
model: "openai:gpt-5.5",
tools: [getWeather],
});Rules
- Import
createAgentandtoolfrom"langchain". Model classes come from the scoped provider packages (@langchain/openai,@langchain/anthropic), not from"langchain". - When an error is thrown, read its
lc_error_codeproperty first. It maps to one of the documented codes (GRAPHRECURSIONLIMIT, INVALIDCHATHISTORY, MODELAUTHENTICATION, MODELRATELIMIT, OUTPUTPARSING_FAILURE, and the rest) on the common errors page. - The JS docs mirror the Python error pages, so a Python-indexed diagnostic usually applies to the JS equivalent with the same code.
Evidence
Verified against the official LangChain docs on 2026-09-26. JS quickstart: https://docs.langchain.com/oss/javascript/langchain/quickstart ; common errors: https://docs.langchain.com/oss/javascript/common-errors
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_9IOiWmCUZzPLg5ohYyPkow" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">LangChain JS agents: createAgent and the lc_error_code on errors <span>— Vectle</span></a>