LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coreerrorsModelAbortError
Class●Since v1.1

ModelAbortError

Error class representing an aborted model operation in LangChain.

This error is thrown when a model operation (such as invocation, streaming, or batching) is cancelled before it completes, commonly due to a user-initiated abort signal (e.g., via an AbortController) or an upstream cancellation event.

The ModelAbortError provides access to any partial output the model may have produced before the operation was interrupted, which can be useful for resuming work, debugging, or presenting incomplete results to users.

Copy
class ModelAbortError

Bases

LangChainError<this>
  • The partialOutput field includes message content that was generated prior to the abort, such as a partial AIMessageChunk.
  • This error extends the LangChainError base class with the marker "model-abort".

Example

Copy
try {
  await model.invoke(input, { signal: abortController.signal });
} catch (err) {
  if (ModelAbortError.isInstance(err)) {
    // Handle user cancellation, check err.partialOutput if needed
  } else {
    throw err;
  }
}

Constructors

constructor
constructor

Properties

property
cause: unknown

The underlying error that caused this ContextOverflowError, if any.

This property is optionally set when wrapping a lower-level error using ContextOverflowError.fromError. It allows error handlers to access or inspect the original error that led to the context overflow.

property
message: string
property
name: "ModelAbortError"
property
partialOutput: AIMessageChunk<MessageStructure<MessageToolSet>>

The partial message output that was produced before the operation was aborted. This is typically an AIMessageChunk, or could be undefined if no output was available.

property
stack: string
property
isInstance: IsInstanceFn
property
stackTraceLimit: number

Methods

method
captureStackTrace
method
prepareStackTrace

Inherited fromLangChainError

Properties

Pcause: Error
—

The underlying error that caused this ContextOverflowError, if any.

Pmessage: StoredMessagePname: stringPstackPisInstance: IsInstanceFnPstackTraceLimit

Methods

McaptureStackTraceMprepareStackTrace
View source on GitHub