CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-langchain

TypeScript framework for building LLM-powered applications with agents, tools, middleware, and model interoperability

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

glossary.mddocs/

Glossary

Comprehensive index of LangChain concepts, APIs, and types for quick lookups.

Need task-based examples? See the Task Index for direct "I want to..." → code mappings.

Core Concepts

Agent

A ReAct (Reasoning + Acting) agent that combines language models with tools to iteratively work towards solutions. Created with createAgent().

See: Agent Guide | Agent API

Tool

A function that agents can call to take actions. Created with tool() or by extending StructuredTool.

See: Tool Guide | Tool API

Middleware

Composable components that extend agent behavior with cross-cutting concerns like logging, retries, or human-in-the-loop.

See: Middleware Guide | Middleware Overview

Structured Output

Type-safe, validated responses from agents using Zod schemas or JSON schemas.

See: Structured Output Guide | API Reference

State

Agent state that persists across invocations when using a checkpointer. Defined with stateSchema.

See: Agent Guide - Custom State

Context

Read-only data provided per invocation that is not persisted. Defined with contextSchema.

See: Agent Guide - Context

Checkpointer

Storage mechanism for persisting agent state across invocations. Enables conversation memory.

See: Agent Guide - Persistence

API Functions

createAgent()

Creates a production-ready ReAct agent with configuration for models, tools, prompts, state, and middleware.

Signature: function createAgent<TConfig>(params: CreateAgentParams): ReactAgent<TConfig>

See: Agent API | Quick Reference

tool()

Creates a structured tool from a function and Zod schema.

Signature: function tool<T>(func: (input: T) => any, fields: { name, description, schema }): StructuredTool<T>

See: Tool API | Quick Reference

initChatModel()

Initializes a chat model from any of 18+ supported providers using a universal interface.

Signature: function initChatModel(model?: string | ChatModel, fields?: InitChatModelFields): ChatModel

See: Model API | Quick Reference

createMiddleware()

Creates custom middleware with lifecycle hooks and state/context schemas.

Signature: function createMiddleware<TSchema, TContextSchema, TTools>(config: MiddlewareConfig): AgentMiddleware

See: Middleware Overview | Custom Middleware Guide

toolStrategy()

Creates a tool-based structured output strategy.

Signature: function toolStrategy<T>(schema: ZodType<T>, options?: ToolStrategyOptions): ToolStrategy<T>

See: Structured Output API

providerStrategy()

Creates a provider-native structured output strategy.

Signature: function providerStrategy<T>(schema: ZodType<T>): ProviderStrategy<T>

See: Structured Output API

filterMessages()

Filters message arrays based on types or custom criteria.

See: Message API

trimMessages()

Trims message arrays to fit within token limits.

See: Message API

Classes

ReactAgent

Agent instance returned by createAgent() with methods for execution.

Methods:

  • invoke() - Synchronous execution
  • stream() - Streaming execution
  • streamEvents() - Event streaming
  • batch() - Batch processing

See: Agent API - ReactAgent Class

Tool

Base class for creating tools with string input.

See: Tool API - Base Tool Class

DynamicTool

Dynamically created tool with string input.

See: Tool API - DynamicTool Class

StructuredTool

Tool with structured input schema (Zod).

See: Tool API - StructuredTool Class

DynamicStructuredTool

Dynamically created structured tool.

See: Tool API - DynamicStructuredTool Class

HumanMessage

Message class for user/human messages.

See: Message API

AIMessage

Message class for AI assistant responses.

See: Message API

SystemMessage

Message class for system instructions.

See: Message API

ToolMessage

Message class for tool execution results.

See: Message API

InMemoryStore

In-memory key-value store for agent data.

See: Storage API

ToolStrategy

Strategy class for tool-based structured outputs.

See: Structured Output API

ProviderStrategy

Strategy class for provider-native structured outputs.

See: Structured Output API

Document

Document container for text processing.

See: Document API

Types

CreateAgentParams

Configuration object for createAgent().

See: Agent API | Quick Reference

UserInput

Input type for agent invocation with messages and state.

See: Agent API - Input Types

State

Agent state returned from invoke/stream with messages and custom state.

See: Agent API - State Types

InvokeConfiguration

Configuration for agent invocation including context and thread_id.

See: Agent API - Configuration Types

StreamConfiguration

Configuration for streaming with streamMode option.

See: Agent API - Configuration Types

ToolCall

Information about a tool call made by the model.

See: Agent API - Tool Types | Tool API

ToolResult

Result from tool execution.

See: Agent API - Tool Types

ToolConfig

Configuration passed to tools during execution.

See: Tool API

ResponseFormat

Union type for structured output formats (Zod, JSON schema, strategies).

See: Structured Output API - Response Format Types

AgentMiddleware

Middleware interface with hooks and schemas.

See: Middleware Overview - Base Interface

MiddlewareConfig

Configuration for creating custom middleware.

See: Middleware Overview - Creating Custom Middleware

Runtime

Runtime context available to middleware hooks.

See: Agent API - Runtime Types | Middleware Overview

Type Inference

InferAgentState

Extracts full merged state type from agent (includes built-in state).

See: Type Inference - Agent Type Inference | Agent API

InferAgentResponse

Extracts structured response type from agent.

See: Type Inference - Agent Type Inference

InferAgentContext

Extracts full merged context type from agent.

See: Type Inference - Agent Type Inference

InferAgentTools

Extracts tools array type from agent.

See: Type Inference - Agent Type Inference

InferAgentMiddleware

Extracts middleware array type from agent.

See: Type Inference - Agent Type Inference

InferMiddlewareState

Extracts state type from single middleware.

See: Type Inference - Middleware Type Inference

InferMiddlewareStates

Merges states from middleware array.

See: Type Inference - Middleware Type Inference

InferMiddlewareContext

Extracts context type from single middleware.

See: Type Inference - Middleware Type Inference

InferMiddlewareContexts

Merges contexts from middleware array.

See: Type Inference - Middleware Type Inference

InferMiddlewareTools

Extracts tools from middleware array.

See: Type Inference - Tool Type Inference

InferSchemaInput

Infers input type from Zod schema or object.

See: Type Inference - Schema Type Inference

ToolsToMessageToolSet

Converts tools array to mapped type by name.

See: Type Inference - Tool Type Inference

Error Classes

MultipleToolsBoundError

Thrown when attempting to bind tools/structured output to a model that already has tools bound.

See: Agent API - Error Classes | Error Handling Guide

MultipleStructuredOutputsError

Thrown when multiple structured outputs are returned but only one was expected.

See: Agent API - Error Classes

StructuredOutputParsingError

Thrown when structured output parsing fails.

See: Agent API - Error Classes | Structured Output API

ToolInvocationError

Thrown when tool execution fails.

See: Agent API - Error Classes

ToolCallLimitExceededError

Thrown when tool call limit is exceeded.

See: Built-in Middleware - Tool Call Limit

PIIDetectionError

Thrown when PII detection fails.

See: Built-in Middleware - PII Detection

Built-in Middleware

humanInTheLoopMiddleware

Pauses agent execution for human review and approval.

See: Human-in-the-Loop Guide | Built-in Catalog

summarizationMiddleware

Automatically summarizes and compresses message history.

See: Built-in Catalog

piiMiddleware

Detects and handles personally identifiable information.

See: Built-in Catalog

piiRedactionMiddleware

Simple PII redaction without detection configuration.

See: Built-in Catalog

dynamicSystemPromptMiddleware

Dynamically updates system prompts based on state/context.

See: Built-in Catalog

llmToolSelectorMiddleware

Uses an LLM to intelligently select tools based on queries.

See: Built-in Catalog

contextEditingMiddleware

Edits or clears context and messages during execution.

See: Built-in Catalog

toolCallLimitMiddleware

Limits the number of tool calls per invocation.

See: Built-in Catalog

modelCallLimitMiddleware

Limits the number of model invocations.

See: Built-in Catalog

todoListMiddleware

Adds todo list management capabilities to agents.

See: Built-in Catalog

modelRetryMiddleware

Retries failed model calls with configurable backoff.

See: Built-in Catalog

modelFallbackMiddleware

Automatically falls back to alternative models on failure.

See: Built-in Catalog

toolRetryMiddleware

Retries failed tool calls with configurable backoff.

See: Built-in Catalog

toolEmulatorMiddleware

Emulates tool execution for testing without calling real tools.

See: Built-in Catalog

openAIModerationMiddleware

Uses OpenAI's moderation API to check for policy violations.

See: Built-in Catalog

anthropicPromptCachingMiddleware

Enables Anthropic's prompt caching for improved performance.

See: Built-in Catalog

Model Providers

Quick lookup for supported model provider formats:

  • OpenAI: openai:gpt-4o, openai:gpt-4o-mini
  • Anthropic: anthropic:claude-3-5-sonnet-20241022
  • Google: google:gemini-1.5-pro
  • Ollama: ollama:llama3.1
  • Cohere: cohere:command-r-plus
  • Groq: groq:mixtral-8x7b-32768
  • Together: together:meta-llama/Llama-3-70b-chat-hf

See: Model Guide | Quick Reference - Model Providers

Common Patterns

Agent with Tools

Creating an agent with tool-calling capabilities.

See: Quick Reference - Agent with Tools | Agent Guide

Agent with Structured Output

Getting type-safe structured responses from agents.

See: Quick Reference - Agent with Structured Output | Structured Output Guide

Agent with Custom State

Adding custom state that persists across invocations.

See: Quick Reference - Agent with Custom State | Agent Guide

Agent with Persistence

Using checkpointers for conversation memory.

See: Quick Reference - Agent with Persistence | Agent Guide

Streaming Responses

Streaming agent responses in real-time.

See: Quick Reference - Streaming Responses | Agent Guide

Batch Processing

Processing multiple inputs in parallel.

See: Agent Guide - Batch Processing

Human-in-the-Loop

Adding human review and approval to agent workflows.

See: Human-in-the-Loop Guide | Agent Guide

Environment Variables

  • OPENAI_API_KEY - OpenAI API key
  • ANTHROPIC_API_KEY - Anthropic API key
  • GOOGLE_APPLICATION_CREDENTIALS - Google credentials path
  • COHERE_API_KEY - Cohere API key
  • GROQ_API_KEY - Groq API key
  • MISTRAL_API_KEY - Mistral AI API key
  • TOGETHER_API_KEY - Together AI API key
  • FIREWORKS_API_KEY - Fireworks AI API key

See: Quick Reference - Environment Variables

Navigation

By Topic

Quick Access

Search Tips

  1. By name: Use Ctrl/Cmd+F on this page to find specific APIs or concepts
  2. By category: Navigate to specific sections above
  3. By use case: Check the "Common Patterns" section
  4. By API: See Quick Reference or API Reference Index
  5. By type: See Type Inference Guide

docs

glossary.md

index.md

quick-reference.md

task-index.md

tile.json