Chuyển đến nội dung
Skillpedia
Agent40k · #7208

foundry-hosted-agent-copilotkit

Skill này làm gì

Công cụ này giúp kết nối một ứng dụng web xây dựng bằng React (dùng CopilotKit) với một “agent” thông minh (xây dựng bằng Microsoft Agent Framework) chạy trên dịch vụ trả phí của Microsoft gọi là Foundry. Nó hỗ trợ giao tiếp giữa hai bên để tạo ra các ứng dụng nâng cao hơn.

Khi nào nên dùng

  • ✓Khi xây dựng một ứng dụng web mới cần một agent thông minh.
  • ✓Khi thêm hoặc sửa một agent thông minh trong ứng dụng web đang có.
  • ✓Khi bạn muốn ứng dụng web dùng các tính năng AI nâng cao như phê duyệt và lịch sử hội thoại.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/foundry-hosted-agent-copilotkit/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để kết nối ứng dụng React của tôi dùng CopilotKit với một agent thông minh trên Microsoft Foundry?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ thiết lập giao tiếp giữa ứng dụng React của bạn (CopilotKit) và agent thông minh (Microsoft Agent Framework) bằng một giao thức gọi là AG-UI. Nó dùng các dịch vụ của Microsoft (Foundry) để lưu trữ agent và quản lý cuộc hội thoại.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.

…

Câu hỏi thường gặp

“Agent” là gì?

Agent là một chương trình máy tính có thể thực hiện tác vụ, hiểu lệnh và tương tác với bạn, giống như một trợ lý ảo.

Microsoft Foundry là gì?

Foundry là dịch vụ của Microsoft cho phép bạn lưu trữ và quản lý các agent thông minh trên đám mây, để ứng dụng của bạn truy cập được.

CopilotKit là gì?

CopilotKit là thư viện cho React giúp dễ dàng xây dựng giao diện trò chuyện và tích hợp với các agent thông minh trong ứng dụng web.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7208
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự