Skip to content

divinedev111/agentkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Go Report Card License: MIT

agentkit

Lightweight framework for building multi-step AI agents in Go. Define tools, give the agent a task, and it figures out the steps. Uses Claude as the reasoning engine.

Think LangGraph — but Go, not Python, and not bloated.

Install

go get github.com/divinedev111/agentkit

Quick Start

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "log"

    "github.com/divinedev111/agentkit"
)

func main() {
    // Define a tool
    calculator := agentkit.DefineTool(
        "calculator",
        "Evaluate a math expression",
        []agentkit.Param{
            {Name: "expression", Type: "string", Description: "Math expression", Required: true},
        },
        func(_ context.Context, input json.RawMessage) (string, error) {
            var args struct{ Expression string }
            json.Unmarshal(input, &args)
            return "42", nil
        },
    )

    // Create and run an agent
    result, err := agentkit.Run(ctx, "math-agent", "What is 6 * 7?",
        agentkit.WithTool(calculator),
        agentkit.WithMaxSteps(5),
    )
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(result.Output)
}

How It Works

The agent loop:

  1. Send the task (and any tool results) to Claude
  2. Claude responds with text and/or tool calls
  3. If tool calls: execute them, feed results back to Claude, go to 1
  4. If no tool calls: return the final text output

That's it. No chains, no graphs, no YAML configs. Just a loop.

Defining Tools

searchTool := agentkit.DefineTool(
    "search",                          // name
    "Search the web for information",  // description (Claude reads this)
    []agentkit.Param{                  // parameters (becomes JSON Schema)
        {Name: "query", Type: "string", Description: "Search query", Required: true},
        {Name: "limit", Type: "number", Description: "Max results"},
    },
    func(ctx context.Context, input json.RawMessage) (string, error) {
        var args struct {
            Query string `json:"query"`
            Limit int    `json:"limit"`
        }
        json.Unmarshal(input, &args)
        // ... do the actual search
        return results, nil
    },
)

Parameters auto-generate a JSON Schema that Claude uses to structure its tool calls. Supported types: string, number, boolean, array, object.

Agent Options

agent := agentkit.New("my-agent",
    agentkit.WithTool(searchTool),          // add a tool
    agentkit.WithTool(saveTool),            // add another tool
    agentkit.WithModel("claude-sonnet-4-20250514"),  // model (default: claude-sonnet-4-20250514)
    agentkit.WithAPIKey("sk-ant-..."),      // API key (default: ANTHROPIC_API_KEY env)
    agentkit.WithMaxSteps(10),              // max iterations (default: 10)
    agentkit.WithMaxTokens(4096),           // max tokens per response
    agentkit.WithSystem("You are a ..."),   // system prompt
    agentkit.OnToolCall(func(name, input string) {
        fmt.Printf("[tool] %s\n", name)    // observe tool calls
    }),
    agentkit.OnStep(func(step int, text string) {
        fmt.Printf("[step %d] %s\n", step, text)  // observe agent thinking
    }),
)

result, err := agent.Run(ctx, "Research the latest Go release")

Result

type Result struct {
    Output    string  // final text output from the agent
    Steps     int     // number of loop iterations
    ToolCalls int     // total tool invocations
}

Architecture

agentkit.go         Package doc
run.go              Top-level API (New, Run, re-exported types)
agent/
  agent.go          Core agentic loop + Claude API client
  options.go        Configuration options
tool/
  tool.go           Tool definition + JSON Schema generation
memory/
  memory.go         Conversation history with eviction
examples/
  simple/           Calculator agent
  researcher/       Web research agent with note-taking

Environment

Variable Description
ANTHROPIC_API_KEY Claude API key (required)

License

MIT

About

Lightweight framework for building multi-step AI agents in Go. LangGraph but not Python, not bloated.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages