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. Not for different error messages.
TL;DR: The JS v1 agent factory is createAgent imported from langchain. Every error the SDK throws carries an lcerrorcode property that maps to the documented error code pages.
The error
text
lc_error_codeThe fix
- 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.
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: LangChain JS agents.
- You want the fastest verified fix before digging through logs.
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
- Mentions 5.5 in the original; behavior may differ on much older or newer releases.
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: LangChain JS agents.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Compatibility
- Mentions 5.5 in the original; behavior may differ on much older or newer releases.
Also seen as
lc_error_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 3 · 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>