From local LLM to tool-using agent (TDS)
A Towards Data Science walkthrough that turns a locally-served LLM into a tool-using agent — a “mini deep research agent” that searches the web, gathers evidence, and synthesizes a cited answer. It is a concrete, fully-local worked example of the spoke’s “skills/tools × MCP = agency” formula. T4: a practitioner tutorial (third-party how-to), useful for the pattern it demonstrates rather than as an authority.
The stack (all interchangeable, by the author’s own framing)
- Model: Gemma 4 E4B (an edge-optimized variant).
- Local runtime: Ollama, exposing an OpenAI-compatible endpoint at
localhost:11434/v1. - Agent framework: the OpenAI Agents SDK, which wraps the local model via
OpenAIChatCompletionsModel— a sibling to the claude-agent-sdk / ADK agent runtimes. - Tools: wired through MCP servers (Tavily web search); the runtime manages MCP connections and auto-exposes each tool’s schema to the model.
The agent loop
The execution cycle is the canonical agent loop: user query → model emits tool calls → the SDK executes the MCP functions → results return to the model → model produces the final cited answer. The article traces concrete three-step sequences (function call → tool output → final message).
Why it matters here
Two things make it worth paging:
- Agency on a local model. It shows the skills/tools + MCP pattern running with no cloud model at all — an OpenAI-compatible local endpoint is enough for the Agents SDK to drive tool-calling. The agent layer is decoupled from where the tokens come from.
- Patterns over implementation. The author’s explicit thesis — “the whole stack here is not the only option” (swap Ollama for LM Studio/llama.cpp, Gemma for Qwen, the OpenAI SDK for Google/Anthropic frameworks) — matches this spoke’s own “the value is the layer, configured around the model” reading. Instruction design, tool composition, and multi-turn reasoning are the substance; the model is a replaceable part.
Cross-spoke context
The local-serving substrate is adjacency, not this spoke’s subject: Ollama as a local inference
runtime belongs to ../llm-inference-wiki, and Gemma as a model to ../llm-providers-wiki. Routed
here because the dominant substance is the agent-building pattern (MCP tool-calling + the agent loop),
not inference mechanics or the model market.
Related
model-context-protocol · agent-loops-verification · claude-agent-sdk · agentskills-spec · agent-orchestration