Skip to main content

Agents Overview

AG-Kit provides two main agent types for building AI applications.

Agent Types

Core Agent

Built-in agent with memory, tools, and event system

LangGraph Agent

LangGraph workflow integration with state management

Core Features

Core Agent

Complete agent implementation with tools, control flow, and streaming

LangGraph Agent

LangGraph workflow integration with state management

Quick Start

import { Agent, OpenAIProvider } from '@ag-kit/agents';

const modelProvider = new OpenAIProvider({
  apiKey: process.env.OPENAI_API_KEY,
  defaultModel: 'gpt-4'
});

// Define a tool with parameters
const weatherTool = {
  name: 'get_weather',
  description: 'Get current weather for a location',
  schema: z.object({
    location: z.string().describe('City name or coordinates'),
    unit: z.enum(['celsius', 'fahrenheit']).default('celsius')
  }),
  handler: async (input: { location: string; unit: string }) => {
    // Tool implementation
    return { temperature: 22, condition: 'sunny', unit: input.unit };
  }
};

const agent = new Agent({
  name: 'my-agent',
  model: modelProvider,
  instructions: 'You are a helpful assistant with access to weather information.',
  tools: [weatherTool]
});

const result = await agent.run('What is the weather in New York?');
console.log(result.data);

Installation

npm install @ag-kit/agents