Awesome Go

golem

CategoryArtificial Intelligence
SubcategoryArtificial Intelligence
Stars9

Framework for building dependable AI agents with typed dependencies, zero external dependencies, and native MCP support

About golem


Why Golem?

Python frameworks like Pydantic AI made agent prototyping easy. Production systems need Go's concurrency, predictable memory, and small binaries. Golem brings typed agents to Go:

  • Type-safe: Agent[Deps, Output] and RunContext[Deps] give tools typed dependencies and typed results. No map[string]any.
  • Zero dependencies: standard library only, so builds are fast and the supply-chain surface is small.
  • Any model: OpenAI, Anthropic, Gemini, Bedrock, Azure, Groq, DeepSeek, Ollama, and LM Studio.
  • Self-correcting: the model can retry bad tool calls or output (ModelRetry), with fallback models, backoff, and per-tool timeouts.
  • Auditable: every run returns messages, token usage, cost, and live events. A failed run keeps its partial evidence (RunError.Partial).
  • Human-in-the-loop: pause a run for approval or an external result, then resume it.
  • Built-in tools: MCP client and server, PDF, Office, web, file, and shell tools, plus skills, planning, and memory.
  • Cost-bounded: cap tokens, requests, tool calls, or dollars per run.

How Golem Compares

Against the other actively maintained Go agent frameworks: langchaingo, Eino, and Genkit (Go).

GolemlangchaingoEinoGenkit
DependenciesNone (stdlib)ManySeveralSeveral
Typed tool dependencies✅❌Partial❌
Built-in MCP client✅❌❌ (eino-ext)❌
Self-correction (ModelRetry)✅❌Partial❌
Model fallback✅❌❌❌
Pause and resume for humans✅❌✅Experimental
Token and cost limits✅❌❌❌
Offline test model✅❌❌❌
PDF, Office, web, shell tools✅Partial❌❌
DesignLinear loopChainsGraphsFlows
  • Choose Golem for a dependency-free, typed, production-guarded agent loop.
  • Choose Eino for branching or parallel multi-agent graphs and a larger component ecosystem.
  • Choose langchaingo for the widest provider and vector-store coverage.
  • Choose Genkit for Google tooling (Developer UI, tracing, evaluation) and tight Gemini integration.

Based on each project's public docs and source as of October 2026. Verify against upstream before depending on a specific behavior.


Architecture

Golem orchestrates agents through a transparent, observable execution loop:

flowchart TB
    RC["<b>golem.RunContext[Deps]</b><br/>Typed Run Dependencies"]
    Prompt["<b>Prompt</b><br/>Text, Images, Docs, Audio"]
    Agent["<b>golem.Agent[Deps, Out]</b><br/>Observable Loop:<br/>self-correction · retries &amp; fallbacks<br/>token &amp; cost bounds · run events"]
    Output["<b>Typed Output</b><br/>Result[Output]"]
    Evidence["<b>Durable Evidence</b><br/>Messages, Cost, Token Usage"]
    Adapters["<b>Model Adapters</b><br/>OpenAI · Anthropic · Gemini<br/>Bedrock · Azure · Ollama/LM Studio"]
    Tools["<b>Tools &amp; Protocols</b><br/>Typed tools · MCP (stdio/HTTP)<br/>PDF/doc extractors · web fetch · shell"]

    RC --> Agent
    Prompt --> Agent
    Agent --> Output
    Output --> Evidence
    Agent --> Adapters
    Agent --> Tools

Installation

go get github.com/abubakarsiddik31/golem

Requires Go 1.26 or newer. Zero external dependencies.


Quick Start

1. Minimal Agent

Initialize a model adapter, create a typed agent, and execute a prompt:

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/abubakarsiddik31/golem"
	"github.com/abubakarsiddik31/golem/model"
	"github.com/abubakarsiddik31/golem/providers/openai"
)

func main() {
	client, err := openai.New(openai.Config{
		APIKey: os.Getenv("OPENAI_API_KEY"),
		Model:  "gpt-4o-mini",
	})
	if err != nil {
		panic(err)
	}

	agent, err := golem.New[struct{}, string](client,
		golem.DecodeFunc[string](func(_ context.Context, r model.Response) (string, error) {
			return r.Message.Content, nil
		}),
	)
	if err != nil {
		panic(err)
	}

	result, err := agent.Run(context.Background(), golem.RunContext[struct{}]{}, "Why is Go ideal for AI agents?")
	if err != nil {
		panic(err)
	}

	fmt.Println(result.Output)
	fmt.Printf("Tokens: %d input, %d output\n", result.Usage.InputTokens, result.Usage.OutputTokens)
}

2. Next steps

  • Typed tools with dependency injection: tools receive your database, auth context, or HTTP client through RunContext[Deps]. See Tools and dependencies and the tools example.
  • Structured output: get typed Go structs back with golem.DecodeJSON[T]() and schema enforcement. See Structured output and the structured-output example.

Supported Providers

Golem ships with standard-library-only adapters for all major frontier and open-weight models:

ProviderAdapter PackageStreamingThinking / ReasoningMultimodalEmbeddingsToken Counting
OpenAIproviders/openai:white_check_mark::white_check_mark::white_check_mark::white_check_mark:—
Anthropicproviders/anthropic:white_check_mark::white_check_mark::white_check_mark:—:white_check_mark:
Google Geminiproviders/gemini:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
AWS Bedrockproviders/bedrock:white_check_mark::white_check_mark::white_check_mark:—:white_check_mark:
Azure OpenAIproviders/azure:white_check_mark::white_check_mark::white_check_mark::white_check_mark:—
Ollama / Localproviders/openai:white_check_mark::white_check_mark::white_check_mark::white_check_mark:—
DeepSeekproviders/openai:white_check_mark::white_check_mark: (reasoning_content + <think>)———
Groqproviders/groq:white_check_mark::white_check_mark:———
OpenAI-Compatibleproviders/openai:white_check_mark::white_check_mark::white_check_mark::white_check_mark:—

Testing Without a Provider

Never mock HTTP endpoints or pay for tokens in unit tests. Golem includes testmodel, a fully deterministic, offline model implementation:

package main

import (
	"context"
	"testing"

	"github.com/abubakarsiddik31/golem"
	"github.com/abubakarsiddik31/golem/model"
	"github.com/abubakarsiddik31/golem/testmodel"
)

func TestAgent(t *testing.T) {
	client := testmodel.New().Respond(
		model.Response{Message: model.Message{Role: model.RoleAssistant, Content: "pong"}},
	)

	agent, _ := golem.New[struct{}, string](client,
		golem.DecodeFunc[string](func(_ context.Context, r model.Response) (string, error) {
			return r.Message.Content, nil
		}),
	)

	result, err := agent.Run(context.Background(), golem.RunContext[struct{}]{}, "ping")
	if err != nil || result.Output != "pong" {
		t.Fatalf("unexpected result: %v, output: %s", err, result.Output)
	}
}

Documentation

Each capability has a guide in docs/guides/, also published at abubakarsiddik31.github.io/golem. Design records live in docs/adr/.


Examples

Runnable programs live in examples/, one per capability. Provider-backed examples read their API key from the environment and exit with instructions when it is unset; the rest run offline.

To run any example:

# Run with OpenAI
OPENAI_API_KEY=sk-... go run ./examples/minimal

# Run locally with Ollama or LM Studio
GOLEM_LOCAL_BASE_URL=http://localhost:11434/v1 go run ./examples/local-models

# Run offline examples (no credentials needed)
go run ./examples/testing-without-a-provider
go run ./examples/pdf-extract
go run ./examples/ocr-scanned-pdf
go run ./examples/deferred-tools
go run ./examples/partial-evidence

Package Structure

golem/        Agent configuration and typed run API
model/        Provider-neutral model request/response contract
tool/         Tool declarations and execution contracts
guard/        Guards at the run's boundaries (prompts, tool calls, results, output)
session/      Store port for conversations that persist between runs
tokens/       Token counting port for budgets and pre-send limits
embedding/    Embedder port: queries, documents, usage
retrieval/    Index port: cosine top-k search and the search_documents tool
telemetry/    Tracing port with an SDK-free OpenTelemetry adapter
mcp/          Model Context Protocol client (stdio & streaming HTTP)
mcpserver/    Expose one Golem agent as an MCP tool (stdio or stateless HTTP)
pdfextract/   Common tool: layout-aware PDF parser (tables, images, text)
docextract/   Common tool: Word, Excel, PowerPoint, CSV, and Markdown extractor
webfetch/     Common tool: fetch a URL as agent-readable text
websearch/    Common tool: ranked web search behind a backend port
fileread/     Common tool: read a file as agent-readable text
shell/        Common tool: run one command, return combined output
skills/       Common tool: standard SKILL.md folder progressive loader
planning/     Toolset: model-owned task plan behind a store port
memory/       Toolset: persistent namespaced Markdown notebook behind a store port
providers/    Stdlib-only adapters implementing model.Model
testmodel/    Deterministic in-memory model doubles for unit testing
internal/     Execution runner loop and private mechanics
examples/     Runnable programs per capability
assets/       Brand assets
scripts/      Coverage, API-compatibility, benchmark, and smoke-test scripts
docs/guides/  Feature guides (source of truth for behavior)
docs/adr/     Decisions that shape public contracts

Status & Roadmap

Golem is stable: see the latest release and the changelog.

The core execution contract is frozen and verified with continuous race-detector CI, memory fuzzing, and deterministic offline tests. Since v1.0.0 the public API follows SemVer with additive-only changes below v2, checked by API diff on every release (ADR 0041).

For architecture rationale, read the foundation brief. For upcoming milestones, read the development roadmap. For measured costs and how to run the benchmarks, read the benchmark baseline.


Development

Run the test suite and verification checks:

go test ./...
go test -race ./...
go vet ./...

The feature guides publish as the official documentation site; preview it locally with mkdocs serve (see docs/website.md). Brand assets and guidelines live in assets/brand/.


Community & Contributing

Golem is an open-source project and actively welcomes community contributions!

  • Good First Issues — approachable issues scoped for newcomers
  • Roadmap — direction, open items, and design decisions
  • GitHub Discussions — ask usage questions, share architectures, and propose RFCs
  • Issues — bug reports and concrete feature requests, not general questions
  • Contributing Guide — instructions for setting up, running checks, and submitting changes
  • Security Policy — guidelines for privately reporting vulnerabilities
  • Code of Conduct — standards for participation

License

Released under the MIT License.

Frequently Asked Questions

What is golem?

golem is a Artificial Intelligence library for the Go programming language. Framework for building dependable AI agents with typed dependencies, zero external dependencies, and native MCP support

How do I install golem?

Install golem with the Go module system using `go get abubakarsiddik31/golem`. Check the repository for the current installation instructions.

What category does golem belong to?

golem is listed under Artificial Intelligence, specifically Artificial Intelligence.

← Back to Artificial Intelligence