Install
go get github.com/microsoft/agent-framework-go@v0.3.1Go implementation of Microsoft Agent Framework (public preview) — agents, function tools, OpenAI / Azure OpenAI / Foundry / Anthropic / Gemini providers, MCP, A2A, graph workflows and testing with a fake provider.
The Go implementation of Microsoft Agent Framework. It shares the concepts of the Python and .NET SDKs — agents, sessions, tools, middleware, context providers and graph workflows — but expresses them as idiomatic Go: plain structs for configuration, context.Context everywhere, and iter.Seq2 streams instead of async enumerables.
Install
go get github.com/microsoft/agent-framework-go@v0.3.1Version
github.com/microsoft/agent-framework-go v0.3.1 (checked 2026-11-19) · requires Go 1.26+ (the module’s go directive; with GOTOOLCHAIN=auto the toolchain is fetched for you)
Best for
Go services that need agents with tools, Azure / Foundry integration, MCP or A2A interop, and checkpointed multi-step workflows.
package main
import ( "context" "fmt" "log"
"github.com/microsoft/agent-framework-go/agent" "github.com/microsoft/agent-framework-go/provider/openaiprovider" "github.com/openai/openai-go/v3")
func main() { // openai.NewClient reads OPENAI_API_KEY from the environment. a := openaiprovider.NewAgent(openai.NewClient(), openaiprovider.AgentConfig{ Model: "gpt-6-luna", Instructions: "You are a concise assistant. Answer in one sentence.", Config: agent.Config{Name: "Helper"}, })
ctx := context.Background()
// Non-streaming: Collect gathers every update into one *agent.Response. resp, err := a.RunText(ctx, "What is a goroutine?").Collect() if err != nil { log.Fatal(err) } fmt.Println(resp.String())
// Streaming: range over the ResponseStream. for update, err := range a.RunText(ctx, "Name three Go proverbs.", agent.Stream(true)) { if err != nil { log.Fatal(err) } fmt.Print(update.String()) } fmt.Println()}The upstream README’s quickstart uses Microsoft Foundry instead; see Providers.
| Concept | Go API | Notes |
|---|---|---|
| Agent | *agent.Agent | Built by a provider constructor such as openaiprovider.NewAgent or foundryprovider.NewAgent; all share one type. |
| Run | a.RunText, a.RunMessage, a.Run | Each returns an agent.ResponseStream (an iter.Seq2[*agent.ResponseUpdate, error]). Call .Collect() for a single *agent.Response. |
| Run options | agent.Stream, agent.WithSession, agent.WithTool, agent.WithStructuredOutput, agent.WithInstructions | Passed variadically to every run method. |
| Session | *agent.Session | Holds conversation history and provider state; JSON-serialisable. |
| Messages | message.Message, message.Contents | Typed content parts: TextContent, FunctionCallContent, FunctionResultContent, ToolApprovalRequestContent, DataContent and more. |
| Function tool | functool.New / functool.MustNew | Typed Go function; the JSON schema is derived from the input struct. |
| Middleware | agent.Middleware, agent.FunctionInvocationMiddleware | Wrap whole runs, or individual tool calls. |
| Context provider | agent.NewContextProvider | Injects instructions, messages or tools before a run and stores state after it (memory, RAG). |
| Workflow | workflow.NewBuilder, inproc.Default | Graph of executors with conditional edges, fan-out, request ports (human in the loop) and checkpoints. |
Compared with the Python guide, the following are not implemented in v0.3.1, according to the upstream README:
@workflow / @step style). Graph workflows only.evaluate_agent, and no dedicated Ollama or Amazon Bedrock provider (these two points come from the module’s package list rather than the README). An OpenAI-compatible Chat Completions endpoint, such as Ollama’s, can still be used through openaiprovider.NewChatCompletionsAgent with an openai.NewClient(option.WithBaseURL(...)) client.What it does have, beyond the basics: Anthropic, Gemini, GitHub Copilot, A2A and AG-UI providers; agent skills; chat-history memory and text-search (RAG) context providers; compaction; an agent “harness” (Todo planning, modes, standing tool approvals, file memory); vector stores with in-memory and Azure AI Search connectors; and OpenTelemetry middleware.
examples/01-get-started is a five-step tutorial)docs/dotnet-go-sdk-feature-comparison.md in the repository