{"slug": "show-hn-agent-sdk-go-build-crash-resilient-ai-agents-in-go", "title": "Show HN: Agent-SDK-go – Build crash-resilient AI agents in Go", "summary": "Agentic Environment released Agent-SDK-go, an open-source Go SDK for building durable AI agents that resume after crashes, running in-process with zero setup via durable-go or switching to Temporal or Restate for distributed execution. The library requires Go 1.26+ and supports OpenAI, Anthropic, Gemini, DeepSeek and Ollama LLM providers, MCP servers over stdio or streamable HTTP, A2A agent interoperability, sub-agents, human-in-the-loop approvals, Redis-backed conversation history, RAG, token budget caps and OpenTelemetry observability. Agentic Environment states the project is an independent community library not affiliated with Temporal Technologies or Restate, and releases follow Semantic Versioning.", "body_md": "**Build durable Go AI agents that pick up right where they left off.**\n\n**Open-source Go SDK for building durable AI agents.** Runs in-process with crash-resilient execution via [durable-go](https://github.com/agenticenv/durable-go) with zero setup, or switch to [Temporal](https://temporal.io) / [Restate](https://restate.dev) for crash-resilient, distributed execution. Every core component is a pluggable interface, so you're never locked in.\n\n📖 [Documentation](https://docs.agenticenv.ai)  ·  [Quickstart](https://docs.agenticenv.ai/getting-started/quickstart)  ·  [Examples](https://docs.agenticenv.ai/examples/running-examples)\n\nReleases follow [Semantic Versioning](https://semver.org/); see the [latest release](https://github.com/agenticenv/agent-sdk-go/releases/latest).\n\nIndependent community library — **not** affiliated with Temporal Technologies or Restate.\n\n- **LLM providers** — OpenAI, Anthropic, Gemini, DeepSeek, Ollama (local) + custom via`interfaces.LLMClient`\n- **Tools & MCP** — built-in and custom tools; MCP servers over stdio or streamable HTTP\n- **A2A** — expose agents as A2A servers or connect remote A2A agents as tools\n- **Sub-agents** — delegate to specialist agents with independent LLMs, tools, and task queues\n- **Human-in-the-loop approvals** — gate tool calls, MCP invocations, and delegation\n- **Conversation history** — multi-turn sessions via in-memory or Redis backends\n- **Memory & RAG** — long-term scoped memory and retrieval-augmented generation\n- **Streaming & AG-UI** — partial token streaming; AG-UI protocol for frontend integration\n- **Reasoning** — extended thinking on Anthropic, Gemini, DeepSeek, and OpenAI reasoning models\n- **Token usage** — aggregate prompt, completion, and reasoning token counts per run\n- **Budget control** — cap token spend per run; stop execution or require human-in-the-loop approval when the limits are reached\n- **Lifecycle hooks** — middleware at LLM, tool, retrieval, and memory lifecycle points\n- **Error control** — fallback LLM after a classified failure, one extra-iteration grant, per-tool circuit breaker\n- **Execution config** — per-operation timeouts and max attempts via`With*ExecutionConfig`\n- **Durable execution** — crash-resilient runs on every runtime; reconnect to active runs and resume event streams after a restart\n- **Distributed execution** — with Temporal, decouple client triggers from worker execution across processes; with Restate, scale via registered endpoint deployments\n- **Observability** — OpenTelemetry traces, metrics, and structured logs\n\n```\ngo get github.com/agenticenv/agent-sdk-go@latest\n```\n\nGo 1.26+. Agents are durable by default, no infrastructure required. Add a [Temporal](https://temporal.io) or [Restate](https://restate.dev) server only when you want distributed, multi-process execution — see [temporal-setup.md](https://github.com/agenticenv/agent-sdk-go/blob/main/temporal-setup.md) and [restate-setup.md](https://github.com/agenticenv/agent-sdk-go/blob/main/restate-setup.md).\n\n**In-process** (zero setup):\n\n```\nimport (\n    \"context\"\n    \"fmt\"\n    \"time\"\n\n    \"github.com/agenticenv/agent-sdk-go/pkg/agent\"\n    \"github.com/agenticenv/agent-sdk-go/pkg/llm\"\n    \"github.com/agenticenv/agent-sdk-go/pkg/llm/openai\"\n)\n\n// errors omitted for brevity\nllmClient, _ := openai.NewClient(\n    llm.WithAPIKey(\"sk-...\"),\n    llm.WithModel(\"gpt-4o\"),\n)\n\na, _ := agent.NewAgent(\n    agent.WithSystemPrompt(\"You are a helpful assistant.\"),\n    agent.WithLLMClient(llmClient),\n    // Durable by default (journals to ./agent_data/<agent_name>). To tune the journal or opt\n    // out, import \"github.com/agenticenv/agent-sdk-go/pkg/agent/runtime/local\" and add:\n    // local.WithLocalConfig(&local.LocalConfig{\n    //     DataDir:      \"./agent_data/my-agent\", // default: \"./agent_data/<agent_name>\"\n    //     AutoPurgeAge: 24 * time.Hour,           // default: 7 days\n    //     Timeout:      2 * time.Minute,          // default: none — bound long-running/stuck runs\n    //     Durability:   local.DurabilityOff(),    // or opt out entirely — pure in-memory, no journal\n    // }),\n)\ndefer a.Close()\n\n// --- Run ---\nrun, _ := a.Run(context.Background(), \"Reply with a short greeting.\", nil)\nresult, _ := run.Get(context.Background())\nfmt.Println(result.Content)\n\n// --- Non-blocking ---\nrun, _ = a.Run(context.Background(), \"Explain durable agents in two short paragraphs.\", nil)\nselect {\ncase <-run.Done():\n    result, _ = run.Get(context.Background())\n    fmt.Println(result.Content)\ncase <-time.After(5 * time.Second):\n    fmt.Println(\"still running, check back later\")\n}\n\n// --- Stream (AG-UI events: text deltas, tools, approvals, lifecycle, …) ---\nstream, _ := a.Stream(context.Background(), \"Write a four-line poem about the ocean.\", nil)\nevents, _ := stream.Events(context.Background())\nfor event := range events {\n    switch e := event.(type) {\n    case *agent.AgentTextMessageContentEvent:\n        fmt.Print(e.Delta)\n    case *agent.AgentToolCallStartEvent:\n        fmt.Println(\"\\n[tool call]\", e.ToolCallName)\n    case *agent.AgentCustomEvent:\n        // tool / delegation approval (when approval policy requires it)\n        if e.Name == string(agent.AgentCustomEventNameToolApproval) {\n            if v, err := agent.ParseCustomEventApproval(e); err == nil {\n                // replace with real approval logic — this auto-approves for demonstration\n                _ = stream.Approve(context.Background(), v.ApprovalToken, agent.ApprovalStatusApproved)\n            }\n        }\n    // also RunFinished, ToolCallResult, …\n    }\n}\n```\n\n**Temporal** (distributed execution) — import `pkg/agent/runtime/temporal`:\n\n```\nimport \"github.com/agenticenv/agent-sdk-go/pkg/agent/runtime/temporal\"\n\na, _ := agent.NewAgent(\n    agent.WithSystemPrompt(\"You are a helpful assistant.\"),\n    agent.WithLLMClient(llmClient),\n    temporal.WithTemporalConfig(&temporal.TemporalConfig{\n        Host:      \"localhost\",\n        Port:      7233,\n        Namespace: \"default\",\n        TaskQueue: \"agent-task-queue\",\n    }),\n)\ndefer a.Close()\n\n// --- Run ---\nrun, _ := a.Run(context.Background(), \"Reply with a short greeting.\", nil)\nresult, _ := run.Get(context.Background())\nfmt.Println(result.Content)\n\n// --- Stream + reconnect ---\nstream, _ := a.Stream(context.Background(), \"Write a four-line poem about the ocean.\", nil)\nsavedRunID := stream.ID() // persist before consuming events\nevents, _ := stream.Events(context.Background())\nfor event := range events {\n    // persist event.Offset() before handling — needed for WithOffset on reconnect\n    _ = event\n}\nsavedOffset := int64(0)\ns, _ := a.GetAgentStream(context.Background(), savedRunID)\nch, _ := s.Events(context.Background(), agent.WithOffset(savedOffset))\nfor event := range ch {\n    _ = event\n}\n```\n\n**Restate** (durable execution) — import `pkg/agent/runtime/restate` (mutually exclusive with Temporal):\n\n```\nimport \"github.com/agenticenv/agent-sdk-go/pkg/agent/runtime/restate\"\n\na, _ := agent.NewAgent(\n    agent.WithSystemPrompt(\"You are a helpful assistant.\"),\n    agent.WithLLMClient(llmClient),\n    restate.WithRestateConfig(&restate.RestateConfig{\n        Ingress: restate.IngressConfig{\n            URL: \"http://localhost:8080\",\n        },\n        Endpoint: restate.EndpointConfig{\n            ListenAddress: \":9080\",\n            AdminURL:      \"http://localhost:9070\",\n        },\n    }),\n)\ndefer a.Close()\n\n// Same Run / Stream / GetAgentStream + WithOffset APIs as Temporal\n```\n\nCrashes and process restarts don't have to mean lost work or missed approvals — see [durable_agent/local](https://github.com/agenticenv/agent-sdk-go/blob/main/examples/durable_agent/local) (single process, zero infrastructure), [durable_agent/temporal](https://github.com/agenticenv/agent-sdk-go/blob/main/examples/durable_agent/temporal) (split worker), and [durable_agent/restate](https://github.com/agenticenv/agent-sdk-go/blob/main/examples/durable_agent/restate) (single process). For the stream reconnect protocol (`GetAgentStream` + `WithOffset`), see the [reconnect example](https://github.com/agenticenv/agent-sdk-go/blob/main/examples/agent_with_reconnect) and [Durable Execution](https://docs.agenticenv.ai/advanced/durable-execution). Local has no `WithOffset(n>0)` — only replay from the start, with completed steps coalesced into one message each (step granularity), not the original token-by-token stream.\n\nDownload a binary from [GitHub Releases](https://github.com/agenticenv/agent-sdk-go/releases), extract it, and put `agctl` on your `PATH`.\n\n```\nexport AGCTL_LLM_APIKEY=sk-your-key\nagctl run --model gpt-4o --prompt \"hello\"\n# or interactive\nagctl chat\n```\n\nSee the [CLI docs](https://docs.agenticenv.ai/getting-started/cli) for commands, config, and env vars.\n\n- **[Agent Chat](https://github.com/agenticenv/agent-chat)** — web chat demo with durable conversations; reference for wiring the SDK into an HTTP-backed app.\n\nRunnable examples in [examples/](https://github.com/agenticenv/agent-sdk-go/blob/main/examples) — see [examples/README.md](https://github.com/agenticenv/agent-sdk-go/blob/main/examples/README.md) for setup and run instructions.\n\nConfig-driven benchmark runner — see [benchmarks/README.md](https://github.com/agenticenv/agent-sdk-go/blob/main/benchmarks/README.md)\n\nEvaluate agent quality with Promptfoo and DeepEval — locally or in CI. See [eval-harness/README.md](https://github.com/agenticenv/agent-sdk-go/blob/main/eval-harness/README.md)\n\nSee [CONTRIBUTING.md](https://github.com/agenticenv/agent-sdk-go/blob/main/CONTRIBUTING.md) for setup, workflow, and guidelines.\nProject policies: [SECURITY.md](https://github.com/agenticenv/agent-sdk-go/blob/main/SECURITY.md) · [CODE_OF_CONDUCT.md](https://github.com/agenticenv/agent-sdk-go/blob/main/CODE_OF_CONDUCT.md)\n\nQuick commands (requires [Task](https://taskfile.dev)): `task check` | `task test` | `task lint` | `task fmt` | `task tidy` | `task test-coverage`\n\nCoverage reports (PR and default branch) are on **[Codecov](https://app.codecov.io/gh/agenticenv/agent-sdk-go)**. Run `task test-coverage` locally to produce `coverage.out` and `coverage.html`.\n\nThis project is provided \"as is\" under the Apache License 2.0. When building AI agents that execute real-world actions, ensure appropriate safeguards, validation, and human-in-the-loop approval workflows are in place. You are responsible for compliance, access control, and operational safety in your deployment. For security issues, follow [SECURITY.md](https://github.com/agenticenv/agent-sdk-go/blob/main/SECURITY.md).", "url": "https://wpnews.pro/news/show-hn-agent-sdk-go-build-crash-resilient-ai-agents-in-go", "canonical_source": "https://github.com/agenticenv/agent-sdk-go", "published_at": "2026-10-02 17:41:45+00:00", "updated_at": "2026-10-02 18:06:34.928728+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "agent-protocols", "ai-tools"], "entities": ["Agent-SDK-go", "Agentic Environment", "durable-go", "Temporal", "Restate", "OpenAI", "Anthropic", "Go"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/show-hn-agent-sdk-go-build-crash-resilient-ai-agents-in-go", "markdown": "https://wpnews.pro/news/show-hn-agent-sdk-go-build-crash-resilient-ai-agents-in-go.md", "text": "https://wpnews.pro/news/show-hn-agent-sdk-go-build-crash-resilient-ai-agents-in-go.txt", "jsonld": "https://wpnews.pro/news/show-hn-agent-sdk-go-build-crash-resilient-ai-agents-in-go.jsonld"}}