AgentKit

AgentKit overview

This page introduces the APIs and concepts to AgentKit. AgentKit is in early access, and is improving on a daily basis.

The AgentKit SDK lets developers build, test, and deploy reliable AI applications at scale — from single model calls to multi-agent workflows that use tools. Using the SDK lets you focus on AI code instead of technical details like orchestration, state, or infrastructure.

Here’s how you can generate a single inference call using the SDK:

import { Agent, agenticOpenai as openai } from "@inngest/agent-kit";

export default inngest.createFunction(
  { id: "summarizer" },
  { event: "api/post.created" },
  async ({ event, step }) => {

    const writer = new Agent({
      name: "writer",
      system: "You are an expert writer.  You write readable, concise, simple content.",
      model: openai({ model: "gpt-4o", step }),
    });
    
    const { output } = await writer.run(
      "Describe the ideas behind the given input into clear topics, and explain any insight: " +
      `<content>${event.data.input}</content>`
    );

  },
);

And here’s how you can create a network of agents, each of which has different tools and instructions, to complete complex tasks:

import { Network, agenticOpenai as openai  } from "@inngest/agent-kit";
import { navigator, classifier, summarizer } from "./src/agents";

export default inngest.createFunction(
  { id: "summarizer" },
  { event: "api/summary.requested" },
  async ({ event, step }) => {

    // Create a network of agents with separate tasks and instructions
    // to solve // a specific task.
    const network = new Network({
      agents: [navigator, classifier, summarizer],
      defaultModel: openai({ model: "gpt-4o", step }),
    })
    
    const input = `Classify then summarize the latest 10 blog posts
      on https://www.deeplearning.ai/blog/`
    
    const result = await network.run(, ({ network }) => {
      // Use an agent which figures out the specific agent to call
      // based off of the network's history.
      return defaultRoutingAgent;
    });

  },
);

Concepts

It’s helpful to familiarize yourself with several concepts in order to effectively use AgentKit:

Agents

An Agent is used to call a single model with a system prompt and a set of tools. When an agent runs, it calls the model passing in the prompt, user input, and any tools. Depending on the response, the agent will automatically call tools and return a standardized output. Agents can be run individually or combined into a Network of Agents which can work together to achieve more complex goals.

Learn more about agents

Networks

A network is a group of agents which can work together using shared state to solve complex tasks. Networks iteratively call individual agents and their tools until the task is complete, using a router to determine the best next step. This lets you solve tasks in ways that may be hard with a single LLM request.

Learn more about networks

Network state

In a network, there’s typically more than one inference call. The network stores state, which includes the memory of all past inference calls and a key-value store for facts, thoughts, and observations returned in each call. State allows you to transfer reasoning from one agent to another during routing, and allows you to complete complex tasks.

Learn more about network state

Network Routers

A network calls different agents, many times, in a loop. The router helps determine which agent should be called next, based off of the current network state, the input, and the available agents. Examples of routers are:

  • Callback code which inspects state and returns agents (supervised networks)
  • Another agent which inspects state, other available agents in the network, then returns another agent it recommends next (fully autonomous networks)
  • Or a mixture of code and routing agents (semi-autonomous networks)

Learn more about network state