← All Labs Lab 01 / 28 Serve a local model through Mycel
Lab 01 · Run models · Proposed

Serve a local model through Mycel

A model running on your own machine dials into Mycel as a supplier and answers a pi tool-calling turn through the same endpoint as hosted models.

Proposed Needs: chat, streaming, tool-calling Source: examples/01-local-model-on-mycel

Not built yet. PROMPT.md is the prompt to build it from.

The point of this lab is that local and hosted models look the same to an agent. A machine such as the M4 Max or the Jetson Thor serves an open-weight model with Ollama, llama-swap or MLX, umwelten supplier probes what it can really do and dials out to a Mycel Exchange, and the agent asks for mycel:<model> like any other. Every other lab, and the coding bench, can then run on that machine without changes.

What it tests

  • Probe vs. claim: do the capabilities the supplier advertises (chat, streaming, tool-calling) match what a real pi turn needs?
  • One endpoint: does resolvePiModel(parseModelSpecString("mycel:<local model>")) answer a tool-calling turn routed to the local box?
  • Headroom: what does the supplier report for concurrency, and does a second request queue or run in parallel? (Ollama serializes at c=1; llama-swap batches. See reports/2026-07-26-headroom-ollama-does-not-batch.md.)

Before you build

  • packages/supplier/ (dial.ts, probe.ts, headroom.ts, offers.ts) and umwelten supplier --help.
  • packages/pi/src/models.ts for the ollama, llamaswap and mlx endpoints and the mycel provider.
  • The hardware recipes on the site's Local page, synced from The-Focus-AI/local-model-labs-m4-max and -thor.

Prompt

Coding-Agent Prompt · Ready to Paste
Build a lab under `examples/01-local-model-on-mycel/` showing that a model served on this machine reaches an agent through Mycel exactly like a hosted model.

Read first: `packages/supplier/src/` (`dial.ts`, `probe.ts`, `headroom.ts`, `offers.ts`, `command.ts`), `packages/mycel/` (how the Exchange registers supplier offers and dispatches by capability and guarantee), `packages/pi/src/models.ts` (`ollama`, `llamaswap`, `mlx` endpoints; the `mycel` provider; `resolvePiModel`, `runPiTurn`), and `examples/04-mycel-exchange/run.ts` for booting a local Exchange.

Requirements:
1. `run.ts` boots a local Mycel Exchange on loopback with an in-memory store and a funded end user, starts the supplier against a local runtime (`--runtime ollama|llamaswap|mlx`, default ollama at its usual port), lets it probe and dial in, and prints the offers it published with their probed capabilities and headroom.
2. It then runs a two-step tool-calling turn with `runPiTurn` on `mycel:<offered model>` (a small `lookup` tool) and prints the answer, the tool call, tokens, tok/s and the micro-dollar charge.
3. It sends two concurrent requests and reports whether they ran in parallel or queued.
4. Offline (`--smoke` with no local runtime reachable): use a scripted OpenAI-compatible fake runtime on loopback so every check still runs. With a runtime reachable, `--smoke` uses it. `--exchange <url>` dials into an existing Exchange such as https://mycel.thefocus.ai instead of booting one.
5. `--smoke` checks: the supplier's offers list tool-calling only if the probe saw a tool call; the pi turn routed through Mycel reached the local runtime; the tool was called and the answer used its result; the charge was recorded; concurrency was measured. PASS/FAIL lines, exit 0 only if all pass.
Strict TypeScript, no `any`, everything closed in `finally`. Write what you learn about each runtime into FINDINGS.md.
Works in Pi, Claude Code, Codex & Antigravity Offline mock first → --live opt-in