LangChain · agent webhook handlers
LangChain agents that run inside webhooks.
Stripe wants a 200 in 10 seconds. Your LangChain agent needs 60 to chain three tool calls. AnyHook returns 200 immediately and lets the agent finish.
The timing problem
A LangChain agent with two or three tool calls — vector search, a DB query, a model call — routinely takes 30 to 90 seconds. Most webhook senders give you 5 to 30. The maths doesn't work.
The usual workaround is to push the work onto a queue you maintain yourself: Redis, SQS, Inngest, Trigger.dev, Vercel cron, BullMQ. Every one of those means a new dependency, a new dashboard, a new dead-letter policy. AnyHook is the queue you don't have to operate.
Run the agent. AnyHook holds the line.
Your existing Next.js or Fastify route stays the same. Just verify AnyHook-Signature instead of the sender's, and run the agent without the timeout pressure.
import { verifyWebhook } from "@anyhook/verify";
import { AgentExecutor } from "langchain/agents";
export async function POST(req: Request) {
const ok = await verifyWebhook(req, process.env.ANYHOOK_SIGNING_SECRET!);
if (!ok) return new Response("invalid", { status: 401 });
const event = await req.json();
// Stripe / GitHub / Shopify already saw a 200 from AnyHook.
// You have up to 5 minutes (Scale plan) to finish.
const result = await agentExecutor.invoke({
input: `Process this event: ${JSON.stringify(event.payload)}`,
});
await persistToDb(result);
await maybeNotify(result);
return new Response("ok", { status: 200 });
}Questions teams ask
- Does AnyHook work with LangGraph too?
- Yes — see /for/langgraph-webhooks. LangGraph's stateful workflows have the same shape: a webhook callback that needs to trigger further model calls.
- What if my agent fails halfway through?
- Return a 5xx from your handler. AnyHook treats that as retriable and applies the configured backoff schedule. The original event is preserved encrypted at rest so you can replay it from the dashboard once you've fixed the bug.
- How does this compare to Inngest or Trigger.dev?
- Those are durable execution platforms — you write your workflow in their DSL and they execute it. AnyHook is upstream: it just turns synchronous webhooks into reliable async deliveries. You can still use Inngest for the workflow if you want; AnyHook just makes sure the trigger event reaches Inngest reliably.
Change one URL. Keep your LangChain handler.
Free tier covers 3K events / month. No SDK, no code changes — just point LangChain at your AnyHook inbound URL.