Local ai agents

From microsoft/ai-agents-for-beginners · View interactive version

Local ai agents is an AI agent skill from the GitHub repository microsoft/ai-agents-for-beginners. 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 routi

How to use this skill

Skill file

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:

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

Setup essentials

foundry model run qwen2.5-7b
foundry service status
from foundry_local_sdk import Configuration, FoundryLocalManager  # foundry-local-sdk 2.x
from openai import OpenAI

FoundryLocalManager.initialize(Configuration(app_name="ai_agents_for_beginners"))
manager = FoundryLocalManager.instance
model = manager.catalog.get_model("qwen2.5-7b")
if not model.is_cached:
    model.download()
model.load()
manager.start_web_service()
client = OpenAI(base_url=manager.urls[0].rstrip("/") + "/v1", api_key="not-required")  # 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

CODE0:

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.