Skip to content
MfRs

Microsoft Agent Framework (Rust)

agent-framework-rs, a community Rust port of Microsoft Agent Framework: installation and cargo features, a first agent, what is stable and what is experimental, and how it maps to the Python and .NET SDKs.

agent-framework on crates.io is a Rust port of Microsoft Agent Framework. It follows the Python SDK’s design closely (chat clients, agents, tools, sessions, context providers, three levels of middleware, a superstep graph engine and the prebuilt orchestrations) and adds the surrounding integrations: MCP, A2A, HTTP hosting, declarative agents, memory backends, Purview and OpenTelemetry. The API is ordinary async Rust on tokio: builders for configuration, traits for extension points, serde_json::Value for workflow messages, and method pairs such as run and run_stream where Python uses a flag.

Install

Terminal window
cargo add agent-framework@0.15.0
cargo add tokio --features full

Version

agent-framework 0.15.0 (checked 2026-11-19) · Rust 1.88 or later · async on tokio

Best for

Rust services that want Agent Framework’s agent, tool and workflow model, with OpenAI, Azure, Anthropic, Gemini, Bedrock or local models, without a Python or .NET runtime.

use agent_framework::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
// Reads OPENAI_API_KEY (and OPENAI_BASE_URL, for a compatible endpoint).
let client = OpenAIChatCompletionClient::from_env("gpt-6-luna")?;
let agent = Agent::builder(client)
.name("assistant")
.instructions("You are a concise assistant. Answer in one sentence.")
.build();
let response = agent.run_once("What is the capital of France?").await?;
println!("{}", response.text());
Ok(())
}

The repository README’s quick start still uses the names ChatAgent, OpenAIClient and AiFunction (and a 0.1 version requirement); in 0.15.0 the types are Agent, OpenAIChatCompletionClient and FunctionTool, as in this guide. The comprehensive guide carries on from here.

The agent-framework crate re-exports the core crate at its root and each companion crate as a module behind a feature (agent_framework::anthropic, agent_framework::mcp, and so on). The prelude brings in the common types from every enabled feature. Only openai is on by default.

FeatureAdds
openai (default)OpenAIChatCompletionClient (Chat Completions, or any compatible endpoint), OpenAIChatClient (Responses API), OpenAIEmbeddingClient
azureAzure OpenAI chat, Responses and embedding clients; Entra ID credentials
foundryMicrosoft Foundry: FoundryChatClient, client-side prompt agents, embeddings, managed memory
anthropicClaude through the Anthropic API, Amazon Bedrock, Vertex AI or Foundry
gemini, mistral, ollama, foundry-local, bedrock, github-copilotThose providers’ chat clients (and embeddings where they offer them)
claudeClaudeAgent, which drives the Claude Code CLI as an agent
copilotstudioA published Copilot Studio agent as a SupportsAgentRun participant
mcpMCP tools over stdio, streamable HTTP and WebSocket
a2aAn A2A client (A2AAgent, A2AClient); serving A2A is part of hosting
hosting, agui-clientaxum routers for DevUI-style, OpenAI-compatible, AG-UI and A2A serving; an AG-UI chat client
foundry-hostingResponsesHostServer and the other servers that run an agent or workflow as a Foundry hosted agent
redis, mem0, cosmos, azure-ai-searchHistory stores and memory or retrieval providers
purviewPurview data-loss-prevention middleware
toolsLocal and Docker shell tools, as agent_framework::builtin_tools
file-skills, mcp-skillsSKILL.md skill packages from disk; skills served over MCP
otel-metrics, otel-export, azure-monitorGenAI metrics through the OpenTelemetry API; a ready-made OTLP exporter; export to Application Insights
qdrant, postgres, sql-server, mongodb, azure-documentdbVector stores (each implies experimental-vector-stores)
fullEvery integration above except the OpenTelemetry features, mcp-skills, and the vector stores
[dependencies]
agent-framework = { version = "0.15.0", features = ["anthropic", "azure", "mcp"] }
tokio = { version = "1", features = ["full"] }

The README’s feature tables predate several providers and omit ollama, gemini, mistral, foundry-local, bedrock, github-copilot, otel-export and experimental-session-store; the crate’s Cargo.toml and docs.rs page are the complete list. The providers page shows which names each provider feature adds to the prelude.

Upstream marks some APIs experimental (Python warns on use, .NET raises a compiler diagnostic). The port puts each of those behind a cargo feature named experimental-<id>, so using one is an explicit choice at build time. Nothing behind these features is covered by semver, full does not include them, and experimental turns them all on:

FeatureWhat it gates
experimental-declarative-agentsThe whole declarative crate: YAML/JSON agents and workflows
experimental-harnessThe agent loop (LoopAgent), todo list, standing tool approvals, agent modes, file memory and file access, durable memory, background agents, and create_harness_agent
experimental-session-storeSaving and restoring whole sessions by key (AgentSessionStore)
experimental-file-historyFileHistoryProvider
experimental-vector-storesThe vector store abstraction, vector collection tools, and the in-memory, Cosmos DB, Azure AI Search, Redis, Qdrant, PostgreSQL, SQL Server, MongoDB and Azure DocumentDB stores
experimental-progressive-toolsAdding or removing tools mid-run from function middleware
experimental-agent-hooksAllow, deny and transform hooks at the agent, model-call and tool-call seams, and Error::InterceptionBlocked
experimental-evalsevaluate_agent, evaluate_workflow, LocalEvaluator and its checks, and CI assertions on EvalResults
experimental-fidesFIDES information-flow control: integrity and confidentiality labels, label-tracking and policy-enforcement function middleware, and a quarantined LLM (agent_framework::security)
experimental-computer-useComputer-use handling: validated constructors for ComputerToolCallContent and ComputerToolResultContent, a hosted computer tool, and the tool loop returning to the caller on a pending call. The types and their Content variants are always present, whether or not the feature is on

Everything else, including the workflow engine, all orchestrations, compaction, skills, TextSearchProvider, MCP, A2A, hosting and the memory providers, is on the stable side. The rules are in the repository’s docs/feature-stages.md, which also lists the upstream experimental features with no Rust counterpart yet, such as functional workflows and MCP long-running tasks.

The crate mirrors the Python package’s module layout, so most names carry over:

Python (agent_framework)Rust (agent_framework)
Agent(client, instructions=..., tools=[...])Agent::builder(client).instructions(...).tool(...).build()
await agent.run("...", session=s)agent.run(vec![Message::user("...")], Some(&mut s)).await or agent.run_once("...")
agent.run(..., stream=True)agent.run_stream(...), a Stream of AgentResponseUpdate
@tool / FunctionToolFunctionTool::typed (schema from a schemars type) or FunctionTool::new
approval_mode="always_require".with_approval_mode(ApprovalMode::AlwaysRequire)
agent.as_tool()agent.as_tool(AsToolOptions::new())
AgentSession, InMemoryHistoryProviderAgentSession, InMemoryHistoryProvider
ContextProvider.before_run / after_runThe ContextProvider trait
Agent, chat and function middlewareMiddleware<AgentContext>, Middleware<ChatContext>, Middleware<FunctionInvocationContext>
response.valueresponse.value (JSON) or response.parse_json::<T>()
WorkflowBuilder, @executorWorkflowBuilder, FunctionExecutor or the Executor trait
SequentialBuilder … MagenticBuilderThe same names
MCPStdioTool, MCPStreamableHTTPToolMcpStdioTool, McpStreamableHttpTool, McpWebsocketTool

The differences that change how code is written:

  • Streaming is a separate method. run_stream and get_streaming_response stand in for stream=True, and runs with local tools or agent middleware stream whole messages rather than tokens.
  • Workflow messages are untyped JSON. Executors receive and send serde_json::Value; there is no handler-type routing. Edges are type-checked only where both ends declare message types by name (workflows).
  • Group chat, handoff and Magentic are single executors that call their participants in a loop, so their events carry one executor id.
  • Middleware is fixed at build time. There is no per-run middleware= argument and no decorator form.
  • Handoff tools are not injected. Attach handoff_tool_spec(...) tools to each handoff participant yourself.
  • Chat middleware runs once per agent run, around the whole tool loop, rather than once per model request as in Python.
  • Declarative workflows use a format of the port’s own, not Microsoft’s Power Fx actions; declarative agents use the official schema.
  • Some identity settings must be explicit. For example, Purview needs a tenant id and application location where Python reads them from the token.

Not ported, according to the repository’s SCOPE.md and docs/feature-stages.md: the DevUI frontend (the API is served, with a small built-in debug page), Durable Task, Azure Functions, the Foundry agentserver’s resilient task runtime, functional workflows, ChatKit, sandboxed code execution and the Power Fx declarative workflow language. The crate has no MCP server either (as_mcp_server in Python); the MCP page shows a minimal hand-written one. Most topic pages close with what is missing in their area.