langchainjs
AGENTS.md18k starsChanged 3 months agoMITView on GitHub
This document provides guidance for AI coding agents working with the LangChain.js codebase. When Corridor's analyzePlan tool is available, create a plan and use the tool to analyze it before generating or modifying code. Apply the resulting security guidance before writing code. LangChain.js is a TypeScript framework for building LLM-powered applications. It provides standard interfaces for agents, models, embeddings, vector stores, and more, enabling developers to chain together interoperable components and third-party integrations. This is a monorepo managed with pnpm…
- Reads credentials
- Installs packages
Trending
More talk lately.about the whole repository
Who's talking about langchain-ai/langchainjs
- langchain-ai/langchain-google“google-genai [feature]: Context Caching”GitHub · Jun 21, 2024 · 21 reactions
- n8n-io/n8n“feat(Openrouter Node): Support setting chat model options as JSON”GitHub · Nov 12, 2025 · 16 reactions
- langchain-ai/langchain-google“Vertex AI [Feature]: Grounding with Google Search and Vertex AI Search”GitHub · Apr 11, 2024 · 7 reactions
- langchain-ai/agentevals“`agentevals` fails with _missing _convertMessagesToOpenAIParams export in @langchain/openai”GitHub · Nov 18, 2025 · 6 reactions
- aegra/aegra“[FEATURE] Add Protocol v2 support (/commands + /stream/events)”GitHub · Jun 8, 2026 · 5 reactions
The biggest 5 of 53 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 53
Talked about on GitHub and Bluesky (53 times).
On GitHub · 50
- Jun 21, 2024google-genai [feature]: Context Caching — langchain-ai/langchain-google21 reactions · 15 comments
- Nov 12, 2025feat(Openrouter Node): Support setting chat model options as JSON — n8n-io/n8n16 reactions · 9 comments
- Apr 11, 2024Vertex AI [Feature]: Grounding with Google Search and Vertex AI Search — langchain-ai/langchain-google7 reactions · 1 comment
- Nov 18, 2025`agentevals` fails with _missing _convertMessagesToOpenAIParams export in @langchain/openai — langchain-ai/agentevals6 reactions · 6 comments
- Jun 8, 2026[FEATURE] Add Protocol v2 support (/commands + /stream/events) — aegra/aegra5 reactions · 1 comment
45 more on GitHub
- Jul 11, 2025Add instrumentation for `langchain` — getsentry/sentry-javascript5 reactions · 1 comment
- Feb 22, 2025vectorstores/typeorm.ts - TypeORMVectorStore.addDocuments() does NOT support `options?: { ids?: string[] }` param — langchain-ai/langchainjs-community5 reactions · 1 comment
- Jan 26, 2024Start here: Welcome to LangChain! — langchain-ai/langchain5 reactions · 2 comments
- Jun 27, 2025Authorization Standards using OAuth 2.1/2.0 Client — langchain-ai/langchain-mcp-adapters4 reactions · 5 comments
- Jun 24, 2025feat: increase eval compatibility with more models — langfuse/langfuse4 reactions · 4 comments
- Jun 3, 2025@langchain/community | @langchain/langgraph Bug: BedrockChat tool duplication — langchain-ai/langchainjs-community4 reactions · 9 comments
- Oct 27, 2023Import map defined in a Jupyter notebook? — denoland/deno4 reactions · 3 comments
- Oct 17, 2023Proposal: Langchain Integration — agi-inc/agent-protocol4 reactions · 5 comments
- Nov 2, 2026chore(deps): bump the ai-and-llm group across 1 directory with 11 updates — DataDog/dd-trace-js3 reactions · 4 comments
- Oct 23, 2026chore(deps): bump the ai-and-llm group across 1 directory with 8 updates — DataDog/dd-trace-js3 reactions · 4 comments
- Oct 19, 2026chore(deps): bump the ai-and-llm group across 1 directory with 11 updates — DataDog/dd-trace-js3 reactions · 4 comments
- Oct 12, 2026chore(deps): bump the ai-and-llm group across 1 directory with 15 updates — DataDog/dd-trace-js3 reactions · 4 comments
- May 27, 2026chore(deps): bump the npm_and_yarn group across 4 directories with 9 updates — GoldenEagle-23/agentkit3 reactions · 1 comment
- Dec 7, 2025Vertex AI support return multi-modal part in Tool Massage — langchain-ai/langchain-google3 reactions · 3 comments
- Nov 26, 2025bug: Proxyagent is not used to add Google Gemini — langfuse/langfuse3 reactions · 6 comments
- Sep 20, 2025@ai-sdk/langchain's support of LangChain v1 — vercel/ai3 reactions · 2 comments
- Jul 26, 2025Type instantiation is excessively deep and possibly infinite with Zod 3.25.68+ — langchain-ai/langgraphjs3 reactions · 5 comments
- Oct 30, 2026chore(deps): bump the ai-and-llm group across 1 directory with 9 updates — DataDog/dd-trace-js2 reactions · 4 comments
- Oct 26, 2026chore(deps): bump the ai-and-llm group across 1 directory with 17 updates — DataDog/dd-trace-js2 reactions · 4 comments
- Oct 9, 2026chore(deps): bump the ai-and-llm group across 1 directory with 10 updates — DataDog/dd-trace-js2 reactions · 5 comments
- Oct 5, 2026chore(deps): bump the ai-and-llm group across 1 directory with 15 updates — DataDog/dd-trace-js2 reactions · 5 comments
- Sep 25, 2026chore(deps): bump the ai-and-llm group across 1 directory with 6 updates — DataDog/dd-trace-js2 reactions · 3 comments
- Sep 24, 2026chore(deps): bump @langchain/core from 1.2.11 to 1.2.12 in /packages/dd-trace/test/plugins/versions in the ai-and-llm group across 1 directory — DataDog/dd-trace-js2 reactions · 3 comments
- Sep 18, 2026chore(deps): bump the npm-production group with 24 updates — ComposioHQ/composio2 reactions · 5 comments
- Sep 16, 2026chore(deps): bump the ai-and-llm group across 1 directory with 7 updates — DataDog/dd-trace-js2 reactions · 4 comments
- Sep 14, 2026chore(deps): bump the ai-and-llm group across 1 directory with 17 updates — DataDog/dd-trace-js2 reactions · 3 comments
- Aug 31, 2026chore(deps): bump the ai-and-llm group across 1 directory with 17 updates — DataDog/dd-trace-js2 reactions · 3 comments
- Aug 18, 2026chore(deps): bump the ai-and-llm group across 1 directory with 10 updates — DataDog/dd-trace-js2 reactions · 3 comments
- Jul 28, 2026chore(deps): bump the ai-and-llm group across 1 directory with 6 updates — DataDog/dd-trace-js2 reactions · 3 comments
- Jul 27, 2026[Feature]: Make Bedrock stream idle timeout configurable — langchain-ai/openwiki2 reactions · 1 comment
- Jun 24, 2026Bump the npm_and_yarn group across 2 directories with 5 updates — CaffeeLake/supavec2 reactions
- May 27, 2026chore(deps): bump uuid and @langchain/core in /integrations/langchain — Dustin4444/mnemopay-sdk2 reactions · 3 comments
- May 25, 2026chore(deps): bump langsmith and @langchain/core — Dustin4444/mnemopay-sdk2 reactions · 3 comments
- May 25, 2026chore(deps): bump uuid and @langchain/core — Dustin4444/mnemopay-sdk2 reactions · 3 comments
- May 17, 2026chore(deps): bump the npm_and_yarn group across 4 directories with 16 updates — billlzzz10/adk-samples2 reactions · 5 comments
- Apr 13, 2026Bump @langchain/core from 0.3.80 to 1.1.39 — thanhan92-f1/hitechclaw-ai2 reactions · 1 comment
- Apr 13, 2026build(deps): bump @langchain/core from 0.3.80 to 1.1.39 — thanhan92-f1/hitechclaw2 reactions
- Apr 13, 2026Bump the npm_and_yarn group across 1 directory with 6 updates — GlacierEQ/stagehand2 reactions · 2 comments
- Apr 10, 2026Bump the npm_and_yarn group across 1 directory with 7 updates — GlacierEQ/stagehand2 reactions · 2 comments
- Apr 8, 2026chore(deps): bump the npm_and_yarn group across 5 directories with 7 updates — patrik-fredon/lobe-chat2 reactions · 1 comment
- Apr 3, 2026build(deps): bump the npm_and_yarn group across 4 directories with 8 updates — abrahem79/lobe-chat2 reactions · 3 comments
- Apr 3, 2026Bump the npm_and_yarn group across 8 directories with 15 updates — CaffeeLake/AugmentOS2 reactions · 1 comment
- Mar 26, 2026Bump the npm_and_yarn group across 8 directories with 16 updates — CaffeeLake/AugmentOS2 reactions · 1 comment
- Mar 26, 2026Bump the npm_and_yarn group across 8 directories with 16 updates — CaffeeLake/AugmentOS2 reactions · 1 comment
- Mar 19, 2026Bump the npm_and_yarn group across 8 directories with 17 updates — CaffeeLake/AugmentOS2 reactions · 1 comment
On Bluesky · 3
- Mar 7, 2026https://github.com/langchain-ai/langchainjs — @tom-doerr.bsky.social1 likes and repost
- Oct 16, 2025🔥 Hot Repo! 🔥 (100+ new stars) 📦 langchain-ai / langchainjs ⭐ 16,008 (+139) 🗒 TypeScript 🦜🔗 Build context-aware reasoning… — @github-trending-js.bsky.social1 likes and repost
- Oct 15, 2025📦 langchain-ai / langchainjs ⭐ 15,862 (+7) 🗒 TypeScript 🦜🔗 Build context-aware reasoning applications 🦜🔗 — @github-trending.bsky.social1 likes and repost
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
When Corridor's analyzePlan tool is available, create a plan and use the tool to analyze it before generating or modifying code.
- Very specific: line 69
All commands can be run from the project root using pnpm --filter <package> to target specific workspaces.
- Very specific: line 127
No explicit
any: - Use proper types (typescript/no-explicit-any: error) - Very specific: line 257
Use expectTypeOf from vitest for type assertions:
- Distinctive: line 334
Use the CLI tool to create new integration packages:
- Very specific: line 344
Before creating new classes, check if @langchain/core already provides what you need:
- Distinctive: line 355
All LLM-related components should support streaming when possible:
- Distinctive: line 369
Use the callback manager for tracing and observability:
- Distinctive: line 387
Use typed errors with proper error codes:
- Very specific: line 397
Add them as regular dependencies in standalone provider packages
- Very specific: line 398
Always use caret (^) for version ranges
- Distinctive: line 399
Ensure dependencies are MIT or permissively licensed
- Distinctive: line 403
Before submitting a PR:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md - AI Agent Guidelines for LangChain.js
This document provides guidance for AI coding agents working with the LangChain.js codebase.
<corridor>Corridor security analysis
When Corridor's analyzePlan tool is available, create a plan and use the tool to analyze it before generating or modifying code. Apply the resulting security guidance before writing code.
</corridor>Project Overview
LangChain.js is a TypeScript framework for building LLM-powered applications. It provides standard interfaces for agents, models, embeddings, vector stores, and more, enabling developers to chain together interoperable components and third-party integrations.
Supported Environments
- Node.js (ESM and CommonJS) - 20.x, 22.x, 24.x
- Cloudflare Workers
- Vercel / Next.js (Browser, Serverless and Edge functions)
- Supabase Edge Functions
- Browser
- Deno
- Bun
Repository Structure
This is a monorepo managed with pnpm workspaces (v10.14.0) and Turborepo.
Key Packages
| Package | Path | Description |
langchain | libs/langchain/ | Main LangChain package with agents, prompts, and orchestration |
@langchain/core | libs/langchain-core/ | Core abstractions and interfaces (base classes, runnables, etc.) |
@langchain/textsplitters | libs/langchain-textsplitters/ | Text splitting utilities |
@langchain/openai | libs/providers/langchain-openai/ | OpenAI integration |
@langchain/anthropic | libs/providers/langchain-anthropic/ | Anthropic integration |
| Other providers | libs/providers/langchain-*/ | First-party provider integrations |
Internal Packages
| Package | Path | Description |
@langchain/build | internal/build/ | Build utilities |
@langchain/tsconfig | internal/tsconfig/ | Shared TypeScript configuration |
@langchain/standard-tests | libs/langchain-standard-tests/ | Standard test suite for integrations |
Development Setup
Prerequisites
- Node.js v24.x (check with
node -v) - pnpm v10.14.0 (package manager)
Initial Setup
# Install dependencies from root
pnpm install
# Build the core package first (required before other packages)
pnpm --filter @langchain/core buildCommon Commands
All commands can be run from the project root using pnpm --filter <package> to target specific workspaces.
Package Filters
--filter langchain- the mainlangchainpackage--filter @langchain/core- the core package--filter @langchain/openai- OpenAI integration (and similarly for other providers)
Building
pnpm --filter langchain build
pnpm --filter @langchain/core buildLinting
pnpm lintFormatting
pnpm format # Fix formatting
pnpm format:check # Check onlyTesting
# Unit tests
pnpm --filter langchain test
pnpm --filter @langchain/core test
# Integration tests (requires API keys)
pnpm --filter langchain test:integration
# Single test file
pnpm --filter <package> test:single <path-to-test>Coding Standards
TypeScript Configuration
The project uses a shared TypeScript configuration from internal/tsconfig/base.json:
- Target: ES2022
- Module: ESNext with bundler resolution
- Strict mode enabled
- Source maps and declaration maps enabled
Lint Rules
Lint rules are defined in .oxlintrc.json. Key rules to follow:
- No
process.env- Except in test files (node/no-process-env: error) - No explicit
any- Use proper types (typescript/no-explicit-any: error) - Prefer template literals - Over string concatenation (
prefer-template: error) - File extensions required - In imports (
import/extensions: error)
Import Conventions
// Always include .js extension for local imports (ESM)
import { Something } from "./something.js";
// Use named exports, not default exports
export { MyClass, myFunction };Zod Schema Support
The codebase supports both Zod v3 and v4:
import { z } from "zod/v3";
import { z as z4 } from "zod/v4";File Naming Conventions
Source Files
- Regular modules:
my_module.ts(snake_case) - Index files:
index.ts - Type definitions:
types.ts
Test Files
- Unit tests:
*.test.ts- Tests that don't require external APIs - Integration tests:
*.int.test.ts- Tests that call external APIs - Type tests:
*.test-d.ts- TypeScript type checking tests - Standard tests:
*.standard.test.ts/*.standard.int.test.ts- Standard test suite
Tests should be placed in a tests/ folder alongside the module being tested.
Core Abstractions
Runnables
The Runnable interface (@langchain/core/runnables) is the foundation of LangChain. All major components extend Runnable:
import {
Runnable,
RunnableConfig,
RunnableLike,
} from "@langchain/core/runnables";Key methods:
invoke(input, config?)- Single invocationstream(input, config?)- Streaming invocationbatch(inputs, config?)- Batch invocation
Messages
Messages are in @langchain/core/messages:
import {
HumanMessage,
AIMessage,
SystemMessage,
ToolMessage,
BaseMessage,
} from "@langchain/core/messages";Tools
Tools extend StructuredTool from @langchain/core/tools:
import { StructuredTool, DynamicTool, tool } from "@langchain/core/tools";Chat Models
Chat models extend BaseChatModel from @langchain/core/language_models/chat_models:
import {
BaseChatModel,
BaseChatModelParams,
} from "@langchain/core/language_models/chat_models";Writing Tests
Unit Tests
import { test, expect, describe } from "vitest";
import { FakeChatModel } from "@langchain/core/utils/testing";
test("should do something", async () => {
const model = new FakeChatModel({});
const result = await model.invoke([["human", "Hello!"]]);
expect(result.content).toBe("Hello!");
});Integration Tests
Integration tests require actual API credentials:
import { describe, test, expect } from "vitest";
import { ChatOpenAI } from "../index.js";
import { HumanMessage } from "@langchain/core/messages";
test("Test ChatOpenAI Generate", async () => {
const chat = new ChatOpenAI({
model: "gpt-4o-mini",
maxTokens: 10,
});
const message = new HumanMessage("Hello!");
const result = await chat.invoke([message]);
expect(typeof result.content).toBe("string");
});Type Tests
Use expectTypeOf from vitest for type assertions:
import { expectTypeOf } from "vitest";
expectTypeOf(someFunction).returns.toMatchTypeOf<ExpectedType>();Standard Tests
For provider integrations, extend the standard test classes:
import { ChatModelUnitTests } from "@langchain/standard-tests";
class MyChatModelStandardUnitTests extends ChatModelUnitTests<
MyChatModelCallOptions,
AIMessageChunk
> {
constructor() {
super({
Cls: MyChatModel,
chatModelHasToolCalling: true,
chatModelHasStructuredOutput: true,
constructorArgs: {},
});
}
}Creating New Integrations
Provider Package Structure
New provider packages should follow this structure:
libs/providers/langchain-{provider}/
├── package.json
├── tsconfig.json
├── tsdown.config.ts
├── vitest.config.ts
├── turbo.json
├── README.md
├── LICENSE
└── src/
├── index.ts
├── chat_models/
│ ├── index.ts
│ └── tests/
│ ├── index.test.ts
│ ├── index.int.test.ts
│ ├── index.standard.test.ts
│ └── index.standard.int.test.ts
└── embeddings.ts (if applicable)Package.json Requirements
{
"name": "@langchain/provider-name",
"type": "module",
"engines": { "node": ">=20" },
"peerDependencies": {
"@langchain/core": "^1.0.0"
},
"devDependencies": {
"@langchain/core": "workspace:^",
"@langchain/standard-tests": "workspace:*",
"@langchain/tsconfig": "workspace:*"
}
}Scaffolding
Use the CLI tool to create new integration packages:
npx create-langchain-integrationBest Practices
1. Use Existing Abstractions
Before creating new classes, check if @langchain/core already provides what you need:
Runnableand its variantsStructuredToolfor toolsBaseChatModelfor chat modelsEmbeddingsfor embedding modelsBaseRetrieverfor retrieversVectorStorefor vector stores
2. Support Streaming
All LLM-related components should support streaming when possible:
async *_streamResponseChunks(
messages: BaseMessage[],
options: this["ParsedCallOptions"],
runManager?: CallbackManagerForLLMRun
): AsyncGenerator<ChatGenerationChunk> {
// Yield chunks as they arrive
}3. Handle Callbacks Properly
Use the callback manager for tracing and observability:
await runManager?.handleLLMNewToken(token);4. Environment Variables
Access environment variables using the utility:
import { getEnvironmentVariable } from "@langchain/core/utils/env";
const apiKey = getEnvironmentVariable("MY_API_KEY");5. Error Handling
Use typed errors with proper error codes:
throw new Error("Model authentication failed", {
cause: { lc_error_code: "MODEL_AUTHENTICATION" },
});6. Third-Party Dependencies
- Add them as regular
dependenciesin standalone provider packages - Always use caret (
^) for version ranges - Ensure dependencies are MIT or permissively licensed
Pull Request Checklist
Before submitting a PR:
- Run
pnpm lintand fix any issues - Run
pnpm formatto format code - Add/update unit tests (
*.test.ts) - Add/update integration tests if applicable (
*.int.test.ts) - Add/update type tests if changing public APIs (
*.test-d.ts) - Update documentation if changing public APIs
- Keep changes focused - one feature/fix per PR
- Ensure no circular dependencies (checked by
lint:dpdm)
Debugging Tips
Running Specific Tests
# Run a single test file
pnpm --filter @langchain/core test src/messages/tests/utils.test.ts
# Run tests matching a pattern
pnpm --filter @langchain/core test --grep "should handle"
# Watch mode
pnpm --filter @langchain/core test:watchBuilding in Watch Mode
pnpm watchChecking for Circular Dependencies
pnpm --filter @langchain/core lint:dpdmResources
- Documentation
- API Reference
- GitHub Issues
- LangChain Forum
- Contributing Guide
- Integration Guide
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

