$npx -y skills add inngest/inngest-skills --skill inngest-agentsUse when building durable AI agents or agentic workflows with Inngest and AgentKit, including model calls, tool calls, multi-agent networks, human approval, realtime progress, provider rate limits, crash-safe execution, and Agent Evals handoff. Covers AgentKit, step.ai, `step.r
| 1 | # Inngest Agents |
| 2 | |
| 3 | Use this skill when the user wants to build, migrate, or debug an AI agent, |
| 4 | multi-step AI workflow, tool-calling loop, support agent, research agent, |
| 5 | human-in-the-loop review flow, or realtime agent UI. |
| 6 | |
| 7 | Inngest's AgentKit defines agents with `createAgent`; when an AgentKit run is |
| 8 | owned by an Inngest function, model calls use Inngest `step.ai` so they retry |
| 9 | and cache model results durably. Use the lower-level Inngest step primitives |
| 10 | around the agent for database reads/writes, tool side effects, waits, |
| 11 | approvals, realtime progress, and flow control. |
| 12 | |
| 13 | Official references: |
| 14 | |
| 15 | - AgentKit agents: https://agentkit.inngest.com/concepts/agents |
| 16 | - `createAgent`: https://agentkit.inngest.com/reference/create-agent |
| 17 | - AI inference and `step.ai`: https://www.inngest.com/docs/features/inngest-functions/steps-workflows/step-ai-orchestration |
| 18 | - Agent Evals: https://www.inngest.com/docs/learn/agent-evals |
| 19 | - AgentKit realtime hooks: https://www.inngest.com/changelog/2025-09-24-agentkit-use-agent |
| 20 | |
| 21 | ## Copyable Example |
| 22 | |
| 23 | When starting a durable support or tool-calling agent from scratch, inspect the |
| 24 | companion example at `../../examples/durable-agent`. It shows the expected |
| 25 | agent-first shape: quick HTTP trigger, typed events, AgentKit inside an |
| 26 | Inngest function, step-scoped context loading, human approval with |
| 27 | `step.waitForEvent`, and durable side effects after approval. |
| 28 | |
| 29 | ## When to Use Inngest for Agents |
| 30 | |
| 31 | Good fit: |
| 32 | |
| 33 | - Agent can take longer than one HTTP request. |
| 34 | - Agent calls tools, APIs, databases, browsers, sandboxes, or MCP servers. |
| 35 | - Agent needs to survive deploys, crashes, serverless timeouts, or model/API |
| 36 | failures. |
| 37 | - Agent may wait for human approval, external callbacks, scheduled follow-up, |
| 38 | or user input. |
| 39 | - Agent progress should stream to a UI from the durable workflow. |
| 40 | - Model/provider calls need concurrency or throttle limits. |
| 41 | - Duplicate sends, charges, writes, or model calls would be costly. |
| 42 | |
| 43 | Not usually worth it: |
| 44 | |
| 45 | - One short, read-only model call with no side effects and no need for durable |
| 46 | progress. |
| 47 | - UI-only autocomplete where losing the request is acceptable. |
| 48 | |
| 49 | ## Architecture |
| 50 | |
| 51 | Use this shape unless the repo already has a stronger established pattern: |
| 52 | |
| 53 | 1. The HTTP/server action layer validates auth, stores the user's intent if |
| 54 | needed, emits an event with a stable `id`, and returns quickly. |
| 55 | 2. An Inngest function owns the agent run. |
| 56 | 3. Load state and external context inside `step.run`. |
| 57 | 4. Create AgentKit agents inside the function or import agent/network |
| 58 | factories. |
| 59 | 5. Run model inference through AgentKit / `step.ai`; wrap non-model tool side |
| 60 | effects in `step.run`. |
| 61 | 6. Use `step.waitForEvent` or `step.waitForSignal` for human approval and |
| 62 | external callbacks. |
| 63 | 7. Publish durable progress with native realtime. |
| 64 | 8. Add sessions and scores when the agent outcome needs to be evaluated later. |
| 65 | 9. Apply flow control at the function level for provider and tenant limits. |
| 66 | |
| 67 | ## Basic AgentKit Function |
| 68 | |
| 69 | Prefer a small, typed function first; add networks and extra tools after the |
| 70 | single-agent path is proven. |
| 71 | |
| 72 | ```typescript |
| 73 | import { createAgent, openai } from "@inngest/agent-kit"; |
| 74 | import { inngest } from "@/inngest/client"; |
| 75 | |
| 76 | export const summarizeTicket = inngest.createFunction( |
| 77 | { |
| 78 | id: "summarize-ticket", |
| 79 | triggers: [{ event: "support/ticket.created" }], |
| 80 | concurrency: [{ key: "event.data.accountId", limit: 2 }] |
| 81 | }, |
| 82 | async ({ event, step }) => { |
| 83 | const ticket = await step.run("load-ticket", () => { |
| 84 | return getTicket(event.data.ticketId); |
| 85 | }); |
| 86 | |
| 87 | const writer = createAgent({ |
| 88 | name: "support-summary-writer", |
| 89 | system: "Write a concise support-ticket summary with next actions.", |
| 90 | model: openai({ model: "gpt-4o" }) |
| 91 | }); |
| 92 | |
| 93 | const { output } = await writer.run(JSON.stringify(ticket)); |
| 94 | |
| 95 | await step.run("save-summary", () => { |
| 96 | return saveTicketSummary(event.data.ticketId, output); |
| 97 | }); |
| 98 | |
| 99 | return { ticketId: event.data.ticketId }; |
| 100 | } |
| 101 | ); |
| 102 | ``` |
| 103 | |
| 104 | ## Tool Calls |
| 105 | |
| 106 | Tools can be defined with AgentKit, but agent-safe tools should still follow |
| 107 | durability rules: |
| 108 | |
| 109 | - Read-only tool calls can run as part of the agent when replaying is harmless. |
| 110 | - External side effects should be isolated with stable IDs and `step.run` |
| 111 | boundaries, or implemented as tool handlers that use the provided `step`. |
| 112 | - Tool outputs should be small enough for step state limits. |
| 113 | - Validate tool parameters |