ADR-0027: External model provider — models run in a local server the user already has, not inside Roteiro

StateFor Review
Architectural SignificanceVERY HIGH
DomainInference
Document version0.3

Reference

Supersedes the in-process engine of ADR-0006 and the GGUF half of the model store in ADR-0003. Amends ADR-0005 (vision moves to the provider, OCR does not), ADR-0015 (producer identity of a model Roteiro did not pin), and ADR-0019 (which endpoint is egress). Configured through ADR-0007.

Summary

Roteiro stops running models and stops storing the GGUF models it ran. Every generative, embedding, vision and audio call goes to an OpenAI-compatible server the user already runs on this machine — Ollama, llama-server, LM Studio — named once as [provider] base_url.

Three things are kept, and they are the substance of the decision as much as the removals are:

  1. roteiro serve's /v1 endpoint stays. It becomes a graph-tools layer in front of the provider rather than a model host. The value it adds — graph tools in the conversation, the Ask panel — was never llama.cpp's.
  2. OCR stays in-process. ocrs is pure Rust and is not a language model; no provider serves it. roteiro model pull survives, narrowed to OCR weights.
  3. Audio transcription stays, served by a provider that accepts audio input. Ollama does not; llama-server does, so the setup guide names it for that one task.

Context

llama.cpp is the largest third-party surface Roteiro carries. It needs cmake and a loadable libclang at build time, it panics in a build script without them, and docs/VENDORED_DEPENDENCIES.md records published upstream advisories for it that cargo audit cannot see. Every hour spent on its batch sizing, prefix cache, speculative decoding and context budgets is an hour spent keeping pace with projects whose whole job that is.

Users who want local models already run one of those projects. Asking them to pull a second copy of the same weights into ~/.roteiro/models — in a format and at a quantisation Roteiro chose — is a cost with no matching benefit.

Every consumer already talks to a model through one seam: crates/rto-llama/src/engine.rs#Engine. An HTTP implementation of that trait replaces the in-process one without changing the consumers' shape.

Decision makers

The Roteiro Project Team. D1–D3 below were decided by the project owner on 2026-10-30.

1. One provider, named by URL, loopback by default

[provider] base_url names the server, e.g. http://127.0.0.1:11434/v1. A credential, if the server wants one, is an environment variable and never a config key, for ADR-0019 §3's reason: roteiro.toml is committed.

Amended by ADR-0028 (v0.2): a non-loopback https:// base_url is accepted from any layer and announced on every run; plaintext to another machine is refused. As first written, this section refused every non-loopback base_url until ADR-0019's gate covered it.

There is no reachability probe at startup. Whether the server answers is discovered by the first call, which names the URL when it fails.

2. [models] values become provider model ids

[models] generative = "qwen3:8b" names a model the provider serves. Roteiro no longer validates the name against a registry, because it no longer owns the list. [models] ocr is the exception and still names a registry entry.

3. Tools travel natively; the loop above the engine does not change

Amended in v0.3. The provider engine reports that it does carry tools (crates/roteiro/src/provider.rs#ProviderEngine). The request's tools go on the wire as OpenAI tools, and the delta.tool_calls the provider streams back are handed to the tool loop as the <tool_call>{…}</tool_call> text it already parses. The loop, its grounding rules and its one-call-per-turn reading are unchanged.

v0.1–0.2 kept tools in the prompt, on the argument that this keeps the protocol identical across providers instead of depending on whether a server parses a given model's tool-call dialect. Measurement refuted it (#971). Ollama runs its own qwen tool-call parser on the generated text whether or not it was sent tools. It claims the <tool_call> the prompt asked for and, with no tools to match, deletes it: the reply arrives empty, or the stream ends without a finish reason. scripts/tool-choice-accuracy.py scored 0/13 on qwen3.8:27b. The dependency on the server's parser was there either way; sending tools is what makes that parser work for the call rather than against it.

4. Model identity is what the provider can attest

A registry model was pinned by digest. A provider tag such as qwen3:8b is a mutable pointer. Media producer identity (ADR-0015) records the provider URL and model id, plus the provider's digest where it exposes one, and a producer with no digest is graded accordingly rather than presented as pinned.

5. Typed answers read logprobs

Typed questions read the label-token distribution. Over HTTP that is top_logprobs, capped at the top 20 tokens, so option_mass and the margin become approximations of what the in-process engine measured, and the figures recorded before this ADR are not comparable to those after it. A provider that returns no logprobs is refused by name rather than answered with a guess.

Options considered + consequences

OptionVerdict
External provider, keep /v1, OCR and audioRecommended. Removes the C++ surface; keeps every user-visible capability.
External provider, drop /v1Rejected (D1). The graph tools and Ask panel are Roteiro's value and are pure Rust.
External provider, drop audioRejected (D3). Costs a capability to avoid one line of setup.
Keep llama.cpp for audio onlyRejected. Keeps the whole toolchain and advisory surface for one task.
Keep the status quoViable, at the costs in Context.

Consequences

Status

For Review. Implementation lands in steps: the provider engine and /v1 first, then each consumer, then the removal of the in-process engine and the GGUF registry. Until the removal step, a build with serve still carries llama.cpp and uses it when [provider] base_url is unset.

Version history

VersionDateChange
0.12026-10-30Initial. Records D1 (keep /v1), D2 (keep OCR weights) and D3 (keep transcription via an audio-capable provider).
0.22026-11-11§1 amended by ADR-0028: a hosted https:// provider is allowed and announced; the loopback-only rule is withdrawn.
0.32026-11-13§3 reversed (#971): the provider engine sends tools natively and reads delta.tool_calls back as <tool_call> text. Keeping tools in the prompt was measured to fail on Ollama, whose qwen parser deletes a prompt-text call it was given no tools for (0/13 on the tool-choice fixture).