Python frameworks like Pydantic AI made agent prototyping accessible with typed schemas and clean ergonomics. But deploying AI agents to mission-critical production systems demands the strengths of Go: high-throughput concurrency, predictable memory usage, fast execution, small deployment binaries, and compile-time correctness. Golem bridges that gap with idiomatic, enterprise-ready agent abstractions designed specifically for Go engineers.
Compile-time type safety with generics
Agents are declared as Agent[Deps, Output]. Tools access strongly-typed dependencies — databases, auth contexts, HTTP clients — via RunContext[Deps]. There is no map[string]any spaghetti and no unexpected runtime reflection errors. The type system catches mismatches before the code runs.
Zero external dependencies
The framework builds exclusively on Go's standard library. That means instant compilation, tiny container images, and a clean security profile free of supply-chain vulnerabilities. No transitive dependencies to audit or update.
Provider-agnostic model adapters
Golem ships with native adapters for OpenAI, Anthropic (with prompt caching and thinking signatures), Google Gemini, AWS Bedrock (Converse API with SigV4), Azure OpenAI, and local offline models through Ollama and LM Studio. The same agent code works across providers. A single adapter package handles OpenAI-compatible endpoints, so any OpenAI-compatible API works out of the box.
Native Model Context Protocol support
A full-featured MCP client connects to any MCP tool server over stdio or streaming HTTP (SSE). External MCP servers become typed agent tools without wrapper code. The client handles transport details so developers work with Go types instead of protocol messages.
Production resilience built into the loop
The execution loop includes in-loop model self-correction through ModelRetry, automated multi-model fallbacks, exponential backoff, per-tool deadlines, and clean in-tool cancellation via tool.Canceled. If a tool call exceeds its deadline or the model returns malformed output, the framework retries or falls back without developer intervention.
Auditable evidence for every run
Every run produces normalized messages, durable additive JSON, live streamable run events, reasoning and thinking token capture, and RunError.Partial — preserving all intermediate tool results even when a run fails or gets cancelled. Teams can audit exactly what the agent did, why it did it, and what it cost.
Human-in-the-loop and deferred execution
Agent runs pause cleanly when tools require human sign-off or external async triggers. The framework preserves full state so runs resume deterministically. This enables approval workflows, long-running external operations, and interactive debugging without losing context.
Batteries-included tooling written in pure Go
pdfextract— layout-aware PDF extraction preserving reading order, tables, and embedded imagesdocextract— multi-format extraction from Word, Excel, PowerPoint, Markdown, and CSVwebfetch— SSR web reader returning clean, agent-readable text without browser overheadfileread— safe workspace file reading with path boundariesshell— isolated command execution with timeout handling and combined stdout/stderrskills— progressive loading of standardSKILL.mdfolders for prompt enrichment
Budget and cost guards
Pre-send token estimation prevents surprise bills. Token-budgeted history truncation keeps context windows manageable. Client-side untrusted history sanitization via SanitizeHistory strips sensitive data before it reaches the model. User-defined price tables calculate and cap dollar costs per run.
Deterministic testing without API calls
The testmodel package provides a fully deterministic, offline model implementation. Unit tests run without mocking HTTP endpoints or paying for tokens. Developers specify exact responses and assert on agent behavior against known inputs.
client := testmodel.New().Respond(
model.Response{Message: model.Message{Role: model.RoleAssistant, Content: "pong"}},
)
agent, _ := golem.New[struct{}, string](client, golem.DecodeFunc[string](...))
result, err := agent.Run(ctx, golem.RunContext[struct{}]{}, "ping")
Structured output with schema enforcement
golem.DecodeJSON[T]() guarantees agents return strongly-typed Go structs. Output schemas enforce strict validation — additional properties rejected, required fields validated. The framework handles schema generation and response parsing so developers work with typed values, not raw JSON.
type WeatherReport struct {
City string `json:"city"`
Temperature float64 `json:"temperature_celsius"`
Condition string `json:"condition"`
}
agent, _ := golem.New[struct{}, WeatherReport](client,
golem.DecodeJSON[WeatherReport](),
golem.WithOutputSchema[struct{}, WeatherReport](schema),
)
What this means for Go teams
Teams building production AI systems no longer need to choose between Python's ergonomics and Go's operational strengths. Golem brings typed dependencies, explicit execution control, and deep observability to a language built for concurrency and reliability. The framework requires Go 1.26.5 or newer and installs with go get github.com/abubakarsiddik31/golem.