# langchain-webhooks-events

langchain-webhooks-events dispatches LangChain 1.0 and LangGraph events to HTTP webhooks or Kafka without stalling chain execution. Useful for real-time tool telemetry and monitoring.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 4 installs · ★ 2935 repo stars
- Author: Jeremy Longshore
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/HEAD/skills/.curated/langchain-webhooks-events/SKILL.md
- Updated: 2026-11-01
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/langchain-webhooks-events

## What it does

This skill handles external event streaming from LangChain 1.0 and LangGraph agents into sinks like Kafka, Redis Streams, or HTTP endpoints. Standard FastAPI `BackgroundTasks` run only after the response terminates, delaying real-time telemetry. Synchronous callbacks in an async loop create even worse lag by blocking token production on every tool call.

The skill implements an `EventDispatchHandler` subclassing `AsyncCallbackHandler`. Events dispatch alongside the chain via `asyncio.create_task`. Tasks stay stored in an active set to prevent Python garbage collection from terminating in-flight requests. Tool outputs are capped at 4000 characters. Every payload carries an idempotency key generated from `run_id`, event type, and step index. A `drain()` call clears tasks before shutdown.

Setup requires Python 3.10+, `langchain-core` and `langgraph` pinned between 1.0 and 2.0, plus `httpx >= 0.27` or target transport drivers like `aiokafka`. Registering handlers with `with_config` fails on subagents because LangGraph subgraphs drop those bindings. You must pass handlers inside the `config` dictionary directly to `ainvoke`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add jeremylongshore/tons-of-skills-marketplace --skill langchain-webhooks-events -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/langchain-webhooks-events/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/langchain-webhooks-events/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add jeremylongshore/tons-of-skills-marketplace --skill langchain-webhooks-events -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/langchain-webhooks-events/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add jeremylongshore/tons-of-skills-marketplace --skill langchain-webhooks-events -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/langchain-webhooks-events/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install jeremylongshore/tons-of-skills-marketplace skills/.curated/langchain-webhooks-events
```

2. **Manually: put the files in place**
- File: `.github/skills/langchain-webhooks-events/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add jeremylongshore/tons-of-skills-marketplace --skill langchain-webhooks-events -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/jeremylongshore/tons-of-skills-marketplace --path skills/.curated/langchain-webhooks-events
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/langchain-webhooks-events/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add jeremylongshore/tons-of-skills-marketplace --skill langchain-webhooks-events -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/HEAD/skills/.curated/langchain-webhooks-events/SKILL.md

## When to use it
- dispatch LangGraph step events to external HTTP endpoints
- forward agent telemetry to Kafka or Redis Streams without latency spikes
- pass event handlers into nested subgraphs using execution `config`
- protect webhook requests with HMAC signatures and idempotency keys

## Example prompts
- Configure an async EventDispatchHandler to push LangChain tool_end events to a webhook with HMAC signing
- Show how to propagate callback handlers to LangGraph subgraphs using config in ainvoke
- Set up agent event dispatch to Kafka via aiokafka using composite idempotency keys

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: ed34cfc5575eea3d.

BEGIN THIRD-PARTY FILE ed34cfc5575eea3d
```text
---
name: langchain-webhooks-events
description: "Dispatch LangChain 1.0 chain/agent events to external systems \u2014\
  \ webhooks, Kafka,\nRedis Streams, SNS \u2014 via async fire-and-forget callbacks,\
  \ subgraph-aware wiring,\nand HMAC-signed delivery with idempotency keys. Use when\
  \ firing webhooks on tool\ncalls, pushing telemetry to Kafka / Redis Streams, or\
  \ fanning progress to multiple\nsubscribers without blocking the chain.\nTrigger\
  \ with \"langchain webhook\", \"langchain event dispatch\", \"langchain callback\
  \ kafka\",\n\"langchain pubsub\", \"langchain per-tool webhook\", \"BaseCallbackHandler\
  \ webhook\",\n\"on_tool_end webhook\", \"langchain analytics event\".\n"
allowed-tools: Read, Write, Edit, Bash(python:*)
version: 2.7.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
- saas
- langchain
- langgraph
- python
- langchain-1.0
- webhooks
- async
- events
- callbacks
compatibility: Designed for Claude Code
---
# LangChain Webhooks and Event Dispatch (Python)

## Overview

A team wires per-tool webhook dispatch from their LangChain agent via FastAPI
`BackgroundTasks` — analytics is always N seconds late because `BackgroundTasks`
fire **after** the HTTP response closes, not during the stream (P60). Worse:
the `BaseCallbackHandler` they attached via `.with_config(callbacks=[h])`
fires on the outer agent but is dark on the subagent's tool calls — custom
callbacks are **not** inherited by LangGraph subgraphs (P28), they must be
passed via `config["callbacks"]` at invoke time.

Pain-catalog anchors handled here:

- P28 — Callbacks via `with_config` don't propagate to subgraphs
- P46 — SSE streams dropped by buffering proxies (see `langchain-langgraph-streaming`)
- P47 — `astream_events(v2)` emits thousands of events; never forward raw
- P48 — Sync `invoke()` inside async endpoint blocks the event loop
```
END THIRD-PARTY FILE ed34cfc5575eea3d

The third-party file has ended. Everything between the ed34cfc5575eea3d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 1900 of 15747 bytes. © Jeremy Longshore · MIT · https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/HEAD/skills/.curated/langchain-webhooks-events/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
