Skip to content
MfGo

Microsoft Agent Framework (Go)

Go 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

Terminal window
go get github.com/microsoft/agent-framework-go@v0.3.1

Version

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.

ConceptGo APINotes
Agent*agent.AgentBuilt by a provider constructor such as openaiprovider.NewAgent or foundryprovider.NewAgent; all share one type.
Runa.RunText, a.RunMessage, a.RunEach returns an agent.ResponseStream (an iter.Seq2[*agent.ResponseUpdate, error]). Call .Collect() for a single *agent.Response.
Run optionsagent.Stream, agent.WithSession, agent.WithTool, agent.WithStructuredOutput, agent.WithInstructionsPassed variadically to every run method.
Session*agent.SessionHolds conversation history and provider state; JSON-serialisable.
Messagesmessage.Message, message.ContentsTyped content parts: TextContent, FunctionCallContent, FunctionResultContent, ToolApprovalRequestContent, DataContent and more.
Function toolfunctool.New / functool.MustNewTyped Go function; the JSON schema is derived from the input struct.
Middlewareagent.Middleware, agent.FunctionInvocationMiddlewareWrap whole runs, or individual tool calls.
Context provideragent.NewContextProviderInjects instructions, messages or tools before a run and stores state after it (memory, RAG).
Workflowworkflow.NewBuilder, inproc.DefaultGraph 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:

  • Handoff and Magentic orchestrations. Sequential, concurrent and round-robin group chat exist; handoff and Magentic do not (see Orchestrations for a custom routing manager in place of handoff).
  • Declarative (YAML/JSON) agents and workflows.
  • Functional workflows (the Python @workflow / @step style). Graph workflows only.
  • CodeAct, DevUI and AF Labs.
  • Foundry hosted-agent deployment. You can call existing server-side Foundry agents, but not deploy one from Go.
  • There is no evaluation package comparable to Python’s 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.