Skip to main content
Agent SDK for Go is a Go library for building production AI agents. It handles the full execution loop — LLM calls, tool use, approvals, memory, multi-agent delegation — so you write configuration and business logic, not plumbing. Who it’s for: Go backend engineers who want to ship agents in the same language, type system, and deployment pipeline as the rest of their stack — without glue code, dynamic typing, or a Python runtime.

Your First Agent

That’s it — configure once, call repeatedly. Tools, memory, and streaming are additive options — not new APIs to learn. This agent is already durable: it journals every LLM call and tool execution to disk via durable-go, no extra config needed.

Install

Go 1.26+. OpenAI API key required for the example above; Anthropic and Gemini are also built in. Temporal and Restate are optional — they add distributed, horizontally-scaled execution, not durability itself.

Why Agent SDK for Go

  • Idiomatic Go — functional options, typed interfaces, no reflection magic. Swap any component (LLM client, memory backend, approval policy) by passing a different option.
  • Durable by default, no infrastructure — the in-process runtime journals every step via durable-go; kill the process and reconnect after a restart. Add temporal.WithTemporalConfig (from pkg/agent/runtime/temporal) or restate.WithRestateConfig (from pkg/agent/runtime/restate) only when you need horizontal scale or a client/worker split. Nothing else changes.
  • Concurrent by default — one Agent instance handles parallel Run and Stream calls; every runtime issues each a unique run automatically.
  • Protocol-native integrations — MCP tool servers, A2A agent-to-agent delegation, and AG-UI streaming events are first-class, not adapters bolted on after the fact.
  • Middleware hooks — intercept LLM calls, tool use, retrieval, and memory at any lifecycle point for logging, PII scrubbing, and guardrails without touching agent logic.
  • Error control — after retries, swap to a fallback model, grant more iterations, or skip a looping tool. See Error Control.
  • Cache-aware requests — LLM requests are structured for provider caching, with Anthropic prompt-cache breakpoints to reduce cost on multi-turn runs.

Runtimes

Run agents in-process — durable by default, no infrastructure — or add Temporal or Restate when you need horizontal scale or a client/worker split. Add temporal.WithTemporalConfig or restate.WithRestateConfig to switch. See Runtimes.

Start here

Quickstart

Your first agent, step by step — under 5 minutes

Architecture

How the agent loop maps to capabilities and runtimes