LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Configuration
  • 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

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

createCompletionCallbackMiddleware

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.

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

Parameters

NameTypeDescription
options*CompletionCallbackOptions

Configuration options.

Example

Copy
import { createCompletionCallbackMiddleware } from "deepagents";

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

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