LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsmiddlewarecreateCompletionCallbackMiddleware
Function●Since v1.9

createCompletionCallbackMiddleware

Copy
createCompletionCallbackMiddleware(
  options: CompletionCallbackOptions
): AgentMiddleware<ZodObject<__type, strip>, undefined, unknown, readonly ClientTool 
View source on GitHub
|
ServerTool
[
]
>

Parameters

NameTypeDescription
options*CompletionCallbackOptions

Example

Create a completion callback middleware for async subagents.

Experimental — this middleware is experimental and may change.

This middleware is added to a subagent's middleware stack. On success or model-call error, it sends a notification to the configured callback thread by calling runs.create().

The callback destination is configured with callbackGraphId and optional url and headers. The target thread is read from callbackThreadId in the subagent state.

If callbackThreadId is not present in state, the middleware does nothing.

Configuration options.

Copy
import { createCompletionCallbackMiddleware } from "deepagents";

const notifier = createCompletionCallbackMiddleware({
  callbackGraphId: "supervisor",
});

const agent = createDeepAgent({
  model: "claude-sonnet-4-5-20250929",
  middleware: [notifier],
});