local-ai-agents
Skill này làm gì
Skill này chỉ cách xây dựng một agent AI chạy hoàn toàn trên máy tính cá nhân. Nó dành cho người muốn quyền riêng tư, chi phí thấp hơn hoặc làm việc mà không phụ thuộc vào cloud.
Khi nào nên dùng
- ✓Khi bạn muốn một agent chạy trên máy tính của mình vì quyền riêng tư, chi phí hoặc khi offline.
- ✓Khi bạn muốn dùng Foundry Local với một model Qwen có thể gọi hàm.
- ✓Khi bạn muốn tìm kiếm tài liệu cục bộ hoặc một máy chủ MCP cục bộ cho agent.
Liên kết skill
https://github.com/microsoft/ai-agents-for-beginners/blob/main/.agents/skills/local-ai-agents/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy xây dựng cho tôi một agent chạy trên laptop mà không gửi dữ liệu lên cloud, và có thể tìm trong tài liệu của tôi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thiết lập một model cục bộ nhỏ có thể gọi các công cụ đơn giản, như đọc file hoặc tìm tài liệu. Model chọn công cụ nào để dùng, còn phần việc nặng do các công cụ đảm nhiệm.
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.
Creating Local AI Agents with Foundry Local and Qwen
Companion skill for Lesson 17 – Creating Local AI Agents. Use it to help a learner build an agent that reasons, calls tools, and searches documentation entirely on their own machine — no cloud inference. Ground every recommendation in the lesson content and the runnable notebook.
Triggers
Activate this skill when a learner wants to:
- Run an agent fully on-device for privacy, cost, or offline reasons.
- Serve a model locally with Foundry Local and connect via the OpenAI-compatible endpoint.
- Use a Qwen function-calling model to drive reliable local tool calls.
- Add local RAG (Chroma) or a local MCP server.
- Design a hybrid local/cloud routing strategy.
Core mental model
An SLM trades breadth for privacy, cost, and offline operation. The winning
strategy: let the SLM orchestrate and let tools do the heavy lifting. The
model does not need to know the codebase — it needs to know when to call
read_file and search_docs. That plays to an SLM's strength (bounded decisions
like tool selection) and away from its weakness (broad knowledge, long multi-hop
reasoning).
Why these specific pieces
- Foundry Local exposes an OpenAI-compatible HTTP endpoint, so cloud agent code transfers by changing only
base_url(and using a local placeholder API key). It also auto-selects the best build (CPU/GPU/NPU) for the machine. - Qwen models are trained for function calling and emit well-formed tool calls consistently — this is what turns a local chat model into a local agent.
- Chroma runs in-process and stores vectors on disk, so the whole RAG pipeline (embed → store → retrieve → reason) stays local.
- MCP is a transport, not a cloud service: an MCP server can run locally over
stdio.
Setup essentials
foundry model run qwen2.5-7b-instruct
foundry service status
from foundry_local import FoundryLocalManager
from openai import OpenAI
manager = FoundryLocalManager("qwen2.5-7b-instruct")
client = OpenAI(base_url=manager.endpoint, api_key=manager.api_key) # local placeholder
~8 GB RAM is a realistic minimum; a GPU/NPU helps but is not required.
Key patterns to reproduce
Point the learner at the notebook
17-local-agent-foundry-local.ipynb:
- Sandboxed tools: every file tool resolves paths and rejects anything outside a single project root — even locally, a tool runs with the user's permissions.
- Tool-calling loop: register tools with the OpenAI tools schema, execute requested tools locally, feed results back, repeat until a final answer.
- Local RAG: upsert docs into a Chroma collection;
search_docsreturns top-k chunks. - Local MCP: connect to a local server over
stdio; scope it to a project directory and validate its outputs.
Hybrid routing (local as one of the models)
| Situation | Where it runs |
|---|---|
| Sensitive data / offline | Local SLM |
| Simple, bounded task | Local SLM (cheap, fast) |
| Hard multi-hop reasoning on non-sensitive data | Cloud model |
| Cloud outage | Local SLM (graceful degradation) |
This mirrors the model-routing idea from Lesson 16, with the workstation as one of the routes. Prefer designs that fall back to local so the agent degrades in quality rather than failing outright.
Guardrails for the assistant
- Keep every file/tool operation scoped to a sandboxed project directory.
- Do not send code or data to the cloud when the learner's stated goal is privacy/offline — keep the whole pipeline local.
- Set realistic expectations for SLM quality; lean on tools and RAG rather than the model's memorised knowledge.
- Note that Lesson 17 has no Foundry Responses endpoint, so the cloud smoke-test action does not apply — validate by running the notebook locally.
Câu hỏi thường gặp
Nó có chạy được mà không cần cloud không?
Skill tập trung vào việc chạy agent hoàn toàn trên máy của bạn, không có suy luận trên cloud.
Model cục bộ nhỏ có mạnh như model cloud không?
Model nhỏ yếu hơn về kiến thức rộng, nên skill để công cụ đảm nhận phần việc nặng.
Nó có thể kết hợp model cục bộ và cloud không?
Có. Nó mô tả định tuyến lai giữa model cục bộ và model cloud.
Chi tiết
Mô tả gốc của tác giả
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the privacy/cost/offline trade-offs. Based on Lesson 17 of AI Agents for Beginners. USE FOR: run an agent locally, offline agent, on-device agent, Foundry Local, Qwen function calling, local tool calling, local RAG, Chroma vector database, local MCP server, privacy-preserving agent, hybrid l
Độ phổ biến
- Sao GitHub
- 79k
- Vị trí xếp hạng
- #1726
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
azure-openai-to-responses
79kGiúp agent của bạn chuyển một ứng dụng Python từ Azure OpenAI Chat Completions sang Responses API mới hơn, từng bước một.
deploying-scalable-agents
79kGiúp agent của bạn chuyển một agent AI đang chạy tốt thành môi trường production có thể mở rộng và được giám sát trên Microsoft Foundry.
jupyter-notebook
79kGiúp agent của bạn tạo hoặc dọn gọn các notebook Jupyter cho thí nghiệm hoặc hướng dẫn từng bước, bằng các template có sẵn.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.