Build production-grade AI agents in Go — extensible and pluggable by design, backed by Temporal for durable, crash-resilient execution, or run in-process with zero setup. See Capabilities for the full feature set.
Versioning: Semantic versioning; published lines are git tags (e.g.
v0.1.2). See the latest release — the README does not pin a patch number so it stays accurate after each tag.Note: Independent community library — not affiliated with Temporal Technologies.
agent-sdk-go is a Go SDK for production AI agents — tools, MCP, A2A, human-in-the-loop approvals, and multi-agent delegation.
Every agent run on the Temporal runtime is a durable workflow: it survives process crashes and deploys, supports horizontal scaling, and is observable as a real service operation. This is the recommended runtime for production workloads where run durability matters. A running Temporal server is required.
The in-process runtime runs the agent loop directly in your process with no external dependencies — ideal for development, testing, and deployments where Temporal is not available. It has full feature parity: tools, MCP, A2A, sub-agents, streaming, AG-UI, approvals, conversation, and observability.
pkg/agent exposes three entry points — Run, Stream, and RunAsync. Add WithTemporalConfig or WithTemporalClient for the Temporal runtime; omit it for in-process. See Getting Started or Runtimes.
interfaces.LLMClient.interfaces.Tool; optional parallel vs sequential execution for multiple tool calls in one LLM round (WithAgentToolExecutionMode).Run, RunAsync, and Stream.WithConversation and conversation.Config; in-memory store for in-process; Redis for remote workers. Bring your own backend via interfaces.Conversation.WithSubAgents; recursive delegation with depth limiting; all sub-agent events fan in to the parent stream on both runtimes.WithMCPConfig or WithMCPClients.WithA2AConfig or WithA2AClients; or expose the agent itself as an A2A server via WithA2ADefaultServer / WithA2AServer and RunA2A.WithMemory and memory.Config; built-in Weaviate and pgvector backends; same config on agent and worker for remote deployments.Retriever interface with built-in Weaviate and pgvector support; extend with your own implementation.Stream and WithStream.★ Temporal runtime only.
Demo applications that use agent-sdk-go end-to-end:
Temporal powers agents through three moving parts: a Temporal client that launches agent workflows, workers (typically NewAgentWorker) that poll task queues and execute workflow and activity code, and workflow history that makes each run durable. Workers are stateless — they replay and advance history, not hold state themselves.
graph TD
A[Agent] --> WF[Workflow: agent loop]
W[Agent Worker] --> WF
WF --> LLM[Activity: LLM call]
WF --> Appr[Activity: approval]
WF --> Child[Child Workflow: sub-agent loop]
WF --> Tool[Activity: tool execution]
WF --> Mem[Activity: save memory]
Child --> LLM2[Activity: LLM call]
Child --> Tool2[Activity: tool execution]
Child --> Mem2[Activity: save memory]
Details: Temporal connection, Sub-agents, Agent and worker in separate processes.
Because every agent run is a Temporal workflow, the process can crash and restart without losing a single step — tool calls already made are not replayed, approvals already given are not re-requested, and the agent resumes exactly where it left off. DisableLocalWorker and NewAgentWorker let you split the client and execution across OS processes or machines while the cluster holds all state.
examples/durable_agent walks through this split across two terminals, including crash and retry scenarios. Step-by-step exercises: examples/durable_agent/README.md.
Stream events and approval events cross two boundaries: Temporal (durable workflow) and your hosts and subscribers. The guarantees differ on each side. These constraints matter most in interactive, user-facing scenarios — autonomous backend agents are largely unaffected since they do not depend on live event delivery.
Stream crashes, the workflow continues in Temporal but your client loses the connection. Once a stream is lost, reconnecting to that specific run is not supported — the recommended approach is to block the user from sending a new prompt until the current one completes, then fetch the final response and display it. This keeps conversation turns sequential and avoids out-of-order state. For autonomous agents, this is a non-issue since the caller waits for completion and the workflow finishes regardless.Runs the agent loop directly in your process — zero setup, zero infrastructure.
When to use: - Development, testing, and prototyping - Deployments where Temporal is not needed - Short-lived runs where crash recovery is not required
All capabilities listed above apply except ★ items. Conversation uses the in-memory store only. If the process crashes, the run is lost — no replay, no remote workers.
Switching to Temporal: add WithTemporalConfig (or WithTemporalClient) to any NewAgent call — no other code changes required.
How to use the SDK—agents, LLMs, Temporal connection, examples.
Go 1.26+ (see go.mod) and credentials for your LLM provider are always required.
go get and an LLM API key.Module: github.com/agenticenv/agent-sdk-go
go get github.com/agenticenv/agent-sdk-go@latest
Local runtime (no Temporal required):
import (
"github.com/agenticenv/agent-sdk-go/pkg/agent"
"github.com/agenticenv/agent-sdk-go/pkg/llm"
"github.com/agenticenv/agent-sdk-go/pkg/llm/openai"
)
llmClient, _ := openai.NewClient(
llm.WithAPIKey("sk-..."),
llm.WithModel("gpt-4o"),
)
a, _ := agent.NewAgent(
agent.WithSystemPrompt("You are a helpful assistant."),
agent.WithLLMClient(llmClient),
)
defer a.Close()
result, err := a.Run(ctx, "Hello", nil)
// result.Content, result.AgentName, result.Model
Temporal runtime (durable execution):
a, _ := agent.NewAgent(
agent.WithTemporalConfig(&agent.TemporalConfig{
Host: "localhost", Port: 7233,
Namespace: "default", TaskQueue: "my-app",
}),
agent.WithSystemPrompt("You are a helpful assistant."),
agent.WithLLMClient(llmClient),
)
defer a.Close()
result, err := a.Run(ctx, "Hello", nil)
Provide either WithTemporalConfig or WithTemporalClient, not both.
Option 1 — WithTemporalConfig (simple, local dev):
agent.WithTemporalConfig(&agent.TemporalConfig{
Host: "localhost", Port: 7233,
Namespace: "default", TaskQueue: "my-app",
})
Option 2 — WithTemporalClient (TLS, API key auth, Temporal Cloud):
Use when you need mTLS, Temporal Cloud API keys, or other connection options. Create the cli
$ claude mcp add agent-sdk-go \
-- python -m otcore.mcp_server <graph>