go-micro README

The project's README from github.com/micro/go-micro. As one markdown file: README.md.

Go Micro Go.Dev reference

Go Micro is an agent harness and service framework for Go.

Overview

A harness is the runtime around an agent: the tools it can call, the memory it keeps, the guardrails that bound it, the workflows that trigger it, the services it depends on, and the protocols other agents use to reach it.

Go Micro gives you the harness as Go code. Build an agent and it gets a model, memory, tools, planning, delegation, guardrails, and service discovery; it is reachable over MCP and A2A. Write services and every endpoint becomes an AI-callable tool. Orchestrate the deterministic parts with durable flows. Agents, services, and flows share one runtime because an agent is a distributed system, and building one is building a service.

See it

Describe a system and Go Micro designs the services, writes the handlers, compiles them, starts them, and gives you an agent to talk to:

$ micro run --prompt "a task management system with categories"

Services:
  ● task — Task management with status tracking
  ● project — Project organization

Generate? [Y/n]

> Create a project called Launch, then add three tasks to it

→ project_Project_Create({"name":"Launch"})
→ task_Task_Create({"title":"Design specs","project_id":"p1..."})
→ task_Task_Create({"title":"Write code","project_id":"p1..."})
→ task_Task_Create({"title":"Ship it","project_id":"p1..."})

Created project Launch and added three tasks to it.

And when the agent needs a capability that doesn't exist, it builds the service mid-conversation:

> I need to track shipping. Create a shipment for order 123 to London.

  ⚡ generating shipping service...
  ✓ shipping
  → shipping_Shipping_Create({"order_id":"123","destination":"London"})

  Created shipment for order 123 going to London.

The generated code is plain Go on disk — edit it by hand at any time; re-running preserves your changes. No key? The no-secret path below works without any provider.

Sponsors

Want to support Go Micro and see your logo here? Become a sponsor — reach out on Discord.

Contents

Quick Start

Install the CLI:

# Binary (no Go required)
curl -fsSL https://go-micro.dev/install.sh | sh

# Or with Go
go install go-micro.dev/v6/cmd/micro@latest

If install or PATH checks fail, use the install troubleshooting guide.

Fastest start — no API key

Scaffold a service, run it, call it:

micro new helloworld
cd helloworld
micro run

Then in another terminal:

curl -X POST http://localhost:8080/api/helloworld/Helloworld.Call \
  -H 'Content-Type: application/json' -d '{"name":"World"}'

Prefer Docker? The micro image (Docker Hub micro/micro or ghcr.io/micro/go-micro) bundles the CLI:

docker run --rm -it micro/micro new helloworld
docker run --rm -it --network host -v "$(pwd)":/micro/helloworld micro/micro run

First agent on-ramp

New to agents? The shortest path, in order — every step works without a provider key:

  1. Verify the install — the install troubleshooting guide covers PATH, micro --version, and first-run checks. (make docs-wayfinding keeps these steps aligned with the installed CLI.)
  2. Run the built-in demo — micro agent demo prints the provider-free first-agent walkthrough, and micro agent quickcheck prints the short recovery map if a step stalls; micro examples and micro zero-to-hero print the runnable examples and the one-command lifecycle harness. Start from the smallest first-agent example or the examples wayfinding index.
  3. Build your own — follow No-secret first agent (mock model, no key), then Your First Agent, and talk to it with micro chat.
  4. When something's off — micro agent preflight before micro run, micro agent doctor after; the debugging guide walks the full recovery path, and micro inspect agent <name> recovers run history, memory, and provider checks. The 0→hero reference then closes the loop — services → agents → workflows — with the maintained support example as the reference app.

Generate from a prompt — with an LLM key

The See it transcript above is real. Set a provider key and run it:

export ANTHROPIC_API_KEY=sk-ant-...   # or OPENAI_API_KEY, GEMINI_API_KEY, ...
micro run --prompt "a task management system with categories" --provider anthropic

The AI designs the architecture, you review it, then it generates handlers with real business logic, compiles them, and starts them — and the console drops you into a conversation with your running system. Read more.

Why an Agent Harness

The first wave of agent frameworks helped developers put a model in a loop. The next problem is operating that loop: connecting it to real tools, scoping what it can touch, preserving state, routing work to specialists, recovering from failures, observing what happened, and letting other agents call it. That is harness work.

Go Micro's answer is to make the harness the same thing you already deploy:

Use Go Micro when the agent has to operate a system, not just answer a prompt.

Writing Services

Under the hood, a service is a struct with methods. Doc comments and @example tags become tool descriptions for AI agents automatically.

package main

import (
    "context"

    "go-micro.dev/v6"
)

type Request struct {
    Name string `json:"name"`
}

type Response struct {
    Message string `json:"message"`
}

type Say struct{}

// Hello greets a person by name.
// @example {"name": "Alice"}
func (h *Say) Hello(ctx context.Context, req *Request, rsp *Response) error {
    rsp.Message = "Hello " + req.Name
    return nil
}

func main() {
    service := micro.NewService("greeter")
    service.Handle(new(Say))
    service.Run()
}

Run it and everything is accessible — REST, gRPC, MCP, agent playground:

micro run
# Dashboard:   http://localhost:8080
# API:         http://localhost:8080/api/{service}/{method}
# Agent:       http://localhost:8080/agent
# MCP Tools:   http://localhost:8080/mcp/tools

You can also scaffold a service from a template:

micro new helloworld
micro new contacts --template crud

Building Agents

An Agent is a service with an LLM inside it. It has a proto-defined Agent.Chat RPC endpoint, registers in the registry, and is callable like any service:

agent := micro.NewAgent("task-mgr",
    micro.AgentServices("task", "project"),
    micro.AgentPrompt("You manage tasks and projects. You understand deadlines and priorities."),
    micro.AgentProvider("anthropic"),
)
agent.Run()

The agent discovers its services from the registry, scopes its tools to their endpoints, and maintains conversation memory in the store. It registers itself so micro chat and other agents can find it.

// Programmatic interaction
resp, _ := agent.Ask(ctx, "What tasks are overdue?")
fmt.Println(resp.Reply)

Multiple agents coordinate via RPC — each is a service with an Agent.Chat endpoint. micro chat routes to the right one.

micro agent list                    # list registered agents
micro call task-mgr Agent.Chat '{"message": "What tasks are overdue?"}'

Plan & Delegate

Every agent gets two built-in harness capabilities, exposed as tools — no extra setup or separate graph runtime:

This keeps intelligence distributed: an agent doesn't need to know how to do everything, only who does. See examples/agent-plan-delegate.

// A sub-agent is just an agent — created with New, talked to with Ask.
// delegate-first: reuse a registered agent, or spin up a focused one.
resp, _ := agent.Ask(ctx, "Plan the launch, create the tasks, and have comms notify the owner.")

Batteries included, pluggable

Just as a service composes pluggable abstractions (registry, broker, store), an agent composes a model, memory, and tools — sane defaults out of the box, each swappable.

agent := micro.NewAgent("assistant",
    micro.AgentProvider("anthropic"),                 // model — swap the provider
    micro.AgentCompactMemory(40, 12),                 // memory — durable, summarized, recallable
    micro.AgentTool("weather", "Get the weather for a city",
        map[string]any{"city": map[string]any{"type": "string"}},
        func(ctx context.Context, in map[string]any) (string, error) {
            return getWeather(in["city"].(string))    // tools beyond your services — any function
        }),
    micro.AgentMaxSteps(8),                            // guardrails
)

Memory is durable and store-backed by default (Postgres, NATS KV, or file), so an agent restores its conversation history after a restart — or supply your own with AgentMemory. Long-running agents can opt into AgentCompactMemory(maxMessages, keepRecent): older turns are collapsed into a deterministic summary, recent turns stay verbatim, and relevant archived turns are recalled on future asks without replaying the whole conversation. Tools are your services automatically, plus any function you register with AgentTool.

Conversation recovery is separate from execution recovery: interrupted agent runs need an explicit AgentWithCheckpoint and resume call. Flow steps resume from successfully saved boundaries; an interrupted step may execute again. See Durability and Recovery for storage requirements, retry semantics, tool replay, and the exactly-once and multi-replica limitations.

Paid tools (x402)

Every endpoint is an AI-callable tool — and it can be a paid tool. Go Micro supports x402, the HTTP 402 payment standard for agents, so a tool can require a stablecoin payment and an agent can settle it autonomously. It's opt-in and carries no crypto in the framework: verification is delegated to a pluggable facilitator (Coinbase, Alchemy, self-hosted), so Base and Solana are just different facilitators.

# Charge for tool calls at the MCP gateway (off unless you set a pay-to address)
micro mcp serve --x402_pay_to 0xYourAddress --x402_network solana --x402_amount 10000
# Per-tool amounts via a config file
micro mcp serve --x402_config x402.json

See the Payments (x402) guide.

Reachable by other agents (A2A)

Within a Go Micro system, agents reach each other over RPC. To make them reachable by agents on other frameworks, Go Micro speaks the Agent2Agent (A2A) protocol. The A2A gateway discovers your agents from the registry, generates an Agent Card for each from its metadata — the same way the MCP gateway derives tools from service endpoints — and translates incoming A2A tasks to the agent's Agent.Chat RPC. No per-agent code: register an agent and it's reachable over A2A.

micro a2a serve --address :4000    # gateway: expose every registered agent over A2A
micro a2a list                     # agents and their Agent Card URLs

Or skip the gateway entirely — an agent can serve its own A2A endpoint directly, handling tasks in-process:

micro.NewAgent("task-mgr", micro.AgentServices("task"), micro.AgentA2A(":4000"))

It works both ways. To call an agent on another framework, an a2a.Client is wired into the two places that hand off work: flow.A2A(url) as a workflow step (the cross-framework Dispatch), and delegate to an http(s) URL from inside an agent.

MCP exposes your services as tools; A2A exposes your agents as agents. See the A2A guide.

Features

AI

Feature Details
Agents micro.NewAgent() — intelligent layer that manages services
Plan & delegate Built-in agent tools — plan multi-step work, delegate subtasks to other agents
Pluggable memory Durable store-backed conversation memory by default; swap with AgentMemory
Custom tools AgentTool — give an agent any function as a tool, beyond its services
Guardrails MaxSteps (stop on count), LoopLimit (stop repeated no-progress calls), ApproveTool (human-in-the-loop)
Tool middleware AgentWrapTool — wrap tool execution for logging, metrics, or retries (like client/server wrappers)
Workflows micro.NewFlow() — event-driven; one step, ordered durable steps, or triggers an agent
Durable execution Flow steps resume from saved boundaries with a persistent store; interrupted steps can repeat, pluggable backend
MCP gateway Every endpoint is an AI tool automatically
A2A gateway Every agent is reachable over the Agent2Agent protocol; cards generated from the registry (micro a2a)
Payments (x402) Opt-in per-call payments for tools via the x402 standard; pluggable facilitator (Base, Solana, …)
9 LLM providers Anthropic, OpenAI, Gemini, Groq, Mistral, Together, Atlas Cloud, MiniMax, Ollama (local + cloud)
Interactive console micro run includes a chat console for talking to services
Service generation micro run --prompt — describe a system, get running services

Framework

Feature Details
Service registry mDNS (default), Consul, etcd
RPC client/server gRPC transport, load balancing, streaming
Pub/sub events NATS, RabbitMQ, HTTP broker
Key-value store File (bbolt), Postgres, NATS KV
Typed model layer CRUD + queries, SQLite/Postgres backends
Everything swappable All abstractions are Go interfaces

Developer experience & deployment

Feature Details
Hot reload micro run watches files, rebuilds on change
Templates micro new --template crud/pubsub/api
One-command deploy micro deploy user@server — SSH + systemd, no Docker

CLI

Command Purpose
micro run --prompt "..." Generate services + agent, start with interactive console
micro run Dev mode: hot reload, gateway, interactive console
micro run -d Detached mode (no console)
micro chat Standalone chat (when not using micro run)
micro agent list List registered agents
micro new myservice Scaffold a service
micro call service endpoint '{}' Call a service or agent from the CLI
micro build Compile production binaries
micro deploy user@server Deploy via SSH + systemd

Multi-Service Projects

Run multiple services together:

users := micro.NewService("users", micro.Address(":9001"))
orders := micro.NewService("orders", micro.Address(":9002"))

users.Handle(new(Users))
orders.Handle(new(Orders))

g := micro.NewGroup(users, orders)
g.Run()

Or use a micro.mu config file:

service users
    path ./users

service orders
    path ./orders
    depends users

AI Providers

Swap providers with a single import — same interface everywhere:

Provider Default Model
Anthropic claude-sonnet-4-20250514
OpenAI gpt-4o
Google Gemini gemini-2.5-flash
Groq llama-3.3-70b-versatile
Mistral mistral-large-latest
Together AI meta-llama/Llama-3.3-70B-Instruct-Turbo
Atlas Cloud deepseek-ai/DeepSeek-V3-0324
MiniMax MiniMax-M3
Ollama llama3.2 (local)
m := model.New("anthropic", model.WithAPIKey(key))
resp, _ := m.Generate(ctx, &model.Request{Prompt: "hello"})

Examples

New to agents? Follow the first-agent on-ramp, then use the examples index for the full services → agents → workflows map.

See all examples.

Autonomous improvement loop

Go Micro maintains itself with the same services → agents → workflows lifecycle it ships: a scheduled loop of AI agents opens issues, writes increments, and merges CI-gated PRs, with a human setting direction. micro loop scaffolds that loop for your own repository — a North Star, ranked issue queue, role prompts, GitHub Actions workflows, and verification:

micro loop init --roles all
micro loop verify

See the micro loop quickstart for the setup checklist (dispatch token, branch protection, seeded priorities) and operating model.

Community

Questions, ideas, or just want to build alongside us? Join the Discord.

Commercial Support

Running Go Micro in production, or building on it and want help? Paid support, consulting, training, and retainers are available directly from the maintainer — and they're what keep the project maintained. See Support for the tiers, or open a request.

Docs

Every path in this README is guarded by CI: make install-smoke verifies install → first run, make inner-loop verifies scaffold → run/chat/inspect → deploy dry-run, make zero-to-hero-transcript verifies the ordered 0→hero lifecycle, and make harness runs the broader local contract.

Package reference: https://pkg.go.dev/go-micro.dev/v6

go-micro (micro/go-micro)

Searching Database…

23.1K ·GitHub
这是什么?Go Micro 是一个面向 Go 的智能体框架和服务框架——它是围绕智能体(包括其工具、记忆、防护规则、工作流和服务)的一层运行时,智能体、服务和持久化流程都共享同一个运行时。
它是一个 Go 框架,还是一个命令行工具?两者都是:服务、智能体和流程都是你编写并导入的 Go 代码,而 micro CLI 负责生成项目脚手架(micro new)、以热重载和交互式控制台的方式运行它们(micro run),并且一条命令即可部署。
我怎么把它跑起来?先安装 micro CLI,然后执行 micro new myservice 和 micro run(开发模式带热重载和聊天控制台)。最快的上手方式不需要任何 API 密钥,官方还提供了一个内置 CLI 的 Docker 镜像。
试用它需要 LLM API 密钥吗?不需要。无密钥路径不依赖任何模型服务商——你可以在 mock 模型上生成并运行服务、搭建第一个智能体。只有想通过提示词生成服务时才需要服务商的密钥;一共支持 9 家服务商。
如果一个智能体运行到一半被打断了会怎样?执行恢复是显式的:被打断的智能体运行需要 AgentWithCheckpoint 和一次 resume 调用才能继续。流程步骤会从已保存的边界恢复,被打断的步骤可能会再执行一次——恰好一次(exactly-once)语义和多副本的限制在文档中都有说明。
什么时候我该选 Go Micro,而不是更简单的智能体框架?当智能体要操作一个真实的系统,而不只是回答一段提示词时:你的服务端点会变成 AI 可调用的工具,智能体之间可以像服务一样互相注册和发现,而且防护规则(MaxSteps、LoopLimit、ApproveTool)就在动作实际发生的地方生效。
智能体开箱即用能得到什么?一个模型、重启后依然保留的持久化存储记忆(Postgres、NATS KV 或文件)、来自你服务的工具以及任意 AgentTool 函数,还有两个内置的工具:plan 用于多步骤任务,delegate 用于通过 RPC 把子任务交给其他智能体。
支持哪些 LLM 服务商?九家,只需一个 import 即可切换:Anthropic、OpenAI、Google Gemini、Groq、Mistral、Together AI、Atlas Cloud、MiniMax,以及用于 llama3.2 等本地模型的 Ollama。
用其他框架的智能体怎么调用我的智能体?通过 Agent2Agent(A2A)协议:网关会发现已注册的智能体,为每个智能体生成一张 Agent Card,并把 A2A 任务转换为 Agent.Chat——不需要为每个智能体单独写代码。MCP 也以同样的方式把你的服务端点暴露为工具。
一个工具可以就某次调用向智能体收费吗?可以,通过 x402 可选择开启:端点可以要求一笔稳定币支付,由智能体自主完成结算。验证会交给可插拔的 facilitator(Coinbase、Alchemy 或自托管),所以 Base 和 Solana 只是不同的 facilitator 而已——框架本身不含任何加密货币相关内容。
Creator
micro
Size
39.9 MB
Stars
23.1K
Age
11y
Commits · 90 Days