Inngest agents

From Asymmetric-al/core · View interactive version

Inngest agents is an AI agent skill from the GitHub repository Asymmetric-al/core. Use 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.run`, `step.waitForEv

How to use this skill

Skill file

Inngest Agents

Use 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:

Copyable Example

When starting a durable support or tool-calling agent from scratch, use the

official inngest/inngest-codex-plugin companion example at

plugins/inngest/examples/durable-agent as the upstream reference. This repo

does not vendor Codex plugin examples; copy only the patterns needed for a

separate product integration change.

When to Use Inngest for Agents

Good fit:

failures.

or user input.

Not usually worth it:

progress.

Architecture

Use this shape unless the repo already has a stronger established pattern:

  1. The HTTP/server action layer validates auth, stores the user's intent if

needed, emits an event with a stable id, and returns quickly.

  1. An Inngest function owns the agent run.
  2. Load state and external context inside step.run.
  3. Create AgentKit agents inside the function or import agent/network

factories.

  1. Run model inference through AgentKit / step.ai; wrap non-model tool side

effects in step.run.

  1. Use step.waitForEvent or step.waitForSignal for human approval and

external callbacks.

  1. Publish durable progress with native realtime.
  2. Add sessions and scores when the agent outcome needs to be evaluated later.
  3. Apply flow control at the function level for provider and tenant limits.

Basic AgentKit Function

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 };
  },
);

Tool Calls

Tools can be defined with AgentKit, but agent-safe tools should still follow

durability rules:

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?

Human in the Loop

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,
  });
});

Realtime Progress

For v4 native realtime:

durable function.

For AgentKit-specific UI hooks, check the installed @inngest/agent-kit

version and current docs before wiring useAgent or useChat.

Agent Evals

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.

Flow Control and Cost

Agent workloads often need provider and tenant limits:

expensive runs.

not re-charge earlier model calls.

Example:

{
  id: "support-agent-run",
  triggers: [{ event: "support/agent.requested" }],
  throttle: {
    limit: 120,
    period: "1m",
    key: `"openai"`
  },
  concurrency: [
    { key: "event.data.accountId", limit: 3 }
  ]
}

Brownfield Migration

When migrating an existing agent:

  1. Search for model calls, tool loops, in-memory state, streaming handlers,

approval polling, and external side effects.

  1. Keep prompt/tool behavior stable at first.
  2. Move the trigger into an event and an Inngest function.
  3. Move model calls to AgentKit / step.ai.
  4. Move side-effecting tools into step.run or durable tool handlers.
  5. Replace process-local waits with step.waitForEvent or

step.waitForSignal.

  1. Add realtime after the durable run is working.

Use inngest-brownfield-audit first when the repo has multiple possible

workflows and the user has not picked one.

Anti-Patterns

continues elsewhere.

Verification

This Repository

These upstream Inngest instructions are vendored for agent tooling and

integration work in this monorepo.

Repository Triggers

Use this skill when inngest-agents matches the current Inngest task. If the

right skill is unclear, start with docs/ai/skills/inngest/SKILL.md.

Repository Workflow

  1. Confirm whether the request is agent-tooling guidance or product runtime

integration.

  1. Use inngest-brownfield-audit before changing existing app workflows or

fragile background work.

  1. Follow this upstream guidance under OpenSpec, root AGENTS.md, repo

rulebooks, framework docs, and runtime evidence.

  1. Keep runtime packages, app code, migrations, and INNGEST_* env

requirements out of agent-tooling-only changes.

Repository Checklist

or dependencies.

workflow behavior.

port.

docs/ai/skills/inngest/references/upstream.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.