Agents

An agent combines a model, instructions, and tools. Service endpoints become its tools, so you can use the same operations from code and conversation.

Create an agent

Keep the notes service running. In your project, create cmd/assistant/main.go:

package main

import (
    "log"
    "os"

    micro "go-micro.dev/v6"
)

func main() {
    agent := micro.NewAgent("assistant",
        micro.AgentProvider("openai"),
        micro.AgentAPIKey(os.Getenv("OPENAI_API_KEY")),
        micro.AgentServices("notes"),
        micro.AgentPrompt("Use the notes service to answer questions about notes."),
    )
    if err := agent.Run(); err != nil {
        log.Fatal(err)
    }
}

Start it in a second terminal with your provider key:

export OPENAI_API_KEY=your-key
go run ./cmd/assistant

Use it

Wait for the agent to register, then in a third terminal:

micro chat

With assistant as the only registered agent, chat connects to it. Ask:

What notes do I have?

The agent can call Notes.List and answer using its result. Check the tool activity to see that the service was called. This uses your model provider and incurs its normal API charges.

Use /agents to check the connection. If other agents are running, micro chat assistant connects to this one explicitly.

Your Go code controls the provider, instructions, and allowed services. Change those options to build your own agent. For programmatic calls, the agent exposes Ask(ctx, message); see the agent API.

Next: coordinate work with a workflow →