扛得住后续 Claude 调用的 Claude Webhook。
Anthropic 通过 Webhook 把智能体的结果发给你。你想把它再喂给一次 Claude 调用,做格式化、打分或路由。这又是 30 秒。AnyHook 帮你补上这段时间差。
时限问题
Claude Managed Agents 的 Webhook 最多进行三次投递尝试,退避间隔在 5 到 120 秒之间。最后一次失败后,事件就会被丢弃,不会有任何信号告诉你它丢了。
拿到智能体结果后,最自然的做法就是把它喂给下一次 Claude 调用:总结执行轨迹、给输出分类、决定是否升级处理。第二次调用又要 20–40 秒。你还没做什么有用的事,就已经超出 SLA 了。
3
Anthropic 丢弃事件前的投递尝试次数
30 秒+
用于总结/分类的第二次 Claude 调用
5–120 秒
Anthropic 三次尝试之间的退避间隔
0
处理程序需要改动的代码
只改一个 URL,Claude 流水线保持不变
AnyHook 约 1 秒应答 Anthropic,再把事件投递到你的端点,附带原始的 Anthropic-Signature 和重新签名的 AnyHook-Signature。
// In your Anthropic dashboard, set the webhook URL to:
// https://in.anyhook.net/{user-slug}/{app-slug}
//
// Your handler is now free to run a follow-up Claude call.
import Anthropic from "@anthropic-ai/sdk";
import { verifyWebhook } from "anyhook-verify";
const anthropic = new Anthropic();
export async function POST(req: Request) {
if (!(await verifyWebhook(req, process.env.ANYHOOK_SIGNING_SECRET!))) {
return new Response("invalid", { status: 401 });
}
const { agent_result } = await req.json();
// Free to take 30+ seconds. Anthropic already saw 200.
const summary = await anthropic.messages.create({
model: "claude-opus-4-7",
max_tokens: 800,
messages: [{ role: "user", content: `Summarise: ${agent_result}` }],
});
await persistSummary(summary);
return new Response("ok", { status: 200 });
}团队常问的问题
- AnyHook 怎么验证 Anthropic 的签名?
- 在边缘节点不验证:Anthropic 的方案不在 AnyHook 验证的方案之列(列表见文档)。原始签名请求头会原样转发,所以你的服务器可以在首次投递时继续自己验证;每次投递都带有的 AnyHook-Signature 则证明它经过了 AnyHook。
- Claude Managed Agent 的 Webhook 会计入我的 Anthropic 限额吗?
- Anthropic 把每个事件向 AnyHook 投递一次(如果 AnyHook 自己没能应答,则按 Anthropic 的常规重试策略处理)。之后,发往你端点的所有下游重试都由 AnyHook 负责。你的处理程序慢,不会给 Anthropic 带来压力。
- 事后还能查看原始的 Claude 请求体吗?
- 可以。每个事件都加密保存,并按套餐分别在 3、30 或 90 天内可以重放;之后 Pro 和 Scale 还会把只读归档保留 1 或 7 年。你可以查看原始请求体,或把它重放到你的端点。
只改一个 URL。Anthropic 处理程序不用动。
Free 套餐包含每月 10,000 个事件。无需 SDK:把 Anthropic 指向你的 AnyHook 接收 URL。