Terminal
Terminal/Skill
Guides building durable AI agents with Inngest and AgentKit, covering tool calls, human approval, realtime progress, and handing off to Agent Evals.
By Inngest
Works with
npx skills add inngest/inngest-skills --skill inngest-agentsUse this skill when the user wants to build, migrate, or debug an AI agent, multi-step AI workflow, tool-calling loop, support agent, research agent, human-in-the-loop review flow, or realtime agent UI.
Inngest's AgentKit defines agents with createAgent; when an AgentKit run is
owned by an Inngest function, model calls use Inngest step.ai so they retry
and cache model results durably. Use the lower-level Inngest step primitives
around the agent for database reads/writes, tool side effects, waits,
approvals, realtime progress, and flow control.
Official references:
createAgent: https://agentkit.inngest.com/reference/create-agentstep.ai: https://www.inngest.com/docs/features/inngest-functions/steps-workflows/step-ai-orchestrationWhen starting a durable support or tool-calling agent from scratch, inspect the
companion example at ../../examples/durable-agent. It shows the expected
agent-first shape: quick HTTP trigger, typed events, AgentKit inside an
Inngest function, step-scoped context loading, human approval with
step.waitForEvent, and durable side effects after approval.
Good fit:
Not usually worth it:
Use this shape unless the repo already has a stronger established pattern:
id, and returns quickly.step.run.step.ai; wrap non-model tool side
effects in step.run.step.waitForEvent or step.waitForSignal for human approval and
external callbacks.Prefer a small, typed function first; add networks and extra tools after the single-agent path is proven.
import { createAgent, openai } from "@inngest/agent-kit";
import { inngest } from "@/inngest/client";
export const summarizeTicket = inngest.createFunction(
{
id: "summarize-ticket",
triggers: [{ event: "support/ticket.created" }],
concurrency: [{ key: "event.data.accountId", limit: 2 }]
},
async ({ event, step }) => {
const ticket = await step.run("load-ticket", () => {
return getTicket(event.data.ticketId);
});
const writer = createAgent({
name: "support-summary-writer",
system: "Write a concise support-ticket summary with next actions.",
model: openai({ model: "gpt-4o" })
});
const { output } = await writer.run(JSON.stringify(ticket));
await step.run("save-summary", () => {
return saveTicketSummary(event.data.ticketId, output);
});
return { ticketId: event.data.ticketId };
}
);
Tools can be defined with AgentKit, but agent-safe tools should still follow durability rules:
step.run
boundaries, or implemented as tool handlers that use the provided step.Tool side-effect checklist:
- What external state can this tool change?
- What idempotency key prevents duplicate writes?
- What should happen if the model calls the same tool twice?
- Is the output safe to store in function run state?
- Does the tool need provider-specific concurrency or throttle limits?
Use a durable wait instead of polling a database or keeping state in memory.
const approval = await step.waitForEvent("wait-for-approval", {
event: "support/reply.approved",
timeout: "3d",
match: "data.ticketId"
});
if (!approval) {
await step.run("mark-review-timeout", () => {
return markTicketNeedsManualReview(event.data.ticketId);
});
return { status: "timed_out" };
}
await step.run("send-reply", () => {
return sendSupportReply({
ticketId: event.data.ticketId,
approvalId: approval.data.approvalId
});
});
For v4 native realtime:
step.realtime.publish between steps.inngest.realtime.publish inside an existing step.run.@inngest/realtime package for v4 projects.For AgentKit-specific UI hooks, check the installed @inngest/agent-kit
version and current docs before wiring useAgent or useChat.
Use inngest-agent-evals when the user asks to score an agent, compare prompts
or models, track user feedback, group runs by conversation/ticket, or debug
agent quality over time. In durable agent workflows, add meta.sessions at the
event that starts or connects the user flow, use direct scoring for signals
known during the run, and use deferred scorers for product outcomes that arrive
later.
Agent workloads often need provider and tenant limits:
Example:
{
id: "support-agent-run",
triggers: [{ event: "support/agent.requested" }],
throttle: {
limit: 120,
period: "1m",
key: `"openai"`
},
concurrency: [
{ key: "event.data.accountId", limit: 3 }
]
}
When migrating an existing agent:
step.ai.step.run or durable tool handlers.step.waitForEvent or
step.waitForSignal.Use inngest-brownfield-audit first when the repo has multiple possible
workflows and the user has not picked one.
try/catch around all model and tool calls.setTimeout, cron polling, or Redis TTL as the human-review mechanism.