Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问clear审计提醒

microsoft-agent-framework微软 Agent 框架

Agent Skill

microsoft-agent-framework 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

5,666

周安装

227

GitHub Stars

55

下载量

1,834
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:microsoft-agent-framework(微软 Agent 框架)
来源仓库:https://github.com/rysweet/amplihack
仓库路径:skills/microsoft-agent-framework
安装命令:
npx skills add https://github.com/rysweet/amplihack --skill microsoft-agent-framework
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/rysweet/amplihack --skill microsoft-agent-framework

简介

用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 适用于关键词搜索、任务场景匹配或来源线索筛选等研究检索场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 安装前需确认权限范围、维护状态,以及是否会触发联网或文件读写操作。
  • microsoft-agent-framework 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Microsoft Agent Framework Skill

Version: 0.1.0-preview | Last Updated: 2025-11-15 | Framework Version: 0.1.0-preview Languages: Python 3.10+, C# (.NET 8.0+) | License: MIT

Quick Reference

Microsoft Agent Framework is an open-source platform for building production AI agents and workflows, unifying AutoGen's simplicity with Semantic Kernel's enterprise features.

Core Capabilities: AI Agents (stateful conversations, tool integration) | Workflows (graph-based orchestration, parallel processing) | Enterprise features (telemetry, middleware, MCP support)

Installation:

  • Python: pip install agent-framework-core --pre
  • C#: dotnet add package Microsoft.Agents.AI --prerelease

Repository: https://github.com/microsoft/agent-framework (5.1k stars)


When to Use This Skill

Use Microsoft Agent Framework when you need:

  1. Production AI Agents with enterprise features (telemetry, middleware, structured outputs)
  2. Multi-Agent Orchestration via graph-based workflows with conditional routing
  3. Tool/Function Integration with approval workflows and error handling
  4. Cross-Platform Development requiring both Python and C# implementations
  5. Research-to-Production Pipeline leveraging AutoGen + Semantic Kernel convergence

Integration with amplihack: Use Agent Framework for stateful conversational agents and complex orchestration. Use amplihack's native agent system for stateless task delegation and simple orchestration. See @integration/decision-framework.md for detailed guidance.


Core Concepts

1. AI Agents

Stateful conversational entities that process messages, call tools, and maintain context.

Python Example:

from agents_framework import Agent, ModelClient

# Create agent with model
agent = Agent(
    name="assistant",
    model=ModelClient(model="gpt-4"),
    instructions="You are a helpful assistant"
)

# Single-turn conversation
response = await agent.run(message="Hello!")
print(response.content)

# Multi-turn with thread
from agents_framework import Thread
thread = Thread()
response = await agent.run(thread=thread, message="What's 2+2?")
response = await agent.run(thread=thread, message="Double that")

C# Example:

using Microsoft.Agents.AI;

var agent = new Agent(
    name: "assistant",
    model: new ModelClient(model: "gpt-4"),
    instructions: "You are a helpful assistant"
);

var response = await agent.RunAsync("Hello!");
Console.WriteLine(response.Content);

2. Tools & Functions

Extend agent capabilities by providing callable functions.

Python Example:

from agents_framework import function_tool

@function_tool
def get_weather(location: str) -> str:
    """Get weather for a location."""
    return f"Weather in {location}: Sunny, 72°F"

agent = Agent(
    name="assistant",
    model=ModelClient(model="gpt-4"),
    tools=[get_weather]
)

response = await agent.run(message="What's the weather in Seattle?")
# Agent automatically calls get_weather() and responds with result

C# Example:

[FunctionTool]
public static string GetWeather(string location)
{
    return $"Weather in {location}: Sunny, 72°F";
}

var agent = new Agent(
    name: "assistant",
    model: new ModelClient(model: "gpt-4"),
    tools: new[] { typeof(Tools).GetMethod("GetWeather") }
);

3. Workflows

Graph-based orchestration for multi-agent systems with conditional routing and parallel execution.

Python Example:

from agents_framework import Workflow, GraphWorkflow

# Define workflow graph
workflow = GraphWorkflow()

# Add agents as nodes
workflow.add_node("researcher", research_agent)
workflow.add_node("writer", writer_agent)
workflow.add_node("reviewer", review_agent)

# Define edges (control flow)
workflow.add_edge("researcher", "writer")  # Sequential
workflow.add_edge("writer", "reviewer")

# Conditional routing
def should_revise(state):
    return state.get("needs_revision", False)

workflow.add_conditional_edge(
    "reviewer",
    should_revise,
    {"revise": "writer", "done": "END"}
)

# Execute workflow
result = await workflow.run(initial_message="Research AI trends")

C# Example:

var workflow = new GraphWorkflow();

workflow.AddNode("researcher", researchAgent);
workflow.AddNode("writer", writerAgent);
workflow.AddNode("reviewer", reviewAgent);

workflow.AddEdge("researcher", "writer");
workflow.AddEdge("writer", "reviewer");

var result = await workflow.RunAsync("Research AI trends");

4. Context & State Management

Maintain conversation history and shared state across agents.

Python:

from agents_framework import Thread, ContextProvider

# Thread maintains conversation history
thread = Thread()
await agent.run(thread=thread, message="Remember: My name is Alice")
await agent.run(thread=thread, message="What's my name?")  # "Alice"

# Custom context provider
class DatabaseContext(ContextProvider):
    async def get_context(self, thread_id: str):
        return await db.fetch_history(thread_id)

    async def save_context(self, thread_id: str, messages):
        await db.save_history(thread_id, messages)

agent = Agent(model=model, context_provider=DatabaseContext())

5. Middleware & Telemetry

Add cross-cutting concerns like logging, auth, and monitoring.

Python:

from agents_framework import Middleware
from opentelemetry import trace

# Custom middleware
class LoggingMiddleware(Middleware):
    async def process(self, message, next_handler):
        print(f"Processing: {message.content}")
        response = await next_handler(message)
        print(f"Response: {response.content}")
        return response

# OpenTelemetry integration
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("agent-run"):
    response = await agent.run(message="Hello")

C#:

public class LoggingMiddleware : IMiddleware
{
    public async Task<Message> ProcessAsync(Message message, Func<Message, Task<Message>> next)
    {
        Console.WriteLine($"Processing: {message.Content}");
        var response = await next(message);
        Console.WriteLine($"Response: {response.Content}");
        return response;
    }
}

Common Patterns

Human-in-the-Loop Approval

from agents_framework import HumanInTheLoop

@function_tool
def delete_file(path: str) -> str:
    """Delete a file (requires approval)."""
    return f"Deleted {path}"

# Add approval wrapper
delete_file_with_approval = HumanInTheLoop(
    tool=delete_file,
    approval_prompt="Approve deletion of {path}?"
)

agent = Agent(tools=[delete_file_with_approval])

Parallel Agent Execution

workflow = GraphWorkflow()

# Add multiple agents
workflow.add_node("analyst1", analyst_agent)
workflow.add_node("analyst2", analyst_agent)
workflow.add_node("synthesizer", synthesis_agent)

# Parallel execution
workflow.add_edge("START", ["analyst1", "analyst2"])  # Both run in parallel
workflow.add_edge(["analyst1", "analyst2"], "synthesizer")  # Wait for both

result = await workflow.run(message="Analyze market trends")

Structured Output Generation

from pydantic import BaseModel

class WeatherReport(BaseModel):
    location: str
    temperature: float
    conditions: str

agent = Agent(
    model=model,
    instructions="Generate weather reports",
    response_format=WeatherReport
)

response = await agent.run(message="Weather in Seattle")
report: WeatherReport = response.parsed
print(f"{report.location}: {report.temperature}°F, {report.conditions}")

Error Handling & Retries

from agents_framework import RetryPolicy

agent = Agent(
    model=model,
    retry_policy=RetryPolicy(
        max_retries=3,
        backoff_factor=2.0,
        exceptions=[TimeoutError, ConnectionError]
    )
)

try:
    response = await agent.run(message="Hello")
except Exception as e:
    print(f"Failed after retries: {e}")

Integration with amplihack

Decision Framework

Use Microsoft Agent Framework when:

  • Building stateful conversational agents (multi-turn dialogue)
  • Need enterprise features (telemetry, middleware, auth)
  • Complex multi-agent orchestration with conditional routing
  • Cross-platform requirements (Python + C#)
  • Integration with Microsoft ecosystem (Azure, M365)

Use amplihack native agents when:

  • Stateless task delegation (code review, analysis)
  • Simple sequential/parallel orchestration
  • File-based operations and local tooling
  • Rapid prototyping without infrastructure
  • Token-efficient skill-based architecture

Hybrid Approach:

# Use amplihack for orchestration
from claude import Agent as ClaudeAgent

orchestrator = ClaudeAgent("orchestrator.md")

# Delegate to Agent Framework for stateful agents
from agents_framework import Agent, Thread

conversational_agent = Agent(
    model=ModelClient(model="gpt-4"),
    instructions="Maintain conversation context"
)

thread = Thread()
response1 = await conversational_agent.run(thread=thread, message="Start task")
response2 = await conversational_agent.run(thread=thread, message="Continue")

# Use amplihack for final synthesis
result = orchestrator.process({"responses": [response1, response2]})

See @integration/amplihack-integration.md for complete patterns.


Quick Start Workflow

  1. Install: pip install agent-framework-core --pre (Python) or dotnet add package Microsoft.Agents.AI --prerelease (C#)
  2. Create Basic Agent: from agents_framework import Agent, ModelClient agent = Agent(name="assistant", model=ModelClient(model="gpt-4"), instructions="You are a helpful assistant") response = await agent.run(message="Hello!")
  3. Add Tools: @function_tool def calculate(expr: str) -> float: return eval(expr) agent = Agent(model=model, tools=[calculate])
  4. Build Workflow: workflow = GraphWorkflow() workflow.add_node("agent1", agent1) workflow.add_node("agent2", agent2) workflow.add_edge("agent1", "agent2") result = await workflow.run(message="Task")
  5. Add Telemetry: from opentelemetry import trace tracer = trace.get_tracer(__name__) with tracer.start_as_current_span("agent-run"): response = await agent.run(message="Hello")

Reference Documentation

For detailed information, see:

  • @reference/01-overview.md - Architecture, components, use cases
  • @reference/02-agents.md - Agent creation, lifecycle, advanced features
  • @reference/03-workflows.md - Workflow patterns, executors, checkpointing
  • @reference/04-tools-functions.md - Tool definition, approval workflows, error handling
  • @reference/05-context-middleware.md - Context providers, middleware patterns, auth
  • @reference/06-telemetry-monitoring.md - OpenTelemetry, logging, debugging
  • @reference/07-advanced-patterns.md - Multi-agent patterns, streaming, DevUI

Working Examples

  • @examples/01-basic-agent.py - Simple conversational agent
  • @examples/02-tool-integration.py - Agent with function calling
  • @examples/03-simple-workflow.py - Multi-agent workflow
  • @examples/04-basic-agent.cs - C# agent implementation
  • @examples/05-tool-integration.cs - C# tool integration
  • @examples/06-simple-workflow.cs - C# workflow example

Maintenance

Check framework freshness: python @scripts/check-freshness.py

Current version tracking: @metadata/version-tracking.json


Token Count: ~4,200 tokens (under 4,800 limit)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.81%
按下载量换算528

Antigravity

20.46%
按下载量换算375

OpenCode

18.12%
按下载量换算332

Gemini CLI

12.27%
按下载量换算225

Cursor

7.53%
按下载量换算138

windsurf

3.66%
按下载量换算67

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills