ADR-0010: Local models run in-process with transformers, as an optional extra¶
- Status: Accepted
- Date: 2026-12-01
Context¶
SPEC-015 adds Hugging Face models. Hosted models are one more OpenAI-compatible preset
(ADR-0005). Running a model on the user's own machine has several options: ask users to start a
server (Ollama, vLLM, llama.cpp) and use chat_api, which already works; or load the model in
AgentPlay's own Python process with the transformers library. A server works well on a
desktop, but on Colab it needs a background process and often a public tunnel, and every
server has its own setup.
Decision¶
- Add a
transformersagent that loads the model in the same process, installed with the optional extraagentplaykit[hf]. The core and the other agents keep needing no extra packages. - Do not install PyTorch through the extra: the right build depends on the computer (CPU, CUDA
version, Apple). Tell the user exactly how to install it when it is missing, and have
doctorshow what is installed and which devices are available. - Load each model once per process and share it between agents and runs, and load it before the run starts, so time limits measure play, not downloads.
- Load safetensors weights only and never run repository code, unless the scenario opts in for that model, with a notice.
- Use the same prompt and reply parser as every other model agent, applied through the model's own chat template, so local and hosted models are compared fairly.
Consequences¶
- One
pip installand a model id are enough to play on Colab or a GPU machine: no server, no tunnel, no key for open models. - Users who already run Ollama or vLLM keep using
chat_api; nothing changes for them. - First use downloads gigabytes of weights; the notice says which model and how big.
- Results on the same hardware repeat exactly with greedy decoding and a pinned revision; across different GPUs they may differ slightly.
- CI tests use a fake
transformersmodule; a small live test with CPU-only PyTorch checks the real library.