跳到正文
Skillpedia
智能体40k · #7208

foundry-hosted-agent-copilotkit

它能做什么

这个工具可以帮助你把一个用 React(配合 CopilotKit)构建的 Web 应用,连接到一个用 Microsoft Agent Framework 构建、运行在微软付费云服务 Foundry 上的“智能体”。它让两者之间能够顺畅通信,从而打造功能更强大的应用。

适用场景

  • ✓当你要构建一个需要智能体的新 Web 应用时。
  • ✓当你要在现有 Web 应用中添加或修改智能体时。
  • ✓当你希望 Web 应用使用审批、对话历史等高级 AI 功能时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/foundry-hosted-agent-copilotkit/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/foundry-hosted-agent-copilotkit/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我该如何将使用 CopilotKit 的 React 应用连接到 Microsoft Foundry 上的智能体?”

每周 5 个新技能,1 分钟读完。

工作原理

该工具使用一种名为 AG-UI 的协议,在你的 React 应用(CopilotKit)和智能体(Microsoft Agent Framework)之间建立通信。它使用微软的服务(Foundry)来托管智能体并管理对话。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

CopilotKit + AG-UI + Microsoft Foundry hosted agents

Use this skill when a React/Next.js app uses CopilotKit and talks over AG-UI to a Microsoft Agent Framework (MAF) agent hosted in Microsoft Foundry. This covers new builds and changes to existing apps. Foundry hosted agents are a paid Azure service.

Scaffold the agent with azd ai agent init and the frontend with your usual React/Next.js tooling. Then follow this skill for everything that connects them.

Mental model

React (CopilotKit v2)        CopilotKitProvider / CopilotChat threadId=<conv_ id> / useInterrupt
      │ HTTP
CopilotKit runtime           CopilotRuntime({ agents: { default: new HttpAgent({ url }) } })
      │ AG-UI (SSE)
AG-UI gateway (FastAPI)      add_agent_framework_fastapi_endpoint(app, AgentFrameworkAgent(FoundryAgent(...),
                               use_service_session=True, service_session_id_from_thread_id=True))   ← keeps no thread state
      │ OpenAI Responses + Entra token (https://ai.azure.com/.default)
Foundry hosted agent         ResponsesHostServer(Agent(tools=[...]))  ← deployed with azd

A deployed hosted agent does not speak AG-UI. It exposes .../agents/<name>/endpoint/protocols/openai/responses (Responses protocol) or .../protocols/invocations. Translate with MAF's own adapter (FoundryAgent + agent-framework-ag-ui) instead of writing an SSE translator by hand. Browsers cannot hold the Entra token, so the gateway is always server-side.

Use the platform first

Before you write any plumbing, check this table. Each row is something older codebases built by hand.

Need Native primitive (don't hand-roll)
Conversation history across turns and restarts Foundry conversations: create one per chat, use its conv_… ID as the AG-UI thread ID, and the gateway passes it through (no snapshot store)
Durable tool approvals ResponsesHostServer persists approval requests by default (FoundryFunctionApprovalStore). The AG-UI adapter turns them into AG-UI interrupts and forwards decisions back to the hosted agent
Runs that survive browser disconnects Responses background: true + store: true, then poll or reconnect (see wiring)
Durable multi-step workflows with gates Invocations hosted agent + @multi_turn_task + FoundryStateStore
Per-user files for the agent Session Files API; the agent reads $HOME with its own tools. Never inline large documents into the prompt
Long-term user memory Foundry Memory Store (user scope) or FoundryMemoryProvider
Tool catalogs, web search, code interpreter Foundry Toolbox (FoundryToolbox) with Tool Search, instead of listing every tool up front
Live docs while coding The Microsoft Learn and Foundry MCP servers (bundled with this skill's plugin)

Choose the wiring

If the app needs… Use Gateway size
Hosted agent + chat + tools + approvals (default) A. AG-UI gateway over a Responses hosted agent ~50 lines of Python
Every state pattern, local prototype, no Foundry compute B. In-process AG-UI (agent runs inside the FastAPI app) ~15 lines
Background runs that keep going after disconnect, reconnect, per-user conversation lists C. Background-runs gateway (custom AG-UI agent over Foundry conversations) ~150 lines of TypeScript
Multi-step plan → approve → execute, irreversible steps that must not run twice D. Invocations hosted agent alongside A or C REST proxy

Code for each is in references/wiring.md. In an existing codebase, identify the wiring before you change anything:

  • FoundryAgent(...) wrapped by add_agent_framework_fastapi_endpoint means A.
  • Agent(client=...) wrapped directly means B.
  • A custom AbstractAgent calling /responses with background means C.
  • protocol: invocations in azure.yaml means D.

Workflow

  1. Pick or identify the wiring (table above).

  2. Use the latest release of every package (@copilotkit/*, @ag-ui/*, agent-framework-*, azd and its azure.ai.agents extension). Then ground on live sources:

    • the Microsoft Learn MCP server for MAF and Foundry
    • the Foundry MCP server for project state
    • docs.copilotkit.ai and the .d.ts files bundled in the installed @copilotkit/* packages
    • docs.ag-ui.com

    APIs move between minor versions, so don't trust memorized names.

…

常见问题

什么是“智能体”?

智能体是一种可以执行任务、理解指令并与你互动的计算机程序,就像一个虚拟助手。

什么是 Microsoft Foundry?

Foundry 是微软提供的一项服务,让你可以在云端托管和管理智能体,并让你的应用能够调用它们。

什么是 CopilotKit?

CopilotKit 是一个用于 React 的库,可以让你轻松构建聊天界面,并在 Web 应用中集成智能体。

详情

作者的原始描述

Build and evolve agentic web apps that pair a CopilotKit React frontend with a Microsoft Agent Framework agent running as a Microsoft Foundry hosted agent, connected over the AG-UI protocol. Covers choosing the wiring, using Foundry-native primitives instead of hand-rolled plumbing, agent tools, human-in-the-loop approvals, generative UI and shared state, local run and azd deploy, debugging the ev

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7208
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能