# Inngest Agent Kit — Build AI Agents with Tools > Inngest Agent Kit gives typed multi-step agents with retry, state, tool use. Drops into Inngest jobs for durable, observable agent runs. ## Install Copy the content below into your project: ## Quick Use 1. `npm install @inngest/agent-kit inngest @anthropic-ai/sdk zod` 2. Use `createAgent({ ... })` to define agents and tools 3. Wrap in `inngest.createFunction({}, {}, async ({step}) => agent.run(...))` for durability --- ## Intro Inngest Agent Kit is the typed agent layer on top of Inngest's durable execution. Build agents with `createAgent()`, give them tools, run them inside `inngest.createFunction()` — automatic retry, state checkpoints, observability, and parallel sub-agent calls. Best for: production agents that need to survive crashes, retries, and timeouts. Works with: Inngest 3.x, TypeScript 5+. Setup time: 5 minutes. --- ### Define an agent ```typescript import { createAgent, anthropic } from "@inngest/agent-kit"; const researchAgent = createAgent({ name: "Researcher", description: "Searches the web and summarizes findings", model: anthropic({ model: "claude-3-5-sonnet-20241022" }), system: "You are a research assistant. Search aggressively, cite sources.", tools: [ { name: "web_search", description: "Search the web", parameters: z.object({ query: z.string() }), handler: async ({ query }) => { return await fetch(`https://api.tavily.com/search?q=${query}`) .then(r => r.json()); }, }, ], }); ``` ### Run it inside an Inngest function ```typescript inngest.createFunction( { id: "research" }, { event: "research.requested" }, async ({ event, step }) => { const { topic } = event.data; // Each agent step is a checkpoint — survives crashes const findings = await step.run("research", () => researchAgent.run(`Research ${topic}`)); return findings; }, ); ``` ### Network of agents ```typescript import { createNetwork } from "@inngest/agent-kit"; const network = createNetwork({ agents: [researchAgent, writerAgent, editorAgent], defaultModel: anthropic({ model: "claude-3-5-haiku-20241022" }), router: ({ network, callCount }) => { if (callCount === 0) return researchAgent; if (network.state.kv.get("draft") === undefined) return writerAgent; return editorAgent; }, }); const final = await network.run("Write a 500-word brief on agent frameworks"); ``` The router function decides which agent runs next, given the network state. Use it to build supervisor-worker patterns or sequential pipelines. --- ### FAQ **Q: Is Inngest free?** A: Yes — Inngest is open-source under Apache-2.0. The Agent Kit is also open-source. Inngest Cloud has a free tier (50K runs/mo); paid plans for higher concurrency and longer retention. **Q: Why use Agent Kit vs raw Inngest?** A: Raw Inngest functions are great for general background jobs. Agent Kit adds typed agent primitives — tools, system prompts, networks of agents — without re-rolling them yourself. Both can be used in the same project. **Q: Does it work with Anthropic and OpenAI?** A: Yes — Agent Kit ships adapters for `anthropic()`, `openai()`, `gemini()`, and any OpenAI-compatible endpoint (so you can plug in LiteLLM Proxy or Together). --- ## Source & Thanks > Built by [Inngest](https://github.com/inngest). Licensed under Apache-2.0. > > [inngest/agent-kit](https://github.com/inngest/agent-kit) — ⭐ Active --- ## 快速使用 1. `npm install @inngest/agent-kit inngest @anthropic-ai/sdk zod` 2. 用 `createAgent({ ... })` 定义 agent 和工具 3. 包进 `inngest.createFunction({}, {}, async ({step}) => agent.run(...))` 拿持久化 --- ## 简介 Inngest Agent Kit 是在 Inngest 持久执行之上的类型化 agent 层。用 `createAgent()` 建 agent、给它工具、放进 `inngest.createFunction()` 跑 —— 自动重试、状态 checkpoint、可观测、子 agent 并行调用。适合需要扛崩溃、重试、超时的生产 agent。需要 Inngest 3.x 和 TypeScript 5+。装机时间 5 分钟。 --- ### 定义 agent ```typescript import { createAgent, anthropic } from "@inngest/agent-kit"; const researchAgent = createAgent({ name: "Researcher", description: "Searches the web and summarizes findings", model: anthropic({ model: "claude-3-5-sonnet-20241022" }), system: "You are a research assistant. Search aggressively, cite sources.", tools: [ { name: "web_search", description: "Search the web", parameters: z.object({ query: z.string() }), handler: async ({ query }) => { return await fetch(`https://api.tavily.com/search?q=${query}`) .then(r => r.json()); }, }, ], }); ``` ### 在 Inngest function 里跑 ```typescript inngest.createFunction( { id: "research" }, { event: "research.requested" }, async ({ event, step }) => { const { topic } = event.data; // 每个 agent step 是 checkpoint,扛崩溃 const findings = await step.run("research", () => researchAgent.run(`Research ${topic}`)); return findings; }, ); ``` ### Agent 网络 ```typescript import { createNetwork } from "@inngest/agent-kit"; const network = createNetwork({ agents: [researchAgent, writerAgent, editorAgent], defaultModel: anthropic({ model: "claude-3-5-haiku-20241022" }), router: ({ network, callCount }) => { if (callCount === 0) return researchAgent; if (network.state.kv.get("draft") === undefined) return writerAgent; return editorAgent; }, }); const final = await network.run("Write a 500-word brief on agent frameworks"); ``` router 函数按 network 状态决定下一个 agent 跑哪个。用它建 supervisor-worker 模式或顺序流水线。 --- ### FAQ **Q: Inngest 免费吗?** A: 免费 —— Inngest Apache-2.0 开源。Agent Kit 也开源。Inngest Cloud 有免费档(5 万次/月),付费档加并发和保留期。 **Q: 为啥用 Agent Kit 不用裸 Inngest?** A: 裸 Inngest function 适合通用后台任务。Agent Kit 加了类型化 agent 原语 —— 工具、系统 prompt、agent 网络 —— 不用自己撸。两者可以同项目混用。 **Q: 能配 Anthropic 和 OpenAI 吗?** A: 能 —— Agent Kit 自带 `anthropic()` / `openai()` / `gemini()` 适配器,以及任何 OpenAI 兼容端点(所以能接 LiteLLM Proxy 或 Together)。 --- ## 来源与感谢 > Built by [Inngest](https://github.com/inngest). Licensed under Apache-2.0. > > [inngest/agent-kit](https://github.com/inngest/agent-kit) — ⭐ Active --- Source: https://tokrepo.com/en/workflows/inngest-agent-kit-build-ai-agents-with-tools Author: Inngest