@octocodeai/freellama-mcp-server 0.1.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONFIGURATION.md +108 -0
- package/DEVELOPING.md +109 -0
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +18 -0
- package/README.md +261 -243
- package/assets/logo.jpg +0 -0
- package/dist/index.js +2305 -1332
- package/dist/research/bash-agent.js +2435 -0
- package/dist/research/octocode-agent.js +1639 -0
- package/docs/ARCHITECTURE.md +294 -87
- package/docs/CLI.md +171 -53
- package/docs/CPU_GPU_ROUTING.md +69 -23
- package/docs/MODEL_SELECTION.md +126 -3
- package/docs/MONITORING.md +293 -0
- package/docs/PRODUCTION.md +53 -25
- package/docs/README.md +36 -0
- package/docs/SCOPES_AND_WARMING.md +225 -0
- package/docs/TESTING.md +113 -8
- package/native/index.d.ts +186 -150
- package/native/index.js +3 -3
- package/package.json +15 -11
- package/adapters/agent_context.py +0 -663
- package/adapters/agent_transport.py +0 -84
- package/adapters/bash_agent.py +0 -370
- package/adapters/octocode_agent.py +0 -394
- package/docs/ADR_RESOURCE_AWARE_BACKEND_ROUTING.md +0 -55
- package/docs/ECONOMICS.md +0 -105
- package/docs/INDEX.md +0 -15
- package/docs/OLLAMA_SIDECAR.md +0 -76
- package/docs/OLLAMA_SYSTEM_OPTIMIZATION.md +0 -254
- package/docs/PRODUCT_POSITIONING.md +0 -291
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
# Ollama and FreeLlama optimization boundary
|
|
2
|
-
|
|
3
|
-
Ollama already owns inference optimization. FreeLlama can improve completed
|
|
4
|
-
work per hour by choosing an eligible model and avoiding unnecessary model
|
|
5
|
-
changes, but it does not make an individual model decode faster.
|
|
6
|
-
|
|
7
|
-
This page explains the active request flow, the settings Ollama owns, the
|
|
8
|
-
current machine audit, and the optimization work that remains.
|
|
9
|
-
|
|
10
|
-
The architecture is portable across Ollama's Metal, CUDA, ROCm, Vulkan, and CPU paths. The audit
|
|
11
|
-
later on this page is intentionally Mac-specific. FreeLlama discovers host RAM per operating system
|
|
12
|
-
and keeps device selection in each Ollama process; it does not translate one machine's memory tier,
|
|
13
|
-
core count, or benchmark into another machine's defaults.
|
|
14
|
-
|
|
15
|
-
## Decision
|
|
16
|
-
|
|
17
|
-
Use stock Ollama as the inference runtime. Keep FreeLlama as an optional Rust
|
|
18
|
-
control plane for evidence-qualified routing, bounded request profiles, session
|
|
19
|
-
affinity, and policy enforcement.
|
|
20
|
-
|
|
21
|
-
Do not advertise FreeLlama as an accelerator or an Ollama inference plugin. It does not tune
|
|
22
|
-
kernels, split one model's layers across CPU and GPU, manage macOS memory pressure, or improve that
|
|
23
|
-
model's tokens per second. It can assign different models to isolated CPU and GPU-capable Ollama
|
|
24
|
-
processes, allowing independent workloads to overlap.
|
|
25
|
-
|
|
26
|
-
## Request flow
|
|
27
|
-
|
|
28
|
-
FreeLlama has four distinct paths:
|
|
29
|
-
|
|
30
|
-
| Request | FreeLlama work | Ollama work | Result |
|
|
31
|
-
|---|---|---|---|
|
|
32
|
-
| Native `/api/*` or `/v1/*` | Streams bytes to the primary compatibility upstream | Performs normal inference and scheduling | Exact Ollama response |
|
|
33
|
-
| `POST /_freellama/v1/routes` | Discovers models, filters capabilities, and applies policy | Supplies installed-model and residency data | Model and request profile; no inference |
|
|
34
|
-
| `POST /_freellama/v1/natural-routes` | Normalizes a schema-bound intent, then runs the deterministic router | Runs the small intent model | Model and request profile; selected task does not run |
|
|
35
|
-
| `POST /_freellama/v1/tasks` | Selects a route and backend, applies managed-task admission, and constructs one bounded request | Runs one nonstreaming chat or embedding request on the assigned process | Route receipt, placement, admission mode, prompt-free metrics, and Ollama response |
|
|
36
|
-
|
|
37
|
-
The natural-language path is intentionally two-stage. The small model cannot
|
|
38
|
-
name a final model. It returns only a task, objective, context hint, and tool or
|
|
39
|
-
vision requirements. Deterministic guards correct explicit requirements before
|
|
40
|
-
the ordinary router selects a model.
|
|
41
|
-
|
|
42
|
-
Calling `natural-routes` does not run the selected task. A client must use the
|
|
43
|
-
returned profile or submit a structured `tasks` request. There is no atomic
|
|
44
|
-
natural-language route-and-run endpoint in the current release.
|
|
45
|
-
|
|
46
|
-
Chat and embedding tasks forward route options. A captured-upstream contract
|
|
47
|
-
test verifies embedding option parity.
|
|
48
|
-
|
|
49
|
-
## What Ollama already optimizes
|
|
50
|
-
|
|
51
|
-
Across supported backends, Ollama provides the following behavior without FreeLlama:
|
|
52
|
-
|
|
53
|
-
- The runtime selects supported acceleration such as Metal, CUDA, ROCm, or Vulkan from the host and
|
|
54
|
-
its process-level device visibility.
|
|
55
|
-
- The scheduler fits model, context, and compute allocations to available
|
|
56
|
-
device memory.
|
|
57
|
-
- The runner selects CPU threads and GPU execution; applications do not need to
|
|
58
|
-
divide one inference manually between the CPU and GPU.
|
|
59
|
-
- Ollama manages request queues plus model loading and eviction. It supports
|
|
60
|
-
same-model parallel requests when memory permits.
|
|
61
|
-
- Ollama reports token counts plus load, prompt-processing, and generation
|
|
62
|
-
durations in API responses.
|
|
63
|
-
- Ollama supports request-specific context length and model residency through
|
|
64
|
-
`num_ctx` and `keep_alive`.
|
|
65
|
-
|
|
66
|
-
Ollama's documented concurrency controls are global server settings. Increasing
|
|
67
|
-
`OLLAMA_NUM_PARALLEL` multiplies context memory by the parallel-request count.
|
|
68
|
-
Increasing `OLLAMA_MAX_LOADED_MODELS` does not create memory; models still need
|
|
69
|
-
to fit. Use `1` for both values on an unmeasured deployment, then increase one variable at a time
|
|
70
|
-
only when a representative concurrent benchmark improves completed tasks per hour without memory
|
|
71
|
-
pressure.
|
|
72
|
-
|
|
73
|
-
Keep three signals distinct when operating FreeLlama: `context_window_fit` only compares requested
|
|
74
|
-
context with advertised model context; FreeLlama's K/V preflight is a conservative metadata lower
|
|
75
|
-
bound; and a completed runner is the only placement observation. None is live free-memory or
|
|
76
|
-
throughput proof. `doctor {view:"scheduler"}` reports configuration and a point-in-time admission
|
|
77
|
-
snapshot, not a fairness or parallel-decoding benchmark.
|
|
78
|
-
|
|
79
|
-
FreeLlama's admission queue and Ollama's internal queue solve different problems. FreeLlama limits
|
|
80
|
-
weighted managed work per backend and applies `--max-queue-wait-seconds`; `OLLAMA_MAX_QUEUE` bounds
|
|
81
|
-
requests that an Ollama process has accepted but cannot schedule. Raw compatibility traffic skips
|
|
82
|
-
FreeLlama admission and reaches the primary Ollama queue directly.
|
|
83
|
-
|
|
84
|
-
Ollama request context and research-adapter context are also separate budgets. Managed tasks set
|
|
85
|
-
request-specific `num_ctx` from the selected task profile. The coding adapters fit their tool
|
|
86
|
-
conversation inside `FREELLAMA_AGENT_NUM_CTX`: by default, they preserve the system prompt and
|
|
87
|
-
original question, compact the oldest observations first, retain recent evidence, and fail before
|
|
88
|
-
the Ollama call if pinned content cannot fit. Raising the Ollama server's global context does not
|
|
89
|
-
disable adapter compaction or increase its configured budget. See [Agent adapters](../AGENTS.md)
|
|
90
|
-
for the complete pagination and compaction contract.
|
|
91
|
-
|
|
92
|
-
## Current Mac audit
|
|
93
|
-
|
|
94
|
-
This audit captures the following snapshot from September 1, 2026. Treat it as machine
|
|
95
|
-
evidence, not a portable default.
|
|
96
|
-
|
|
97
|
-
| Item | Observed value | Interpretation |
|
|
98
|
-
|---|---|---|
|
|
99
|
-
| Hardware | Apple M4 Pro, 14 CPU cores, 48 GB unified memory | CPU and GPU share the memory system |
|
|
100
|
-
| macOS | 15.7.2 | Native Ollama supports this Apple-silicon system |
|
|
101
|
-
| Ollama server | 0.33.2 | Active application server on `127.0.0.1:11434`; re-read with `doctor` rather than trusting this row |
|
|
102
|
-
| First CLI on `PATH` | `/usr/local/bin/ollama`, 0.33.2 | Matches the active server |
|
|
103
|
-
| Metal device budget | 36 GiB reported by Ollama | This is the scheduler's observed device budget, not all 48 GB |
|
|
104
|
-
| Default context | 32,768 tokens | Ollama selected its 24–48 GiB device-memory tier |
|
|
105
|
-
| Parallel requests | 1 | Appropriate baseline for interactive and large-model tests |
|
|
106
|
-
| Keep-alive | 5 minutes | Ollama default |
|
|
107
|
-
| Loaded-model limit | `OLLAMA_MAX_LOADED_MODELS=2` | Explicit service configuration for the measured topology |
|
|
108
|
-
| K/V-cache type | `OLLAMA_KV_CACHE_TYPE=q8_0` | Explicit memory-saving configuration; requalify quality per important model |
|
|
109
|
-
| Flash Attention | `auto` | Ollama enables it automatically on supported backends; force `1` only after a measured compatibility check. Required for quantized K/V cache. |
|
|
110
|
-
| GGUF CPU threads | 10 worker threads | Ollama selected the 10 performance cores rather than all 14 cores |
|
|
111
|
-
| MLX | GPU runner observed | MLX models use their own runner path, not the GGUF tuning path |
|
|
112
|
-
| Power mode | Automatic on battery and AC power | High Power Mode remains an unmeasured experiment |
|
|
113
|
-
|
|
114
|
-
The server log also showed Metal fusion, concurrent Metal execution, graph
|
|
115
|
-
optimization, and automatic parameter fitting. FreeLlama must not claim these
|
|
116
|
-
as its own optimizations.
|
|
117
|
-
|
|
118
|
-
### Verify CLI and server alignment
|
|
119
|
-
|
|
120
|
-
The selected CLI is `/usr/local/bin/ollama`, and both the CLI and active server report 0.33.2.
|
|
121
|
-
Verify this alignment after changing Ollama installations or service definitions:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
command -v ollama
|
|
125
|
-
ollama --version
|
|
126
|
-
curl --silent http://127.0.0.1:11434/api/version
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
The client and server versions must match before you test a CLI feature. A mismatch does not prove
|
|
130
|
-
an inference slowdown, but it can produce incompatible commands, flags, or diagnostics.
|
|
131
|
-
|
|
132
|
-
## What FreeLlama adds today
|
|
133
|
-
|
|
134
|
-
The active Rust implementation adds:
|
|
135
|
-
|
|
136
|
-
- capability filtering before speed ranking;
|
|
137
|
-
- explicit `fastest`, `balanced`, and `quality` evidence contracts;
|
|
138
|
-
- fail-closed quality routing when the policy has no qualified model;
|
|
139
|
-
- task-specific context, output, thinking, and tool-validation profiles;
|
|
140
|
-
- session affinity and preference for an eligible resident model;
|
|
141
|
-
- separate transition locks for primary and CPU backends, with shared execution permits for
|
|
142
|
-
resident tasks and an exclusive permit for a cold transition;
|
|
143
|
-
- exact-model placement on an optional second CPU Ollama process, including `num_gpu=0` for its
|
|
144
|
-
managed requests;
|
|
145
|
-
- guarded agent placement preferences plus a normalized, three-warm-sample, 10%-advantage feedback
|
|
146
|
-
loop for `fastest` and `balanced` work;
|
|
147
|
-
- independent 3:2:1 priority-fair weighted GPU and CPU admission pools, so a GPU burst cannot
|
|
148
|
-
starve a CPU helper or indefinitely starve background managed work;
|
|
149
|
-
- prompt-free load, prompt-processing, and output-generation metrics derived
|
|
150
|
-
from Ollama's response fields;
|
|
151
|
-
- a local natural-language intent interpreter that cannot choose a model;
|
|
152
|
-
- an Ollama-compatible loopback endpoint and an escape hatch to port 11434.
|
|
153
|
-
|
|
154
|
-
These features can reduce reloads or avoid an unsuitable model. They do not
|
|
155
|
-
change the selected model's prompt-processing or decode rate.
|
|
156
|
-
|
|
157
|
-
The measured dual-backend workload improved median completion time from 37.997 to 28.233 seconds
|
|
158
|
-
(1.346 times, or 25.70%). Qwen reported 19,175,677,668 GPU-resident bytes, Nomic reported zero,
|
|
159
|
-
and all requests carried correct backend receipts with zero FreeLlama queue wait. One of three
|
|
160
|
-
parallel trials was slower than sequential, so this remains a workload-level optimization rather
|
|
161
|
-
than an inference-speed claim.
|
|
162
|
-
|
|
163
|
-
## Unsupported optimizations
|
|
164
|
-
|
|
165
|
-
FreeLlama does not provide:
|
|
166
|
-
|
|
167
|
-
- a live minimum-free-VRAM guard. FreeLlama does calculate a metadata-backed F16 K/V lower bound
|
|
168
|
-
and refuses a known impossible CPU/unified-memory floor, but Ollama remains the authority for
|
|
169
|
-
current free memory, runner graph allocation, and final loading;
|
|
170
|
-
- transition coordination for native passthrough requests or processes that
|
|
171
|
-
bypass the managed `tasks` endpoint;
|
|
172
|
-
- live thermal, power-mode, or swap-aware routing;
|
|
173
|
-
- online token-rate, error-rate, or cold-load-duration scoring;
|
|
174
|
-
- per-engine tuning for GGUF compared with MLX;
|
|
175
|
-
- dynamic `keep_alive` or concurrency limits by workload;
|
|
176
|
-
- an atomic natural-language route-and-run operation;
|
|
177
|
-
- held-out quality policies for completion, coding, tools, browser, vision, or
|
|
178
|
-
long-context tasks in the example policy;
|
|
179
|
-
- quality-aware or thermal-aware CPU/GPU load balancing. Automatic placement uses persisted,
|
|
180
|
-
prompt-free warm-latency aggregates only within exact operator-owned assignments.
|
|
181
|
-
|
|
182
|
-
The RFC describes several of these capabilities as planned phases. Do not treat
|
|
183
|
-
the RFC as evidence that they have shipped.
|
|
184
|
-
|
|
185
|
-
## Optimization decisions
|
|
186
|
-
|
|
187
|
-
Use this table before changing Ollama or FreeLlama:
|
|
188
|
-
|
|
189
|
-
| Candidate change | Default decision | Reason |
|
|
190
|
-
|---|---|---|
|
|
191
|
-
| Expose Ollama beyond loopback | Do not add | Keep `OLLAMA_HOST` on loopback and put authenticated TLS ingress in front of FreeLlama instead |
|
|
192
|
-
| Permit Ollama cloud features in a local-only deployment | Do not add | Set `OLLAMA_NO_CLOUD=1` when the deployment promises local-only operation |
|
|
193
|
-
| Force layers of one model between CPU and GPU | Do not add | Ollama already fits and offloads the model; partial CPU fallback usually reduces decode throughput |
|
|
194
|
-
| Assign different models to isolated CPU and GPU-capable processes | Supported, benchmark per workload | Process isolation is reliable, but CPU speed and shared-memory pressure still determine whether overlap helps |
|
|
195
|
-
| Add macOS kernel or `sysctl` tuning | Do not add | Ollama does not document a supported, product-specific kernel setting. Unified-memory behavior belongs to macOS and Metal |
|
|
196
|
-
| Run Ollama in Docker on macOS | Do not use for performance | Docker Desktop does not provide Ollama GPU acceleration on macOS |
|
|
197
|
-
| Increase context globally | Do not add | Context memory grows with length; set the smallest sufficient `num_ctx` per request |
|
|
198
|
-
| Set parallel requests above 1 | Benchmark first | It can improve concurrent throughput but multiplies context memory and can hurt interactive latency |
|
|
199
|
-
| Keep more than one model loaded per process | Benchmark first | Model weights, runtime buffers, and every active context must fit together; start with `OLLAMA_MAX_LOADED_MODELS=1` |
|
|
200
|
-
| Leave Ollama's queue without a deployment limit | Do not add | Set a measured `OLLAMA_MAX_QUEUE`; it remains separate from FreeLlama's admission deadline |
|
|
201
|
-
| Pin multiple 18–21 GB models | Do not add by default | The observed 36 GiB Metal budget cannot safely establish that two heavy models plus contexts fit |
|
|
202
|
-
| Force Flash Attention | Benchmark per engine and model | The inspected GGUF path already enabled it automatically; MLX has a different runner |
|
|
203
|
-
| Use `q8_0` K/V cache | **8/10; qualify, then prefer for parallel/long-context work** | Ollama documents roughly half the KV memory of `f16` with very small precision loss; it is the practical companion to higher `OLLAMA_NUM_PARALLEL`, but it remains a process-wide quality tradeoff |
|
|
204
|
-
| Use `q4_0` K/V cache | Reject as a default | It saves more memory with a larger possible quality loss |
|
|
205
|
-
| Enable High Power Mode | Sustained-load experiment only | Apple documents higher sustained performance. Local token-rate and energy effects are not measured |
|
|
206
|
-
| Keep the small intent model resident | Keep bounded | It reduces routing latency but consumes memory and can affect a large-model transition |
|
|
207
|
-
|
|
208
|
-
## Measurement contract
|
|
209
|
-
|
|
210
|
-
Measure optimization with Ollama's response fields:
|
|
211
|
-
|
|
212
|
-
- prompt tokens per second = `prompt_eval_count / prompt_eval_duration` in
|
|
213
|
-
seconds;
|
|
214
|
-
- output tokens per second = `eval_count / eval_duration` in seconds;
|
|
215
|
-
- cold-load cost = `load_duration`;
|
|
216
|
-
- end-to-end latency = `total_duration` plus measured FreeLlama overhead;
|
|
217
|
-
- workload throughput = successful, quality-qualified tasks per hour.
|
|
218
|
-
|
|
219
|
-
Compare one variable at a time against stock Ollama. Include cold and warm runs,
|
|
220
|
-
fixed prompts, fixed output budgets, exact-output guardrails, quality guardrails, resident
|
|
221
|
-
memory, swap, and failure counts. A higher token rate is not an improvement if
|
|
222
|
-
quality falls, requests fail, or model transitions dominate the workload.
|
|
223
|
-
|
|
224
|
-
Use `cargo run -- bench-all` (`packages/rust-core/src/model_bench.rs`) for model selection evidence.
|
|
225
|
-
Use [CPU and GPU model routing](CPU_GPU_ROUTING.md) for the separate-process benchmark and
|
|
226
|
-
verification procedure.
|
|
227
|
-
|
|
228
|
-
- Local-model router RFC — lived in the gitignored `.octocode/` workspace and is no longer in the tree; the shipped design it argued for is [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
229
|
-
|
|
230
|
-
## Recommended next work
|
|
231
|
-
|
|
232
|
-
1. Keep the CLI executable aligned with the active Ollama server; `doctor` reports the selected
|
|
233
|
-
path, both versions, and effective memory-related settings.
|
|
234
|
-
2. Back up the versioned prompt-free feedback snapshot with the policy and deployed binary.
|
|
235
|
-
Verified warm work-unit latency and queue wait survive restart; raw prompts are never stored.
|
|
236
|
-
3. Validate the metadata-backed K/V lower bound against a frozen alternating-model workload before
|
|
237
|
-
widening it beyond CPU/unified-memory impossible-floor refusal. Keep Ollama as final authority.
|
|
238
|
-
4. Extend transition coordination only if managed streaming or another parsed
|
|
239
|
-
execution path needs it. Native passthrough remains Ollama-owned.
|
|
240
|
-
5. Evaluate request-specific context and residency profiles before testing global K/V-cache or
|
|
241
|
-
concurrency changes. Keep Flash Attention automatic on supported backends or set it explicitly
|
|
242
|
-
to `1` before selecting a quantized K/V cache.
|
|
243
|
-
6. Promote a hardware-and-engine profile only after `benchmark/hardware/run_validation.py` and its
|
|
244
|
-
held-out quality workload pass on a real self-hosted runner.
|
|
245
|
-
|
|
246
|
-
## Sources
|
|
247
|
-
|
|
248
|
-
- [Ollama FAQ and server settings](https://docs.ollama.com/faq)
|
|
249
|
-
- [Ollama context length](https://docs.ollama.com/context-length)
|
|
250
|
-
- [Ollama hardware and Metal support](https://docs.ollama.com/gpu)
|
|
251
|
-
- [Ollama API usage metrics](https://docs.ollama.com/api/usage)
|
|
252
|
-
- [Ollama embedding API](https://docs.ollama.com/api/embed)
|
|
253
|
-
- [Ollama macOS support](https://docs.ollama.com/macos)
|
|
254
|
-
- [Apple power modes](https://support.apple.com/en-lamr/101613)
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
# Product positioning
|
|
2
|
-
|
|
3
|
-
FreeLlama is a **governed local-model delegation layer for developers who run AI agents on
|
|
4
|
-
Ollama**. It helps an agent decide whether local inference is appropriate and select an eligible
|
|
5
|
-
installed model. It executes within machine and policy limits and returns evidence about what happened.
|
|
6
|
-
|
|
7
|
-
The shortest accurate description is:
|
|
8
|
-
|
|
9
|
-
> Ollama runs local models. FreeLlama helps agents use them deliberately.
|
|
10
|
-
|
|
11
|
-
This positioning is intentionally narrower than “AI gateway” and more useful than “Ollama proxy.”
|
|
12
|
-
FreeLlama preserves Ollama's API, but its distinctive work is the decision and evidence layer around
|
|
13
|
-
inference: model qualification, fail-closed routing, admission, CPU/GPU placement, grounded
|
|
14
|
-
research, and execution receipts.
|
|
15
|
-
|
|
16
|
-
## Product category decision
|
|
17
|
-
|
|
18
|
-
| Question | Decision |
|
|
19
|
-
|---|---|
|
|
20
|
-
| Product category | Local-model delegation control plane |
|
|
21
|
-
| Primary audience | Developers operating coding or research agents with Ollama |
|
|
22
|
-
| Core job | Move suitable work to local models without silently lowering quality or losing control of the machine |
|
|
23
|
-
| Primary alternative | Call Ollama directly and implement routing, verification, and resource coordination in every agent |
|
|
24
|
-
| Product promise | Make local delegation explicit, bounded, observable, and measurable |
|
|
25
|
-
| Not the product | A chat UI, an Ollama fork, a hosted inference service, or a generic multi-provider gateway |
|
|
26
|
-
|
|
27
|
-
“Trustworthy local-model delegation” is the clearest value phrase. “Localhost control plane” is an
|
|
28
|
-
accurate architectural phrase, but it supports the explanation rather than leads it.
|
|
29
|
-
|
|
30
|
-
## How the product fits
|
|
31
|
-
|
|
32
|
-
```mermaid
|
|
33
|
-
flowchart LR
|
|
34
|
-
U["Developer"] --> A["AI agent or application"]
|
|
35
|
-
A -->|"MCP, CLI, Rust, or control API"| F["FreeLlama"]
|
|
36
|
-
F --> D{"Delegate?\nWhich model?\nWhich backend?"}
|
|
37
|
-
D -->|"qualified GPU task"| G["Primary Ollama\nGPU-capable runner"]
|
|
38
|
-
D -->|"explicit CPU assignment"| C["Secondary Ollama\nCPU runner"]
|
|
39
|
-
D -->|"guard fails"| X["Refuse before inference"]
|
|
40
|
-
G --> E["Answer + execution receipt"]
|
|
41
|
-
C --> E
|
|
42
|
-
X --> E
|
|
43
|
-
E --> A
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
[Ollama](https://docs.ollama.com/api/introduction) owns model execution and its API. FreeLlama
|
|
47
|
-
owns the policy around managed use of that runtime. The [Model Context Protocol
|
|
48
|
-
(MCP)](https://modelcontextprotocol.io/specification/2025-06-18/architecture) makes those controls
|
|
49
|
-
available to compatible agent hosts as seven bounded tools. Native Ollama requests can still pass
|
|
50
|
-
through unchanged to the primary upstream.
|
|
51
|
-
|
|
52
|
-
See [FreeLlama architecture](ARCHITECTURE.md) for the complete responsibility and request-flow
|
|
53
|
-
contracts.
|
|
54
|
-
|
|
55
|
-
## Audience hierarchy
|
|
56
|
-
|
|
57
|
-
### Primary: developers operating AI agents
|
|
58
|
-
|
|
59
|
-
The strongest user is a developer who already uses a capable cloud or local agent and wants to
|
|
60
|
-
delegate bounded work to Ollama. Examples include grounded repository research, embeddings, OCR,
|
|
61
|
-
bulk transforms, and helper-model tasks.
|
|
62
|
-
|
|
63
|
-
Their job is not merely “run a model.” It is:
|
|
64
|
-
|
|
65
|
-
1. Determine whether a local model is suitable for the task.
|
|
66
|
-
2. Avoid sending work to an incapable, unmeasured, or oversized model.
|
|
67
|
-
3. Keep large files, vectors, images, and intermediate tool output out of the orchestrator's
|
|
68
|
-
context.
|
|
69
|
-
4. Coordinate concurrent work without uncontrolled model loads or memory pressure.
|
|
70
|
-
5. Receive citations, verdicts, placement, queue, and timing signals that the agent can inspect.
|
|
71
|
-
|
|
72
|
-
FreeLlama fits this user because its MCP server, CLI, agent skill, and control API expose exactly
|
|
73
|
-
those decisions. The core job-to-be-done is:
|
|
74
|
-
|
|
75
|
-
> When my agent encounters expensive but bounded work, decide whether a local model can handle it,
|
|
76
|
-
> run it under explicit limits, and give the agent enough evidence to trust or reject the result.
|
|
77
|
-
|
|
78
|
-
### Secondary: Ollama power users and local-AI operators
|
|
79
|
-
|
|
80
|
-
An operator with several installed models can use FreeLlama to diagnose environment drift, inspect
|
|
81
|
-
residency, preview routes, coordinate admission, assign selected helpers to a CPU backend, and turn
|
|
82
|
-
benchmark results into routing policy.
|
|
83
|
-
|
|
84
|
-
This audience can use the CLI without an MCP host. The relevant value is machine-aware operation,
|
|
85
|
-
not agent integration alone. FreeLlama discovers the current host and observes Ollama state instead
|
|
86
|
-
of embedding assumptions from the development Mac. See [model selection](MODEL_SELECTION.md) and
|
|
87
|
-
[CPU/GPU routing](CPU_GPU_ROUTING.md).
|
|
88
|
-
|
|
89
|
-
### Secondary: developers embedding local-model policy
|
|
90
|
-
|
|
91
|
-
Library and tool authors can use the Rust core, Node native boundary, or HTTP control API instead
|
|
92
|
-
of rebuilding discovery, routing, admission, and evaluation. This is an integration audience, not
|
|
93
|
-
the clearest first-run story.
|
|
94
|
-
|
|
95
|
-
### Adjacent: Ollama developers and contributors
|
|
96
|
-
|
|
97
|
-
FreeLlama can help Ollama contributors as a downstream compatibility and workload testbed. Its
|
|
98
|
-
diagnostics expose version drift, native passthrough tests protect API compatibility, and its
|
|
99
|
-
dual-process experiments document observed runner placement.
|
|
100
|
-
|
|
101
|
-
Ollama developers are not the primary audience. FreeLlama does not replace Ollama's scheduler,
|
|
102
|
-
runner, model storage, accelerator backends, or token generation. It is a sidecar that exercises
|
|
103
|
-
and governs Ollama from the client side. Describe the relationship as complementary:
|
|
104
|
-
|
|
105
|
-
> Ollama makes local inference possible; FreeLlama makes agent delegation to it governable.
|
|
106
|
-
|
|
107
|
-
### Not a target: mainstream users
|
|
108
|
-
|
|
109
|
-
FreeLlama is not a mainstream local-AI product. It has no end-user chat interface. Meaningful use
|
|
110
|
-
assumes familiarity with Ollama and its model tags. Users also need a terminal or MCP host and an
|
|
111
|
-
understanding of policy or benchmark concepts.
|
|
112
|
-
[Open WebUI](https://github.com/open-webui/open-webui) already addresses approachable self-hosted
|
|
113
|
-
AI interfaces.
|
|
114
|
-
|
|
115
|
-
A separate desktop or web interface can sit on top of FreeLlama as a new product layer. Keep that
|
|
116
|
-
layer from blurring the current audience or forcing consumer concerns into the control plane.
|
|
117
|
-
|
|
118
|
-
## The gap FreeLlama fills
|
|
119
|
-
|
|
120
|
-
Calling Ollama directly is the correct path when the caller already knows the exact model
|
|
121
|
-
and request. FreeLlama becomes useful when the caller has to make and defend a delegation decision.
|
|
122
|
-
|
|
123
|
-
| Direct Ollama question | FreeLlama question |
|
|
124
|
-
|---|---|
|
|
125
|
-
| Which model tag receives this request? | Which installed model qualifies for this task and confidence threshold? |
|
|
126
|
-
| Did the request return HTTP 200? | Was it admitted, where did it execute, and what did it cost? |
|
|
127
|
-
| Can the model call tools? | Did bounded research read evidence and produce verifiable citations? |
|
|
128
|
-
| Can Ollama load this model? | Does it fit the discovered machine and current resident workload? |
|
|
129
|
-
| Can I set request options? | Can this managed model use the explicitly assigned CPU backend without changing raw traffic? |
|
|
130
|
-
|
|
131
|
-
This distinction also separates FreeLlama from a broad gateway such as
|
|
132
|
-
[LiteLLM](https://github.com/BerriAI/litellm). LiteLLM unifies many providers and adds centralized
|
|
133
|
-
authentication, budgets, spend tracking, and load balancing. FreeLlama is Ollama-specific,
|
|
134
|
-
machine-aware, and centered on agent delegation evidence. Its bearer boundary supports a trusted
|
|
135
|
-
operator or team; it does not attempt LiteLLM's tenant, spend, or provider-management scope.
|
|
136
|
-
|
|
137
|
-
[RouteLLM](https://github.com/lm-sys/RouteLLM) is the closer routing-specific comparison. It trains
|
|
138
|
-
and evaluates routers that select between stronger and weaker model endpoints. FreeLlama does not
|
|
139
|
-
implement a learned prompt router. It applies deterministic local eligibility and operator policy,
|
|
140
|
-
then adds host fit, admission, physical CPU/GPU placement evidence, and grounded-research receipts.
|
|
141
|
-
|
|
142
|
-
## The product loop
|
|
143
|
-
|
|
144
|
-
The flexible part of FreeLlama is not an unconstrained agent choosing hardware. It is a guarded
|
|
145
|
-
feedback loop with explicit operator and policy boundaries.
|
|
146
|
-
|
|
147
|
-
```mermaid
|
|
148
|
-
flowchart TD
|
|
149
|
-
T["Agent describes task, objective, and constraints"] --> P["Preview route"]
|
|
150
|
-
P --> Q{"Capability, policy, confidence,\nand capacity qualify?"}
|
|
151
|
-
Q -->|"no"| R["Refuse with reasons"]
|
|
152
|
-
Q -->|"yes"| A["Admit on selected backend"]
|
|
153
|
-
A --> O["Ollama executes"]
|
|
154
|
-
O --> V["Return result, placement, queue,\nand timing evidence"]
|
|
155
|
-
V --> F["Record normalized warm feedback"]
|
|
156
|
-
F -.->|"auto; fastest or balanced only\nafter enough samples"| P
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
An agent can request `auto`, `prefer_cpu`, or `prefer_gpu`, but the request remains a preference.
|
|
160
|
-
Explicit model choice, session affinity, capability requirements, policy, confidence, and operator
|
|
161
|
-
CPU assignments remain authoritative. Runtime feedback only influences eligible `auto` routes for
|
|
162
|
-
speed-oriented objectives after comparable warm samples exist; it never overrides a quality
|
|
163
|
-
objective. This design lets the system adapt to another machine without turning resource placement
|
|
164
|
-
into an opaque autonomous decision.
|
|
165
|
-
|
|
166
|
-
## Message hierarchy
|
|
167
|
-
|
|
168
|
-
Use one message at each level:
|
|
169
|
-
|
|
170
|
-
| Context | Message |
|
|
171
|
-
|---|---|
|
|
172
|
-
| Category | Local-model delegation control plane |
|
|
173
|
-
| One line | FreeLlama helps AI agents use Ollama deliberately, with routing, resource limits, and evidence. |
|
|
174
|
-
| Problem | Local inference is direct to call but hard to delegate to safely across different models and machines. |
|
|
175
|
-
| Promise | Move suitable work local without silently lowering quality or destabilizing the runtime. |
|
|
176
|
-
| Mechanism | Qualify, preview, admit, execute, and return a receipt. |
|
|
177
|
-
| Boundary | Ollama runtime underneath; FreeLlama policy around it. |
|
|
178
|
-
|
|
179
|
-
Good headline directions are outcome-first:
|
|
180
|
-
|
|
181
|
-
- **Use local models without lowering your standards.**
|
|
182
|
-
- **Give your AI agent a governed path to Ollama.**
|
|
183
|
-
- **Delegate locally. Keep the evidence.**
|
|
184
|
-
|
|
185
|
-
Avoid “AI orchestration platform.” It is broad enough to hide the product. Avoid leading with
|
|
186
|
-
“proxy,” because raw passthrough is a compatibility feature rather than the principal value.
|
|
187
|
-
|
|
188
|
-
## Build credible attention
|
|
189
|
-
|
|
190
|
-
Create interest through short, reproducible contrasts rather than market-size or
|
|
191
|
-
speed claims.
|
|
192
|
-
|
|
193
|
-
### Demonstration 1: refuse before wasting work
|
|
194
|
-
|
|
195
|
-
Show an agent previewing a task, rejecting an unqualified model, and returning the reason without
|
|
196
|
-
an inference call. The story is not “the router is smart”; it is “a weak local model cannot quietly
|
|
197
|
-
produce a confident answer.”
|
|
198
|
-
|
|
199
|
-
### Demonstration 2: preserve frontier context
|
|
200
|
-
|
|
201
|
-
Give `delegate_research` a narrow repository question. Show the local adapter reading allowlisted
|
|
202
|
-
files and returning an answer, citations, and a verification verdict instead of returning all source
|
|
203
|
-
material and intermediate tool output to the orchestrator.
|
|
204
|
-
|
|
205
|
-
One measured six-question run reduced 59,208 source tokens to 1,742 returned tokens, or 97.1%
|
|
206
|
-
context offload. That is a single measured workload, not a universal savings rate. The durable
|
|
207
|
-
claim is context isolation; see [token economics](ECONOMICS.md).
|
|
208
|
-
|
|
209
|
-
### Demonstration 3: use the machine as a system
|
|
210
|
-
|
|
211
|
-
Run a large GPU completion and a small CPU helper concurrently, then show both placement receipts.
|
|
212
|
-
On the measured 48 GB Apple M4 Pro, three warmed trials reduced median wall time from 37.997 to
|
|
213
|
-
28.233 seconds, a 1.346-times speedup. One of the three parallel trials was slower than sequential,
|
|
214
|
-
so the claim is “these workloads can overlap,” not “CPU/GPU mode is always faster.” See the full
|
|
215
|
-
[CPU/GPU measurement](CPU_GPU_ROUTING.md#interpret-the-measured-mac-result).
|
|
216
|
-
|
|
217
|
-
These demonstrations map directly to three memorable benefits: **trust, context, and resources**.
|
|
218
|
-
Turn them into a short terminal recording, copyable README recipes, and versioned benchmark
|
|
219
|
-
receipts. Each demo needs the command, machine profile, model tags, policy, result, and
|
|
220
|
-
failure conditions.
|
|
221
|
-
|
|
222
|
-
## Adoption path
|
|
223
|
-
|
|
224
|
-
The first-use sequence needs to reveal value before asking for sophisticated configuration:
|
|
225
|
-
|
|
226
|
-
```mermaid
|
|
227
|
-
flowchart LR
|
|
228
|
-
I["Install beside Ollama"] --> D["doctor\nsee machine and drift"]
|
|
229
|
-
D --> P["preview\nsee a route and reasons"]
|
|
230
|
-
P --> T["run one managed task\nsee the receipt"]
|
|
231
|
-
T --> G["delegate research\nsee citations and verdict"]
|
|
232
|
-
G --> B["benchmark\nmeasure local models"]
|
|
233
|
-
B --> Y["policy\nallow proven routes"]
|
|
234
|
-
Y --> R["resource tuning\nCPU/GPU and admission"]
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
The product must not require a new user to understand every tool, KV-cache setting, or routing
|
|
238
|
-
objective before the first managed task. Advanced controls become relevant after the first receipt
|
|
239
|
-
makes the control loop visible.
|
|
240
|
-
|
|
241
|
-
## Claim and naming guardrails
|
|
242
|
-
|
|
243
|
-
| Do not say | Say instead |
|
|
244
|
-
|---|---|
|
|
245
|
-
| Free local inference | Local inference uses hardware, power, memory, and time; FreeLlama can preserve paid frontier context. |
|
|
246
|
-
| Automatically picks the optimal model | Routes among eligible installed models using explicit policy and available evidence. |
|
|
247
|
-
| Makes Ollama faster | Can improve workload efficiency; it does not increase one model's decode speed. |
|
|
248
|
-
| Runs CPU and GPU in parallel on every machine | Can overlap explicitly assigned workloads when the host and Ollama backends support them; measure the result. |
|
|
249
|
-
| Works the same on any hardware | Uses platform-specific host discovery on macOS, Linux, and Windows. Portable defaults do not remove the need to observe accelerator behavior. |
|
|
250
|
-
| Replaces Ollama | Runs beside Ollama and preserves its native API. |
|
|
251
|
-
| For everyone | Built first for developers and local-AI operators. |
|
|
252
|
-
| Llama models only | Works with qualifying models exposed by Ollama; “Llama” is the product name, not a model-family restriction. |
|
|
253
|
-
|
|
254
|
-
Use the word “Free” to refer to reducing reliance on metered frontier inference, not zero-cost
|
|
255
|
-
computing. Readers can misread “Llama” as Meta Llama-only, so put the Ollama relationship and model
|
|
256
|
-
agnosticism within Ollama near the first description.
|
|
257
|
-
|
|
258
|
-
## Product decision
|
|
259
|
-
|
|
260
|
-
Narrow the story before broadening the product:
|
|
261
|
-
|
|
262
|
-
1. Lead with developers operating AI agents, not all developers.
|
|
263
|
-
2. Make trustworthy delegation the category-defining job.
|
|
264
|
-
3. Use MCP as the primary agent integration and the CLI as the operator surface.
|
|
265
|
-
4. Treat Ollama power users and embedders as secondary audiences.
|
|
266
|
-
5. Treat Ollama contributors as an adjacent ecosystem audience, not the main customer.
|
|
267
|
-
6. Do not pursue a mainstream chat interface until the developer onboarding loop is clear and
|
|
268
|
-
repeatable.
|
|
269
|
-
|
|
270
|
-
This decision matches the code that exists today. The Rust core, CLI, MCP server, proxy, agent
|
|
271
|
-
skill, benchmark harnesses, and policy system all support a developer control plane. Positioning it
|
|
272
|
-
as a consumer app promises a product surface the repository does not provide.
|
|
273
|
-
|
|
274
|
-
## Related documentation
|
|
275
|
-
|
|
276
|
-
- [Architecture](ARCHITECTURE.md): ownership boundaries and request flows
|
|
277
|
-
- [MCP server](../packages/mcp/README.md): six agent-facing tools and their contracts
|
|
278
|
-
- [CLI](CLI.md): operator commands and control-plane workflows
|
|
279
|
-
- [Model selection](MODEL_SELECTION.md): evidence, qualification, and recommendation
|
|
280
|
-
- [CPU/GPU routing](CPU_GPU_ROUTING.md): portable configuration, feedback, and measured limits
|
|
281
|
-
- [Testing](TESTING.md): verification tiers and live-runtime boundaries
|
|
282
|
-
- [Token economics](ECONOMICS.md): measured context isolation and its limits
|
|
283
|
-
|
|
284
|
-
## Sources
|
|
285
|
-
|
|
286
|
-
- [Ollama API introduction](https://docs.ollama.com/api/introduction)
|
|
287
|
-
- [Ollama tool calling](https://docs.ollama.com/capabilities/tool-calling)
|
|
288
|
-
- [Model Context Protocol architecture](https://modelcontextprotocol.io/specification/2025-06-18/architecture)
|
|
289
|
-
- [Open WebUI](https://github.com/open-webui/open-webui)
|
|
290
|
-
- [LiteLLM](https://github.com/BerriAI/litellm)
|
|
291
|
-
- [RouteLLM](https://github.com/lm-sys/RouteLLM)
|