How to Create Local AI Agents wit Foundry Local and Qwen
Skill wey go help for Lesson 17 – Creating Local AI Agents.
Use am to help person wey dey learn build agent wey sabi reason, dey call tools, and dey search
documentation all na inside dem machine — no cloud inference. Make every
recommendation stand gidigba for lesson content and the runnable notebook.
Triggers
Activate this skill when person wey dey learn want:
- Run agent fully inside device for privacy, cost, or offline reasons.
- Serve model locally with Foundry Local and connect via the OpenAI-compatible endpoint.
- Use Qwen function-calling model to make local tool calls correct.
- Add local RAG (Chroma) or local MCP server.
- Design hybrid local/cloud routing way.
Core mental model
Small Language Model (SLM) dey trade wide knowledge for privacy, cost, and offline work. The best
way: make the SLM dey organize and make tools carry the heavy work. The
model no need to know the codebase — e need to know wen to call
read_file and search_docs. Dis one dey play to SLM strength (small decisions
like tool choice) and avoid hin weakness (big knowledge, long multi-hop
reasoning).
Why these specific pieces
- Foundry Local get OpenAI-compatible HTTP endpoint, so cloud agent code fit transfer by just changing
base_url(and using local fake API key). E also dey choose best build (CPU/GPU/NPU) for machine. - Qwen models get epp to call functions and always dey give correct tool calls — na dis one make local chat model become local agent.
- Chroma dey run inside process and dey store vectors for disk, so all RAG work (embed → store → retrieve → reason) remains local.
- MCP na transport, no be cloud service: MCP server fit run local with
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) # lokal plassholder
About 8 GB RAM na minimum wey make sense; GPU/NPU fit help but dem no mandatory.
Key patterns wey you fit repeat
Show the learner the notebook