# Local LLM host

A fourth install target: the Codex CLI engine pointed at a model served from
this machine, in a tree of its own. `npx @mmerterden/multi-agent-pipeline
install --local` writes `~/.codex-local/` and leaves `~/.codex/` untouched.

## Why a separate tree rather than a profile

The engine keeps its model binding in agent files under its own home. Two
installs sharing one home means the second silently retunes the first, and a
run started on one answers on the other's model. A profile would also open a
second dimension every consumer has to ask about, which is the name-based
branching the host registry exists to remove. So the local target is a host
record like any other, in the host registry: id `local`, root `.codex-local`.

## What the server has to be

Not "any OpenAI-compatible server". The engine speaks the OpenAI **Responses**
API and no other: `wire_api = "chat"` is refused when the config loads, and both
the custom-provider path and `--oss --local-provider` send `POST /v1/responses`.
A server that offers only `/v1/chat/completions` cannot answer.

Ollama serves `/v1/responses` from v0.13.3, with streaming and tool calling, and
the engine requires v0.13.4 or newer. Whether another local server qualifies is
a question about that server, and the answer is which endpoint it serves.

## What the user chooses

The registry is packaged data: it names install roots and argv, so it is not
extensible. Two values are the user's and live in preferences:

```json
{
  "global": {
    "localModel": {
      "baseUrl": "http://127.0.0.1:11434/v1",
      "model": "qwen3-coder",
      "contextWindow": 131072
    }
  }
}
```

Both are validated before either reaches a config file or an agent file
(`lib/local-model.mjs`, and `doctor` check `local-model`):

- `baseUrl` is loopback unless `allowRemote` is set. The base URL is where every
  prompt in a run goes, so an address off this machine is an explicit decision
  rather than a typo that happened to resolve.
- `model` is a narrow character set, because the value is written into a TOML
  file.
- `contextWindow` is required and not guessed. A one-turn request already
  carries about 45 KB of instructions before the task, and a phase spec is
  larger again; a window set too small truncates the diff and the run reports on
  a file it never saw.

Until a model is recorded, agents are written with no model at all and children
inherit the session's. That is the one answer that cannot be wrong.

## What the run looks like

| | Local LLM host |
|---|---|
| Rungs | all four collapse to the one model; no reasoning effort |
| Review panel | one reviewer, triage on the same model |
| Children at once | 1 |
| Price | zero per token; the ledger still counts tokens, so a run is comparable with one that cost money |
| Network | optional |
| Autopilot | not offered |

The engine still attempts a request to its vendor's telemetry host. Denying it
does not stop a run, but "offline" means the model is local, not that the
process makes no outbound request.

## The honest limit

Quality drops, and this host says so. One reviewer instead of three means less
disagreement to triage, and a smaller model reads a diff less carefully. The
profile claims the pipeline runs, not that it runs as well.

## Gates

`pipeline/scripts/smoke-local-host.sh` covers the registry shape, the
preference refusals (an address off this machine, a model name carrying shell
syntax, a window too small, a non-http scheme), a live install that keeps to its
own tree, and the agent binding with and without a configured model. No model is
started there, so nothing in it claims a local model produces usable work.
