✨ mlxserve provider (#252): MLX-Serve over its OpenAI API
- registry entry mlxserve (port 11234): probe from /v1/models (served window
only when loaded, warning when the model is not downloaded or the key is
refused), unload via /v1/unload-model, pull via the Ollama /api/pull wire
- thinkingOffBoth: MLX-Serve reasons when either enable_thinking or
reasoning_effort says so, the summary request turns off both
- dropSSEComments middleware for every provider: a comment-only SSE block
(": keepalive") made openai-go decode an empty event
("unexpected end of JSON input")
- mm init knows mlxserve (facts from /api/show + meta.gen_* sampling)
- MLX demos (mlx-gemma-4-e4b, -12b, -26b-a4b, mlx-qwen), docs EN+FR
- openai-go v1.12.0
- tickets #253-#256
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>25ed885 parent: c5a4014 modified
.gitignore +1 -0 | @@ -27,3 +27,4 @@ bob-the-bot | ||
| 27 | 27 | bob-the-smoll |
| 28 | 28 | bob-coder |
| 29 | 29 | |
| 30 | +!demos/mlx-* | |
| @@ -27,3 +27,4 @@ bob-the-bot | |||
| 27 | bob-the-smoll | 27 | bob-the-smoll |
| 28 | bob-coder | 28 | bob-coder |
| 29 | 29 | ||
| 30 | +!demos/mlx-* | ||
added
.tickets/issues/0252-add-mlx-serve-provider.yaml +135 -0 | new file mode 100644 | ||
| @@ -0,0 +1,135 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 252 | |
| 3 | +title: Add MLX-Serve provider | |
| 4 | +state: closed | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-24T05:46:56.000Z | |
| 9 | +updatedAt: 2026-11-24T16:50:01.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | + - priority::medium | |
| 14 | +milestone: v2.0.1 | |
| 15 | +epic: Providers (LLM Engine) | |
| 16 | +related: | |
| 17 | + - 62 | |
| 18 | +body: | | |
| 19 | + Add [MLX-Serve](https://github.com/ddalcu/mlx-serve) as a provider | |
| 20 | + (`provider: mlxserve`). | |
| 21 | + | |
| 22 | + MLX-Serve is a native local LLM server for Apple Silicon (MLX, no Python; | |
| 23 | + also NVIDIA builds on Linux). One server on `http://localhost:11234` speaks | |
| 24 | + the OpenAI (chat, completions, Responses), Anthropic Messages and Ollama | |
| 25 | + APIs, with streaming, tool calls, JSON schemas, vision and reasoning. Models | |
| 26 | + are pulled with `mlx-serve pull <model>` and loaded on demand by | |
| 27 | + `mlx-serve serve`. | |
| 28 | + | |
| 29 | + Like Ollama ([#62 — Add Ollama provider](.tickets/issues/0062-add-ollama-provider.yaml)), | |
| 30 | + use the OpenAI API (`/v1/chat/completions`) and give it its own registry | |
| 31 | + entry in `internal/engine/provider.go`, so that a difference found later is | |
| 32 | + one field to change. | |
| 33 | + | |
| 34 | + ## Acceptance criteria | |
| 35 | + - `provider: mlxserve` works with default base URL `http://localhost:11234/v1`. | |
| 36 | + - Reasoning, thinking switch, context window and tool calls behave as | |
| 37 | + measured (not assumed) against a real MLX-Serve. | |
| 38 | + - `mm init` and the decision-model config know the new provider. | |
| 39 | + - A demo agent config and EN+FR docs. | |
| 40 | +tasks: | |
| 41 | + - id: 1 | |
| 42 | + title: Measure MLX-Serve's /v1 (reasoning field, progress, thinking switch, window, tool calls, 404) | |
| 43 | + state: closed | |
| 44 | + priority: high | |
| 45 | + author: | |
| 46 | + name: k33g | |
| 47 | + email: ph.charriere@gmail.com | |
| 48 | + createdAt: 2026-11-24T05:46:56.000Z | |
| 49 | + updatedAt: 2026-11-24T06:05:16.000Z | |
| 50 | + closedAt: 2026-11-24T06:05:16.000Z | |
| 51 | + - id: 2 | |
| 52 | + title: Registry entry mlxserve + probe (model list / loaded model / context size) | |
| 53 | + state: closed | |
| 54 | + priority: none | |
| 55 | + author: | |
| 56 | + name: k33g | |
| 57 | + email: ph.charriere@gmail.com | |
| 58 | + createdAt: 2026-11-24T05:46:56.000Z | |
| 59 | + updatedAt: 2026-11-24T06:05:16.000Z | |
| 60 | + closedAt: 2026-11-24T06:05:16.000Z | |
| 61 | + - id: 3 | |
| 62 | + title: Accept mlxserve in config validation, decision models and mm init presets | |
| 63 | + state: closed | |
| 64 | + priority: none | |
| 65 | + author: | |
| 66 | + name: k33g | |
| 67 | + email: ph.charriere@gmail.com | |
| 68 | + createdAt: 2026-11-24T05:46:56.000Z | |
| 69 | + updatedAt: 2026-11-24T06:05:16.000Z | |
| 70 | + closedAt: 2026-11-24T06:05:16.000Z | |
| 71 | + - id: 4 | |
| 72 | + title: "Tests: Resolve rows, probe test, thinking-off behaviour" | |
| 73 | + state: closed | |
| 74 | + priority: none | |
| 75 | + author: | |
| 76 | + name: k33g | |
| 77 | + email: ph.charriere@gmail.com | |
| 78 | + createdAt: 2026-11-24T05:46:56.000Z | |
| 79 | + updatedAt: 2026-11-24T06:05:16.000Z | |
| 80 | + closedAt: 2026-11-24T06:05:16.000Z | |
| 81 | + - id: 5 | |
| 82 | + title: Demo agent config with a small MLX model (e.g. gemma4) | |
| 83 | + state: closed | |
| 84 | + priority: none | |
| 85 | + author: | |
| 86 | + name: k33g | |
| 87 | + email: ph.charriere@gmail.com | |
| 88 | + createdAt: 2026-11-24T05:46:56.000Z | |
| 89 | + updatedAt: 2026-11-24T06:05:16.000Z | |
| 90 | + closedAt: 2026-11-24T06:05:16.000Z | |
| 91 | + - id: 6 | |
| 92 | + title: Document the provider (EN + FR) | |
| 93 | + state: closed | |
| 94 | + priority: none | |
| 95 | + author: | |
| 96 | + name: k33g | |
| 97 | + email: ph.charriere@gmail.com | |
| 98 | + createdAt: 2026-11-24T05:46:56.000Z | |
| 99 | + updatedAt: 2026-11-24T06:05:16.000Z | |
| 100 | + closedAt: 2026-11-24T06:05:16.000Z | |
| 101 | +comments: | |
| 102 | + - id: 1 | |
| 103 | + author: | |
| 104 | + name: k33g | |
| 105 | + email: ph.charriere@gmail.com | |
| 106 | + createdAt: 2026-11-24T06:05:16.000Z | |
| 107 | + body: | | |
| 108 | + Implemented on branch `feature/mlx-serve-provider` (not committed). | |
| 109 | + Measured on mlx-serve 26.11.3 (Gemma 4 E4B 8-bit): | |
| 110 | + - reasoning in `reasoning_content`, ON if either `enable_thinking` or | |
| 111 | + `reasoning_effort` says so → new `thinkingOffBoth` (summary sends both off); | |
| 112 | + - no prompt_progress; `/v1/models` has `loaded` + `context_length` | |
| 113 | + (served window only when loaded); unknown model = answered by the default | |
| 114 | + model with HTTP 200 (only the probe warning shows it); | |
| 115 | + - `/api/pull` (Ollama wire) → `pullOllamaAPI`; `/v1/unload-model` → `unloadMlxServe`; | |
| 116 | + - **bug found**: `: keepalive` SSE comments broke openai-go's decoder | |
| 117 | + (`unexpected end of JSON input`) → `dropSSEComments` middleware for all providers. | |
| 118 | + Demo `demos/mlxserve/` (written by `mm init --check`), docs EN+FR. | |
| 119 | + - id: 2 | |
| 120 | + author: | |
| 121 | + name: k33g | |
| 122 | + email: ph.charriere@gmail.com | |
| 123 | + createdAt: 2026-11-24T06:18:51.000Z | |
| 124 | + body: | | |
| 125 | + The demo is now `demos/mlx-gemma/` (agent in `.mm/agent.yaml`); | |
| 126 | + `demos/mlxserve/` was removed and the docs point to the new folder. | |
| 127 | + - id: 3 | |
| 128 | + author: | |
| 129 | + name: k33g | |
| 130 | + email: ph.charriere@gmail.com | |
| 131 | + createdAt: 2026-11-24T16:50:01.000Z | |
| 132 | + body: | | |
| 133 | + Merged into `main`. The demo folder is now `demos/mlx-gemma-4-e4b/` | |
| 134 | + (docs and README repointed); `demos/mlx-gemma-4-12b/`, | |
| 135 | + `demos/mlx-gemma-4-26b-a4b/` and `demos/mlx-qwen/` are other MLX-Serve agents. | |
| new file mode 100644 | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 252 | ||
| 3 | +title: Add MLX-Serve provider | ||
| 4 | +state: closed | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-24T05:46:56.000Z | ||
| 9 | +updatedAt: 2026-11-24T16:50:01.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | + - priority::medium | ||
| 14 | +milestone: v2.0.1 | ||
| 15 | +epic: Providers (LLM Engine) | ||
| 16 | +related: | ||
| 17 | + - 62 | ||
| 18 | +body: | | ||
| 19 | + Add [MLX-Serve](https://github.com/ddalcu/mlx-serve) as a provider | ||
| 20 | + (`provider: mlxserve`). | ||
| 21 | + | ||
| 22 | + MLX-Serve is a native local LLM server for Apple Silicon (MLX, no Python; | ||
| 23 | + also NVIDIA builds on Linux). One server on `http://localhost:11234` speaks | ||
| 24 | + the OpenAI (chat, completions, Responses), Anthropic Messages and Ollama | ||
| 25 | + APIs, with streaming, tool calls, JSON schemas, vision and reasoning. Models | ||
| 26 | + are pulled with `mlx-serve pull <model>` and loaded on demand by | ||
| 27 | + `mlx-serve serve`. | ||
| 28 | + | ||
| 29 | + Like Ollama ([#62 — Add Ollama provider](.tickets/issues/0062-add-ollama-provider.yaml)), | ||
| 30 | + use the OpenAI API (`/v1/chat/completions`) and give it its own registry | ||
| 31 | + entry in `internal/engine/provider.go`, so that a difference found later is | ||
| 32 | + one field to change. | ||
| 33 | + | ||
| 34 | + ## Acceptance criteria | ||
| 35 | + - `provider: mlxserve` works with default base URL `http://localhost:11234/v1`. | ||
| 36 | + - Reasoning, thinking switch, context window and tool calls behave as | ||
| 37 | + measured (not assumed) against a real MLX-Serve. | ||
| 38 | + - `mm init` and the decision-model config know the new provider. | ||
| 39 | + - A demo agent config and EN+FR docs. | ||
| 40 | +tasks: | ||
| 41 | + - id: 1 | ||
| 42 | + title: Measure MLX-Serve's /v1 (reasoning field, progress, thinking switch, window, tool calls, 404) | ||
| 43 | + state: closed | ||
| 44 | + priority: high | ||
| 45 | + author: | ||
| 46 | + name: k33g | ||
| 47 | + email: ph.charriere@gmail.com | ||
| 48 | + createdAt: 2026-11-24T05:46:56.000Z | ||
| 49 | + updatedAt: 2026-11-24T06:05:16.000Z | ||
| 50 | + closedAt: 2026-11-24T06:05:16.000Z | ||
| 51 | + - id: 2 | ||
| 52 | + title: Registry entry mlxserve + probe (model list / loaded model / context size) | ||
| 53 | + state: closed | ||
| 54 | + priority: none | ||
| 55 | + author: | ||
| 56 | + name: k33g | ||
| 57 | + email: ph.charriere@gmail.com | ||
| 58 | + createdAt: 2026-11-24T05:46:56.000Z | ||
| 59 | + updatedAt: 2026-11-24T06:05:16.000Z | ||
| 60 | + closedAt: 2026-11-24T06:05:16.000Z | ||
| 61 | + - id: 3 | ||
| 62 | + title: Accept mlxserve in config validation, decision models and mm init presets | ||
| 63 | + state: closed | ||
| 64 | + priority: none | ||
| 65 | + author: | ||
| 66 | + name: k33g | ||
| 67 | + email: ph.charriere@gmail.com | ||
| 68 | + createdAt: 2026-11-24T05:46:56.000Z | ||
| 69 | + updatedAt: 2026-11-24T06:05:16.000Z | ||
| 70 | + closedAt: 2026-11-24T06:05:16.000Z | ||
| 71 | + - id: 4 | ||
| 72 | + title: "Tests: Resolve rows, probe test, thinking-off behaviour" | ||
| 73 | + state: closed | ||
| 74 | + priority: none | ||
| 75 | + author: | ||
| 76 | + name: k33g | ||
| 77 | + email: ph.charriere@gmail.com | ||
| 78 | + createdAt: 2026-11-24T05:46:56.000Z | ||
| 79 | + updatedAt: 2026-11-24T06:05:16.000Z | ||
| 80 | + closedAt: 2026-11-24T06:05:16.000Z | ||
| 81 | + - id: 5 | ||
| 82 | + title: Demo agent config with a small MLX model (e.g. gemma4) | ||
| 83 | + state: closed | ||
| 84 | + priority: none | ||
| 85 | + author: | ||
| 86 | + name: k33g | ||
| 87 | + email: ph.charriere@gmail.com | ||
| 88 | + createdAt: 2026-11-24T05:46:56.000Z | ||
| 89 | + updatedAt: 2026-11-24T06:05:16.000Z | ||
| 90 | + closedAt: 2026-11-24T06:05:16.000Z | ||
| 91 | + - id: 6 | ||
| 92 | + title: Document the provider (EN + FR) | ||
| 93 | + state: closed | ||
| 94 | + priority: none | ||
| 95 | + author: | ||
| 96 | + name: k33g | ||
| 97 | + email: ph.charriere@gmail.com | ||
| 98 | + createdAt: 2026-11-24T05:46:56.000Z | ||
| 99 | + updatedAt: 2026-11-24T06:05:16.000Z | ||
| 100 | + closedAt: 2026-11-24T06:05:16.000Z | ||
| 101 | +comments: | ||
| 102 | + - id: 1 | ||
| 103 | + author: | ||
| 104 | + name: k33g | ||
| 105 | + email: ph.charriere@gmail.com | ||
| 106 | + createdAt: 2026-11-24T06:05:16.000Z | ||
| 107 | + body: | | ||
| 108 | + Implemented on branch `feature/mlx-serve-provider` (not committed). | ||
| 109 | + Measured on mlx-serve 26.11.3 (Gemma 4 E4B 8-bit): | ||
| 110 | + - reasoning in `reasoning_content`, ON if either `enable_thinking` or | ||
| 111 | + `reasoning_effort` says so → new `thinkingOffBoth` (summary sends both off); | ||
| 112 | + - no prompt_progress; `/v1/models` has `loaded` + `context_length` | ||
| 113 | + (served window only when loaded); unknown model = answered by the default | ||
| 114 | + model with HTTP 200 (only the probe warning shows it); | ||
| 115 | + - `/api/pull` (Ollama wire) → `pullOllamaAPI`; `/v1/unload-model` → `unloadMlxServe`; | ||
| 116 | + - **bug found**: `: keepalive` SSE comments broke openai-go's decoder | ||
| 117 | + (`unexpected end of JSON input`) → `dropSSEComments` middleware for all providers. | ||
| 118 | + Demo `demos/mlxserve/` (written by `mm init --check`), docs EN+FR. | ||
| 119 | + - id: 2 | ||
| 120 | + author: | ||
| 121 | + name: k33g | ||
| 122 | + email: ph.charriere@gmail.com | ||
| 123 | + createdAt: 2026-11-24T06:18:51.000Z | ||
| 124 | + body: | | ||
| 125 | + The demo is now `demos/mlx-gemma/` (agent in `.mm/agent.yaml`); | ||
| 126 | + `demos/mlxserve/` was removed and the docs point to the new folder. | ||
| 127 | + - id: 3 | ||
| 128 | + author: | ||
| 129 | + name: k33g | ||
| 130 | + email: ph.charriere@gmail.com | ||
| 131 | + createdAt: 2026-11-24T16:50:01.000Z | ||
| 132 | + body: | | ||
| 133 | + Merged into `main`. The demo folder is now `demos/mlx-gemma-4-e4b/` | ||
| 134 | + (docs and README repointed); `demos/mlx-gemma-4-12b/`, | ||
| 135 | + `demos/mlx-gemma-4-26b-a4b/` and `demos/mlx-qwen/` are other MLX-Serve agents. | ||
added
.tickets/issues/0253-variables-in-the-system-prompt-date-cwd-env-name.yaml +48 -0 | new file mode 100644 | ||
| @@ -0,0 +1,48 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 253 | |
| 3 | +title: "Variables in the system prompt: {{date}}, {{cwd}}, {{env.NAME}}" | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-24T05:59:01.000Z | |
| 9 | +updatedAt: 2026-11-24T05:59:01.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | +related: | |
| 14 | + - 244 | |
| 15 | +body: | | |
| 16 | + Let the agent file use variables in `system:`, replaced when mm builds the | |
| 17 | + prompt: | |
| 18 | + | |
| 19 | + ```yaml | |
| 20 | + # Variables: {{date}}, {{cwd}}, {{env.NAME}}. | |
| 21 | + system: | | |
| 22 | + You are a helpful assistant. Today is {{date}}. | |
| 23 | + ``` | |
| 24 | + | |
| 25 | + - `{{date}}`: today's date (format to decide, e.g. `2026-11-24`). | |
| 26 | + - `{{cwd}}`: the directory mm runs in. | |
| 27 | + - `{{env.NAME}}`: the value of the environment variable NAME. | |
| 28 | + | |
| 29 | + ## Points to decide | |
| 30 | + - An unknown variable or an unset `env.NAME`: left as is, empty, or a | |
| 31 | + banner warning? | |
| 32 | + - Escaping a literal `{{…}}` in a prompt. | |
| 33 | + - Which fields besides `system:`: `turnReminder`, skills, mmConfigs agents? | |
| 34 | + - `{{env.NAME}}` can put a secret in the prompt (and so in sessions and | |
| 35 | + traces): document it, or refuse names that look like keys (see #244). | |
| 36 | + - When it is evaluated: once at start-up, or at each turn (a session that | |
| 37 | + crosses midnight)? Cached prompt prefix: changing it every turn costs | |
| 38 | + the server's KV cache. | |
| 39 | + - Same `{{name}}` syntax as the declared tools' placeholders | |
| 40 | + (`internal/config/tools.go`) — reuse `placeholderPattern`. | |
| 41 | + | |
| 42 | + ## Acceptance criteria | |
| 43 | + - The three variables are replaced in `system:` in every mode (terminal, | |
| 44 | + window, ACP, `-p`). | |
| 45 | + - `mm init` writes the comment line listing the variables. | |
| 46 | + - Tests, and EN+FR reference docs. | |
| 47 | +tasks: [] | |
| 48 | +comments: [] | |
| new file mode 100644 | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 253 | ||
| 3 | +title: "Variables in the system prompt: {{date}}, {{cwd}}, {{env.NAME}}" | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-24T05:59:01.000Z | ||
| 9 | +updatedAt: 2026-11-24T05:59:01.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | +related: | ||
| 14 | + - 244 | ||
| 15 | +body: | | ||
| 16 | + Let the agent file use variables in `system:`, replaced when mm builds the | ||
| 17 | + prompt: | ||
| 18 | + | ||
| 19 | + ```yaml | ||
| 20 | + # Variables: {{date}}, {{cwd}}, {{env.NAME}}. | ||
| 21 | + system: | | ||
| 22 | + You are a helpful assistant. Today is {{date}}. | ||
| 23 | + ``` | ||
| 24 | + | ||
| 25 | + - `{{date}}`: today's date (format to decide, e.g. `2026-11-24`). | ||
| 26 | + - `{{cwd}}`: the directory mm runs in. | ||
| 27 | + - `{{env.NAME}}`: the value of the environment variable NAME. | ||
| 28 | + | ||
| 29 | + ## Points to decide | ||
| 30 | + - An unknown variable or an unset `env.NAME`: left as is, empty, or a | ||
| 31 | + banner warning? | ||
| 32 | + - Escaping a literal `{{…}}` in a prompt. | ||
| 33 | + - Which fields besides `system:`: `turnReminder`, skills, mmConfigs agents? | ||
| 34 | + - `{{env.NAME}}` can put a secret in the prompt (and so in sessions and | ||
| 35 | + traces): document it, or refuse names that look like keys (see #244). | ||
| 36 | + - When it is evaluated: once at start-up, or at each turn (a session that | ||
| 37 | + crosses midnight)? Cached prompt prefix: changing it every turn costs | ||
| 38 | + the server's KV cache. | ||
| 39 | + - Same `{{name}}` syntax as the declared tools' placeholders | ||
| 40 | + (`internal/config/tools.go`) — reuse `placeholderPattern`. | ||
| 41 | + | ||
| 42 | + ## Acceptance criteria | ||
| 43 | + - The three variables are replaced in `system:` in every mode (terminal, | ||
| 44 | + window, ACP, `-p`). | ||
| 45 | + - `mm init` writes the comment line listing the variables. | ||
| 46 | + - Tests, and EN+FR reference docs. | ||
| 47 | +tasks: [] | ||
| 48 | +comments: [] | ||
added
.tickets/issues/0254-measure-and-show-the-token-generation-speed-tokens-s.yaml +92 -0 | new file mode 100644 | ||
| @@ -0,0 +1,92 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 254 | |
| 3 | +title: Measure and show the token generation speed (tokens/s) | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-24T06:32:51.000Z | |
| 9 | +updatedAt: 2026-11-24T06:32:51.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | +epic: Providers (LLM Engine) | |
| 14 | +body: | | |
| 15 | + Compute the model's generation speed and show it to the user, e.g. | |
| 16 | + `⚡ 48.2 tok/s` after an answer, so models, quantisations and servers can | |
| 17 | + be compared from inside mm. | |
| 18 | + | |
| 19 | + ## What exists | |
| 20 | + - `ui.Usage` (`internal/ui/ui.go`) already carries the tokens of each | |
| 21 | + model call (input, output, thoughts, cached), filled in | |
| 22 | + `internal/engine/engine.go` from the server's `usage`; only the ACP | |
| 23 | + front end reports it today (`internal/acp/usage.go`). | |
| 24 | + - Some servers already measure it themselves, in a `timings` object | |
| 25 | + beside `usage` in the last streamed chunk (llama.cpp style): | |
| 26 | + `predicted_n`, `predicted_ms`, `predicted_per_second`, | |
| 27 | + `prompt_n`, `prompt_ms`, `prompt_per_second`. Seen on MLX-Serve | |
| 28 | + 26.11.3 (2026-11-24): `"timings":{"prompt_n":59,"prompt_ms":265.17, | |
| 29 | + "prompt_per_second":222.5,"predicted_n":14,"predicted_ms":283.09, | |
| 30 | + "predicted_per_second":49.45}`. To check: llama-server, llmman, DMR, | |
| 31 | + Kronk, Ollama. | |
| 32 | + | |
| 33 | + ## Two sources, in this order | |
| 34 | + 1. **The server's `timings`** when present: exact, and it separates | |
| 35 | + prompt reading (prefill) from generation (decode). Read it in the SSE | |
| 36 | + tap (`internal/engine/reasoning.go`), as prompt_progress already is. | |
| 37 | + 2. **Measured by mm** otherwise: output tokens (`usage.completion_tokens`, | |
| 38 | + reasoning included) divided by the time from the FIRST streamed token to | |
| 39 | + the last. Not from the request start, which would count the prompt | |
| 40 | + reading. Without `usage`, an estimate from the streamed text is worse: | |
| 41 | + say it is an estimate, or show nothing. | |
| 42 | + | |
| 43 | + ## Points to decide | |
| 44 | + - Where to show it: the end-of-turn line (`⚙ N command(s) · …`), the | |
| 45 | + window's status bar, the banner? Per model call, or one figure per turn | |
| 46 | + (sum of tokens / sum of decode time)? | |
| 47 | + - Show prefill speed too (`prompt_per_second`), useful for long contexts? | |
| 48 | + - Off by default or on? A config key (`showSpeed`?) and/or a `/stats` | |
| 49 | + command. | |
| 50 | + - ACP: report it through the usage update, or not at all. | |
| 51 | + - Store it in sessions / traces for later comparison? | |
| 52 | + | |
| 53 | + ## Acceptance criteria | |
| 54 | + - The speed shown matches the server's `predicted_per_second` when the | |
| 55 | + server gives one, and is close to it (same order of magnitude) when mm measures it. | |
| 56 | + - Nothing shown, and no error, when neither source is available. | |
| 57 | + - Unit tests with fake streams (with and without `timings`, with and | |
| 58 | + without `usage`); EN+FR docs. | |
| 59 | +tasks: | |
| 60 | + - id: 1 | |
| 61 | + title: List which servers send timings (llama-server, llmman, DMR, Kronk, Ollama, MLX-Serve) | |
| 62 | + state: open | |
| 63 | + priority: high | |
| 64 | + author: | |
| 65 | + name: k33g | |
| 66 | + email: ph.charriere@gmail.com | |
| 67 | + createdAt: 2026-11-24T06:32:51.000Z | |
| 68 | + - id: 2 | |
| 69 | + title: Read timings in the SSE tap; measure first-to-last token time as fallback | |
| 70 | + state: open | |
| 71 | + priority: none | |
| 72 | + author: | |
| 73 | + name: k33g | |
| 74 | + email: ph.charriere@gmail.com | |
| 75 | + createdAt: 2026-11-24T06:32:51.000Z | |
| 76 | + - id: 3 | |
| 77 | + title: Show the speed in the terminal, the window and (maybe) ACP | |
| 78 | + state: open | |
| 79 | + priority: none | |
| 80 | + author: | |
| 81 | + name: k33g | |
| 82 | + email: ph.charriere@gmail.com | |
| 83 | + createdAt: 2026-11-24T06:32:51.000Z | |
| 84 | + - id: 4 | |
| 85 | + title: Tests and EN+FR docs | |
| 86 | + state: open | |
| 87 | + priority: none | |
| 88 | + author: | |
| 89 | + name: k33g | |
| 90 | + email: ph.charriere@gmail.com | |
| 91 | + createdAt: 2026-11-24T06:32:51.000Z | |
| 92 | +comments: [] | |
| new file mode 100644 | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 254 | ||
| 3 | +title: Measure and show the token generation speed (tokens/s) | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-24T06:32:51.000Z | ||
| 9 | +updatedAt: 2026-11-24T06:32:51.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | +epic: Providers (LLM Engine) | ||
| 14 | +body: | | ||
| 15 | + Compute the model's generation speed and show it to the user, e.g. | ||
| 16 | + `⚡ 48.2 tok/s` after an answer, so models, quantisations and servers can | ||
| 17 | + be compared from inside mm. | ||
| 18 | + | ||
| 19 | + ## What exists | ||
| 20 | + - `ui.Usage` (`internal/ui/ui.go`) already carries the tokens of each | ||
| 21 | + model call (input, output, thoughts, cached), filled in | ||
| 22 | + `internal/engine/engine.go` from the server's `usage`; only the ACP | ||
| 23 | + front end reports it today (`internal/acp/usage.go`). | ||
| 24 | + - Some servers already measure it themselves, in a `timings` object | ||
| 25 | + beside `usage` in the last streamed chunk (llama.cpp style): | ||
| 26 | + `predicted_n`, `predicted_ms`, `predicted_per_second`, | ||
| 27 | + `prompt_n`, `prompt_ms`, `prompt_per_second`. Seen on MLX-Serve | ||
| 28 | + 26.11.3 (2026-11-24): `"timings":{"prompt_n":59,"prompt_ms":265.17, | ||
| 29 | + "prompt_per_second":222.5,"predicted_n":14,"predicted_ms":283.09, | ||
| 30 | + "predicted_per_second":49.45}`. To check: llama-server, llmman, DMR, | ||
| 31 | + Kronk, Ollama. | ||
| 32 | + | ||
| 33 | + ## Two sources, in this order | ||
| 34 | + 1. **The server's `timings`** when present: exact, and it separates | ||
| 35 | + prompt reading (prefill) from generation (decode). Read it in the SSE | ||
| 36 | + tap (`internal/engine/reasoning.go`), as prompt_progress already is. | ||
| 37 | + 2. **Measured by mm** otherwise: output tokens (`usage.completion_tokens`, | ||
| 38 | + reasoning included) divided by the time from the FIRST streamed token to | ||
| 39 | + the last. Not from the request start, which would count the prompt | ||
| 40 | + reading. Without `usage`, an estimate from the streamed text is worse: | ||
| 41 | + say it is an estimate, or show nothing. | ||
| 42 | + | ||
| 43 | + ## Points to decide | ||
| 44 | + - Where to show it: the end-of-turn line (`⚙ N command(s) · …`), the | ||
| 45 | + window's status bar, the banner? Per model call, or one figure per turn | ||
| 46 | + (sum of tokens / sum of decode time)? | ||
| 47 | + - Show prefill speed too (`prompt_per_second`), useful for long contexts? | ||
| 48 | + - Off by default or on? A config key (`showSpeed`?) and/or a `/stats` | ||
| 49 | + command. | ||
| 50 | + - ACP: report it through the usage update, or not at all. | ||
| 51 | + - Store it in sessions / traces for later comparison? | ||
| 52 | + | ||
| 53 | + ## Acceptance criteria | ||
| 54 | + - The speed shown matches the server's `predicted_per_second` when the | ||
| 55 | + server gives one, and is close to it (same order of magnitude) when mm measures it. | ||
| 56 | + - Nothing shown, and no error, when neither source is available. | ||
| 57 | + - Unit tests with fake streams (with and without `timings`, with and | ||
| 58 | + without `usage`); EN+FR docs. | ||
| 59 | +tasks: | ||
| 60 | + - id: 1 | ||
| 61 | + title: List which servers send timings (llama-server, llmman, DMR, Kronk, Ollama, MLX-Serve) | ||
| 62 | + state: open | ||
| 63 | + priority: high | ||
| 64 | + author: | ||
| 65 | + name: k33g | ||
| 66 | + email: ph.charriere@gmail.com | ||
| 67 | + createdAt: 2026-11-24T06:32:51.000Z | ||
| 68 | + - id: 2 | ||
| 69 | + title: Read timings in the SSE tap; measure first-to-last token time as fallback | ||
| 70 | + state: open | ||
| 71 | + priority: none | ||
| 72 | + author: | ||
| 73 | + name: k33g | ||
| 74 | + email: ph.charriere@gmail.com | ||
| 75 | + createdAt: 2026-11-24T06:32:51.000Z | ||
| 76 | + - id: 3 | ||
| 77 | + title: Show the speed in the terminal, the window and (maybe) ACP | ||
| 78 | + state: open | ||
| 79 | + priority: none | ||
| 80 | + author: | ||
| 81 | + name: k33g | ||
| 82 | + email: ph.charriere@gmail.com | ||
| 83 | + createdAt: 2026-11-24T06:32:51.000Z | ||
| 84 | + - id: 4 | ||
| 85 | + title: Tests and EN+FR docs | ||
| 86 | + state: open | ||
| 87 | + priority: none | ||
| 88 | + author: | ||
| 89 | + name: k33g | ||
| 90 | + email: ph.charriere@gmail.com | ||
| 91 | + createdAt: 2026-11-24T06:32:51.000Z | ||
| 92 | +comments: [] | ||
added
.tickets/issues/0255-unload-the-model-when-mini-me-exits-unloadonexit.yaml +100 -0 | new file mode 100644 | ||
| @@ -0,0 +1,100 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 255 | |
| 3 | +title: Unload the model when mini-me exits (unloadOnExit, on by default) | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-24T07:02:40.000Z | |
| 9 | +updatedAt: 2026-11-24T07:02:40.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | +epic: Providers (LLM Engine) | |
| 14 | +related: | |
| 15 | + - 101 | |
| 16 | + - 223 | |
| 17 | +body: | | |
| 18 | + When mm exits, unload the agent's model from the server's memory, so a | |
| 19 | + model is not left taking GB of RAM / VRAM after the session. **On by | |
| 20 | + default**, switched off in the agent file: | |
| 21 | + | |
| 22 | + ```yaml | |
| 23 | + # Unload the model from the server's memory when mm exits. | |
| 24 | + # false: leave it loaded (faster next start, or another tool uses it). | |
| 25 | + unloadOnExit: true | |
| 26 | + ``` | |
| 27 | + | |
| 28 | + ## What exists | |
| 29 | + - `engine.Engine.Unload(ctx, model)` (ticket 101, | |
| 30 | + [#101](.tickets/issues/0101-unload-a-model-from-memory-unload-command-and-un.yaml)): | |
| 31 | + one line, never an error, per provider — llmman/ollama (keep_alive 0), | |
| 32 | + kronk, mlxserve, llamacpp in router mode; dmr and openai cannot (say | |
| 33 | + nothing on exit for those). | |
| 34 | + - Ticket 92 noted "an unload on exit would be a follow-up, not done". | |
| 35 | + | |
| 36 | + ## When "exit" happens | |
| 37 | + Every way out: `/quit`, Ctrl-D / Ctrl-C in the terminal, closing the | |
| 38 | + window (`-tui`), end of a `-p` run, ACP session closed / editor | |
| 39 | + reloaded, SIGTERM. Not on a crash (nothing to do), and bounded in time: | |
| 40 | + a server that does not answer must not hold the exit (short timeout, e.g. | |
| 41 | + 2–3 s). | |
| 42 | + | |
| 43 | + ## Points to decide | |
| 44 | + - **Default true changes the behaviour of every existing agent file**: | |
| 45 | + release note, and `mm init` writes the key with its comment. | |
| 46 | + - `-p` runs: unloading after each one-shot run makes the next one | |
| 47 | + reload the model (slow in a loop/script). Same default, or off for | |
| 48 | + `-p` unless the file says true? | |
| 49 | + - **Other users of the same model**: another mm session, another agent, | |
| 50 | + another tool on the same server. Unloading would cut them. Link with | |
| 51 | + the lease idea of [#223](.tickets/issues/0223-llamacpp-start-llama-server-when-it-is-not-runnin.yaml) | |
| 52 | + (one lease per running mm process; the last one unloads)? | |
| 53 | + - Which models: only the agent's own, or also the models it loaded | |
| 54 | + through `mmConfigs` agents and the skill/tool-routing deciders? | |
| 55 | + - Should `unloadModels: false` (which removes /unload and the tool) | |
| 56 | + also turn this off, or are the two independent? | |
| 57 | + - What to print: one line `🧹 unloaded <model>` on stderr, nothing in | |
| 58 | + ACP mode? | |
| 59 | + | |
| 60 | + ## Acceptance criteria | |
| 61 | + - Default: quitting mm unloads the model on a provider that can unload | |
| 62 | + (checked live on at least llmman/ollama and mlxserve). | |
| 63 | + - `unloadOnExit: false`: the model stays loaded. | |
| 64 | + - The exit is never delayed more than the timeout when the server is down. | |
| 65 | + - Unit tests (fake server: unload called once on exit, not called when | |
| 66 | + false, timeout respected); configuration reference EN+FR. | |
| 67 | +tasks: | |
| 68 | + - id: 1 | |
| 69 | + title: Config key unloadOnExit (default true), validation, mm init writes it | |
| 70 | + state: open | |
| 71 | + priority: none | |
| 72 | + author: | |
| 73 | + name: k33g | |
| 74 | + email: ph.charriere@gmail.com | |
| 75 | + createdAt: 2026-11-24T07:02:40.000Z | |
| 76 | + - id: 2 | |
| 77 | + title: Call Engine.Unload on every exit path (terminal, window, -p, ACP, signals) with a short timeout | |
| 78 | + state: open | |
| 79 | + priority: high | |
| 80 | + author: | |
| 81 | + name: k33g | |
| 82 | + email: ph.charriere@gmail.com | |
| 83 | + createdAt: 2026-11-24T07:02:40.000Z | |
| 84 | + - id: 3 | |
| 85 | + title: Decide -p behaviour and other users of the same model (see #223) | |
| 86 | + state: open | |
| 87 | + priority: medium | |
| 88 | + author: | |
| 89 | + name: k33g | |
| 90 | + email: ph.charriere@gmail.com | |
| 91 | + createdAt: 2026-11-24T07:02:40.000Z | |
| 92 | + - id: 4 | |
| 93 | + title: Tests, EN+FR docs, release note (behaviour change) | |
| 94 | + state: open | |
| 95 | + priority: none | |
| 96 | + author: | |
| 97 | + name: k33g | |
| 98 | + email: ph.charriere@gmail.com | |
| 99 | + createdAt: 2026-11-24T07:02:40.000Z | |
| 100 | +comments: [] | |
| new file mode 100644 | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 255 | ||
| 3 | +title: Unload the model when mini-me exits (unloadOnExit, on by default) | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-24T07:02:40.000Z | ||
| 9 | +updatedAt: 2026-11-24T07:02:40.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | +epic: Providers (LLM Engine) | ||
| 14 | +related: | ||
| 15 | + - 101 | ||
| 16 | + - 223 | ||
| 17 | +body: | | ||
| 18 | + When mm exits, unload the agent's model from the server's memory, so a | ||
| 19 | + model is not left taking GB of RAM / VRAM after the session. **On by | ||
| 20 | + default**, switched off in the agent file: | ||
| 21 | + | ||
| 22 | + ```yaml | ||
| 23 | + # Unload the model from the server's memory when mm exits. | ||
| 24 | + # false: leave it loaded (faster next start, or another tool uses it). | ||
| 25 | + unloadOnExit: true | ||
| 26 | + ``` | ||
| 27 | + | ||
| 28 | + ## What exists | ||
| 29 | + - `engine.Engine.Unload(ctx, model)` (ticket 101, | ||
| 30 | + [#101](.tickets/issues/0101-unload-a-model-from-memory-unload-command-and-un.yaml)): | ||
| 31 | + one line, never an error, per provider — llmman/ollama (keep_alive 0), | ||
| 32 | + kronk, mlxserve, llamacpp in router mode; dmr and openai cannot (say | ||
| 33 | + nothing on exit for those). | ||
| 34 | + - Ticket 92 noted "an unload on exit would be a follow-up, not done". | ||
| 35 | + | ||
| 36 | + ## When "exit" happens | ||
| 37 | + Every way out: `/quit`, Ctrl-D / Ctrl-C in the terminal, closing the | ||
| 38 | + window (`-tui`), end of a `-p` run, ACP session closed / editor | ||
| 39 | + reloaded, SIGTERM. Not on a crash (nothing to do), and bounded in time: | ||
| 40 | + a server that does not answer must not hold the exit (short timeout, e.g. | ||
| 41 | + 2–3 s). | ||
| 42 | + | ||
| 43 | + ## Points to decide | ||
| 44 | + - **Default true changes the behaviour of every existing agent file**: | ||
| 45 | + release note, and `mm init` writes the key with its comment. | ||
| 46 | + - `-p` runs: unloading after each one-shot run makes the next one | ||
| 47 | + reload the model (slow in a loop/script). Same default, or off for | ||
| 48 | + `-p` unless the file says true? | ||
| 49 | + - **Other users of the same model**: another mm session, another agent, | ||
| 50 | + another tool on the same server. Unloading would cut them. Link with | ||
| 51 | + the lease idea of [#223](.tickets/issues/0223-llamacpp-start-llama-server-when-it-is-not-runnin.yaml) | ||
| 52 | + (one lease per running mm process; the last one unloads)? | ||
| 53 | + - Which models: only the agent's own, or also the models it loaded | ||
| 54 | + through `mmConfigs` agents and the skill/tool-routing deciders? | ||
| 55 | + - Should `unloadModels: false` (which removes /unload and the tool) | ||
| 56 | + also turn this off, or are the two independent? | ||
| 57 | + - What to print: one line `🧹 unloaded <model>` on stderr, nothing in | ||
| 58 | + ACP mode? | ||
| 59 | + | ||
| 60 | + ## Acceptance criteria | ||
| 61 | + - Default: quitting mm unloads the model on a provider that can unload | ||
| 62 | + (checked live on at least llmman/ollama and mlxserve). | ||
| 63 | + - `unloadOnExit: false`: the model stays loaded. | ||
| 64 | + - The exit is never delayed more than the timeout when the server is down. | ||
| 65 | + - Unit tests (fake server: unload called once on exit, not called when | ||
| 66 | + false, timeout respected); configuration reference EN+FR. | ||
| 67 | +tasks: | ||
| 68 | + - id: 1 | ||
| 69 | + title: Config key unloadOnExit (default true), validation, mm init writes it | ||
| 70 | + state: open | ||
| 71 | + priority: none | ||
| 72 | + author: | ||
| 73 | + name: k33g | ||
| 74 | + email: ph.charriere@gmail.com | ||
| 75 | + createdAt: 2026-11-24T07:02:40.000Z | ||
| 76 | + - id: 2 | ||
| 77 | + title: Call Engine.Unload on every exit path (terminal, window, -p, ACP, signals) with a short timeout | ||
| 78 | + state: open | ||
| 79 | + priority: high | ||
| 80 | + author: | ||
| 81 | + name: k33g | ||
| 82 | + email: ph.charriere@gmail.com | ||
| 83 | + createdAt: 2026-11-24T07:02:40.000Z | ||
| 84 | + - id: 3 | ||
| 85 | + title: Decide -p behaviour and other users of the same model (see #223) | ||
| 86 | + state: open | ||
| 87 | + priority: medium | ||
| 88 | + author: | ||
| 89 | + name: k33g | ||
| 90 | + email: ph.charriere@gmail.com | ||
| 91 | + createdAt: 2026-11-24T07:02:40.000Z | ||
| 92 | + - id: 4 | ||
| 93 | + title: Tests, EN+FR docs, release note (behaviour change) | ||
| 94 | + state: open | ||
| 95 | + priority: none | ||
| 96 | + author: | ||
| 97 | + name: k33g | ||
| 98 | + email: ph.charriere@gmail.com | ||
| 99 | + createdAt: 2026-11-24T07:02:40.000Z | ||
| 100 | +comments: [] | ||
added
.tickets/issues/0256-mm-init-always-propose-llamacpp-as-the-default-server.yaml +83 -0 | new file mode 100644 | ||
| @@ -0,0 +1,83 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 256 | |
| 3 | +title: "mm init: always propose llamacpp as the default server" | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-24T07:16:50.000Z | |
| 9 | +updatedAt: 2026-11-24T07:16:50.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | +epic: Scaffolding | |
| 14 | +related: | |
| 15 | + - 221 | |
| 16 | +body: | | |
| 17 | + ## Asked (user, 2026-11-24) | |
| 18 | + | |
| 19 | + In `mm init`, the server shown by default is still `llmman`; it must be | |
| 20 | + `llamacpp`. | |
| 21 | + | |
| 22 | + ## Why it still happens (code read 2026-11-24) | |
| 23 | + | |
| 24 | + [#221](.tickets/issues/0221-mm-init-llamacpp-as-the-default-server-instead-of.yaml) | |
| 25 | + chose "llamacpp **first among the servers that answer**": it moved | |
| 26 | + llamacpp first in `providers` and `local` | |
| 27 | + ([internal/agentinit/wizard.go](internal/agentinit/wizard.go)), but the | |
| 28 | + default is still `Flow.firstAnswering()` | |
| 29 | + ([internal/agentinit/flow.go](internal/agentinit/flow.go), `st.Default = | |
| 30 | + f.firstAnswering()`): the first server of `local` that answers, and | |
| 31 | + `providers[0]` only when none does. With llmman running and llama-server | |
| 32 | + not (no answer on 9931 nor 8080), the default is llmman. | |
| 33 | + | |
| 34 | + ## Wanted | |
| 35 | + | |
| 36 | + `llamacpp` is the default of the first question **whatever answers**. | |
| 37 | + The list keeps showing, for each local server, "answers" / "does not | |
| 38 | + answer", so a running llmman or Ollama is still visible and one keystroke | |
| 39 | + away. | |
| 40 | + | |
| 41 | + ## Points to check | |
| 42 | + - Same default in the line mode, the window and `mm acp-create` (same | |
| 43 | + `Flow`); `--provider` and `--yes` unchanged — with `--yes` and no | |
| 44 | + `--provider`, llamacpp too, even when it does not answer (then the | |
| 45 | + model list is empty: what does `--yes` do?). | |
| 46 | + - When llamacpp does not answer, say it on the default (e.g. the detail | |
| 47 | + "does not answer — start llama-server") rather than silently propose a | |
| 48 | + dead server. | |
| 49 | + - Is `firstAnswering` still needed (the address choice, other callers)? | |
| 50 | + Remove it if nothing else uses it. | |
| 51 | + | |
| 52 | + ## Acceptance criteria | |
| 53 | + - llmman running, llama-server not: default `llamacpp`. | |
| 54 | + - llama-server running: default `llamacpp`. Nothing running: `llamacpp`. | |
| 55 | + - Tests updated (`wizard_test.go` cases of `firstAnswering`); docs EN+FR | |
| 56 | + that describe the default (create-an-agent, create-an-agent-from-an-editor, | |
| 57 | + cli reference, explanation/mm-init). | |
| 58 | +tasks: | |
| 59 | + - id: 1 | |
| 60 | + title: Default of the provider question = llamacpp, not the first that answers | |
| 61 | + state: open | |
| 62 | + priority: high | |
| 63 | + author: | |
| 64 | + name: k33g | |
| 65 | + email: ph.charriere@gmail.com | |
| 66 | + createdAt: 2026-11-24T07:16:50.000Z | |
| 67 | + - id: 2 | |
| 68 | + title: Behaviour of --yes when llamacpp does not answer | |
| 69 | + state: open | |
| 70 | + priority: medium | |
| 71 | + author: | |
| 72 | + name: k33g | |
| 73 | + email: ph.charriere@gmail.com | |
| 74 | + createdAt: 2026-11-24T07:16:50.000Z | |
| 75 | + - id: 3 | |
| 76 | + title: Tests and EN+FR docs | |
| 77 | + state: open | |
| 78 | + priority: none | |
| 79 | + author: | |
| 80 | + name: k33g | |
| 81 | + email: ph.charriere@gmail.com | |
| 82 | + createdAt: 2026-11-24T07:16:50.000Z | |
| 83 | +comments: [] | |
| new file mode 100644 | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 256 | ||
| 3 | +title: "mm init: always propose llamacpp as the default server" | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-24T07:16:50.000Z | ||
| 9 | +updatedAt: 2026-11-24T07:16:50.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | +epic: Scaffolding | ||
| 14 | +related: | ||
| 15 | + - 221 | ||
| 16 | +body: | | ||
| 17 | + ## Asked (user, 2026-11-24) | ||
| 18 | + | ||
| 19 | + In `mm init`, the server shown by default is still `llmman`; it must be | ||
| 20 | + `llamacpp`. | ||
| 21 | + | ||
| 22 | + ## Why it still happens (code read 2026-11-24) | ||
| 23 | + | ||
| 24 | + [#221](.tickets/issues/0221-mm-init-llamacpp-as-the-default-server-instead-of.yaml) | ||
| 25 | + chose "llamacpp **first among the servers that answer**": it moved | ||
| 26 | + llamacpp first in `providers` and `local` | ||
| 27 | + ([internal/agentinit/wizard.go](internal/agentinit/wizard.go)), but the | ||
| 28 | + default is still `Flow.firstAnswering()` | ||
| 29 | + ([internal/agentinit/flow.go](internal/agentinit/flow.go), `st.Default = | ||
| 30 | + f.firstAnswering()`): the first server of `local` that answers, and | ||
| 31 | + `providers[0]` only when none does. With llmman running and llama-server | ||
| 32 | + not (no answer on 9931 nor 8080), the default is llmman. | ||
| 33 | + | ||
| 34 | + ## Wanted | ||
| 35 | + | ||
| 36 | + `llamacpp` is the default of the first question **whatever answers**. | ||
| 37 | + The list keeps showing, for each local server, "answers" / "does not | ||
| 38 | + answer", so a running llmman or Ollama is still visible and one keystroke | ||
| 39 | + away. | ||
| 40 | + | ||
| 41 | + ## Points to check | ||
| 42 | + - Same default in the line mode, the window and `mm acp-create` (same | ||
| 43 | + `Flow`); `--provider` and `--yes` unchanged — with `--yes` and no | ||
| 44 | + `--provider`, llamacpp too, even when it does not answer (then the | ||
| 45 | + model list is empty: what does `--yes` do?). | ||
| 46 | + - When llamacpp does not answer, say it on the default (e.g. the detail | ||
| 47 | + "does not answer — start llama-server") rather than silently propose a | ||
| 48 | + dead server. | ||
| 49 | + - Is `firstAnswering` still needed (the address choice, other callers)? | ||
| 50 | + Remove it if nothing else uses it. | ||
| 51 | + | ||
| 52 | + ## Acceptance criteria | ||
| 53 | + - llmman running, llama-server not: default `llamacpp`. | ||
| 54 | + - llama-server running: default `llamacpp`. Nothing running: `llamacpp`. | ||
| 55 | + - Tests updated (`wizard_test.go` cases of `firstAnswering`); docs EN+FR | ||
| 56 | + that describe the default (create-an-agent, create-an-agent-from-an-editor, | ||
| 57 | + cli reference, explanation/mm-init). | ||
| 58 | +tasks: | ||
| 59 | + - id: 1 | ||
| 60 | + title: Default of the provider question = llamacpp, not the first that answers | ||
| 61 | + state: open | ||
| 62 | + priority: high | ||
| 63 | + author: | ||
| 64 | + name: k33g | ||
| 65 | + email: ph.charriere@gmail.com | ||
| 66 | + createdAt: 2026-11-24T07:16:50.000Z | ||
| 67 | + - id: 2 | ||
| 68 | + title: Behaviour of --yes when llamacpp does not answer | ||
| 69 | + state: open | ||
| 70 | + priority: medium | ||
| 71 | + author: | ||
| 72 | + name: k33g | ||
| 73 | + email: ph.charriere@gmail.com | ||
| 74 | + createdAt: 2026-11-24T07:16:50.000Z | ||
| 75 | + - id: 3 | ||
| 76 | + title: Tests and EN+FR docs | ||
| 77 | + state: open | ||
| 78 | + priority: none | ||
| 79 | + author: | ||
| 80 | + name: k33g | ||
| 81 | + email: ph.charriere@gmail.com | ||
| 82 | + createdAt: 2026-11-24T07:16:50.000Z | ||
| 83 | +comments: [] | ||
modified
README.md +6 -4 | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | |
| 9 | 9 | Mini Me started as the preparation of a *Tools-in-Action* talk for **Devoxx Belgium 2026**, where I explain how an **agent loop** works with a single tool: `bash`. The model asks for a command, the agent runs it, the output goes back to the model, and so on until the model answers. |
| 10 | 10 | |
| 11 | -From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk): small enough to be read in an afternoon, and careful about what a small model does wrong: | |
| 11 | +From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk, MLX-Serve): small enough to be read in an afternoon, and careful about what a small model does wrong: | |
| 12 | 12 | |
| 13 | 13 | - **hallucinations** — the agent shows the real output of every command before the model comments on it, and the prompt forbids stating anything a command did not return; |
| 14 | 14 | - **silent failures** — a failing command, a refused edit or a rejected permission goes back to the model as text, so it reads why and tries something else; |
| @@ -20,7 +20,7 @@ What makes Mini Me a bit special is that it was designed from the start to be us | ||
| 20 | 20 | |
| 21 | 21 | ## Install |
| 22 | 22 | |
| 23 | -You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key). | |
| 23 | +You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), or [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key). | |
| 24 | 24 | |
| 25 | 25 | ```bash |
| 26 | 26 | git clone https://git.rickub.com/bots-garden/mini-me.git |
| @@ -44,7 +44,7 @@ Then pick a configuration file. Copy one to `agent.yaml` in your project and adj | ||
| 44 | 44 | | `agent.lsp.yaml` | the same agent with a language server behind an `lsp` tool | |
| 45 | 45 | | `agent.mcp-example.yaml` | the same agent with MCP servers | |
| 46 | 46 | |
| 47 | -For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`. | |
| 47 | +For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`; for MLX-Serve, [Run mini-me on MLX-Serve](docs/en/how-to/run-with-mlx-serve.md) and `demos/mlx-gemma-4-e4b/`. | |
| 48 | 48 | |
| 49 | 49 | Or let `mm init` write the file for you: see [More features](#more-features). To keep a project's mini-me files together, put the agent in `.mm/agent.yaml`: `mm` finds it on its own, and its paths are written from the project root — see [Keep a project's mini-me files in a `.mm` folder](docs/en/how-to/keep-the-config-in-a-mm-folder.md). |
| 50 | 50 | |
| @@ -150,6 +150,7 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | ||
| 150 | 150 | | `demos/llmman/` | mm on llmman, and an agent that asks other agents | |
| 151 | 151 | | `demos/ollama/` | mm on Ollama | |
| 152 | 152 | | `demos/kronk/` | mm on Kronk, a coding agent with `mradermacher/Qwopus3.5-4B-Coder.Q8_0`, and the line to change for Qwen3.5 2B | |
| 153 | +| `demos/mlx-gemma-4-e4b/` | mm on MLX-Serve, an agent in a `.mm` folder for `lmstudio-community/gemma-4-E4B-it-MLX-8bit` | | |
| 153 | 154 | | `demos/smollm3-demo/` | an agent written by `mm init` for SmolLM3-3B in a `.mm` folder, with `toolFormat: xml_tools` and reasoning off | |
| 154 | 155 | | `demos/structured-output/` | agents that answer in JSON, and a coordinator using them | |
| 155 | 156 | | `demos/structured-output-pizza/` | one JSON agent declared with Go types: a pizza's name → its ingredients (quantity, unit, category, allergens), whether it is vegetarian, its baking time (Gemma 4 E4B on llmman) | |
| @@ -171,13 +172,14 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | ||
| 171 | 172 | | `demos/gemini-style/` | the same idea with Gemini CLI's system prompt (Research → Strategy → Execution, Directives vs Inquiries, Context Efficiency), adapted to mm and to Gemma 4 26B-A4B on llmman; reads `GEMINI.md`; measured results | |
| 172 | 173 | | `demos/gemma-coder/` | a Go specialist for vibe coding on the same model as `gemini-style` (Gemma 4 26B-A4B, thinking on, gopls for `lsp`, `yolo: true`): writes the code and its tests, validates with `go build`/`go test`, commits without asking back; diagrams of the loop and of the settings chosen; measured 16/18 on nine Go cases | |
| 173 | 174 | | `demos/muse-coder/` | the Swift counterpart of `gemma-coder` on Muse-Glimmer 30B (`reasoning_strength: high`, sourcekit-lsp for `lsp`, `yolo: true`, SwiftPM + Swift Testing): measured 17/18 on nine Swift cases, the real binary run on fresh input; `lsp rename` only works across files after a build (measured), and `medium` reasoning scored 2/6 against 5/6 for `high` on the long cases | |
| 174 | -| `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/` | | |
| 175 | +| `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/`, with Go notes for `search_docs`, Context7 and seven skills (added 2026-11-23, not measured) | | |
| 175 | 176 | | `demos/codex-style/` | the same idea with Codex CLI's default instructions (preambles, plans, ambition vs. precision, final-answer format), adapted to mm and to gpt-oss 20B (harmony format, `reasoning_effort`, `model_identity`) on llmman; measured results | |
| 176 | 177 | | `demos/news-roundup/` | a press-review agent: DuckDuckGo News through a small MCP server (Python standard library), Qwen3.5 9B on llmman, ready-made citations so no article is invented, measured results | |
| 177 | 178 | | `demos/project-wizard/` | the interactive prompts (`ask_user`) in a small agent: a four-question form (text, two choices, several choices), then a yes/no confirmation carrying the plan before any file is written; Qwen3.5 9B on llmman, measured results | |
| 178 | 179 | | `demos/hooks/` | hooks in Node.js around a small shell assistant (Gemma 4 E4B on llmman): a question holding a secret never reaches the model, today's date and the file list are added to every question, `rm -r` / `sudo` / `curl \| sh` are denied, every tool call and turn is logged to `.mm/hooks-audit.jsonl` | |
| 179 | 180 | | `demos/hooks-ask/` | `preAsk` and `postAsk` hooks in Node.js around a help desk that hands technical questions to an expert agent (both Gemma 4 E4B on llmman): secrets masked before they leave, at most 2 `ask_agent` calls per question, standing rules added for the expert, a failed hand-off turned into an instruction, every hand-off logged to `.mm/ask-audit.jsonl` | |
| 180 | 181 | | `demos/dungeon/` | a solo role-playing game in the style of Dungeons & Dragons, same principle as `demos/team`: a Game Master hands each action to a storyteller, a referee or a scribe (Qwen3.5 4B on llmman for all four); real dice and the hero sheet in shell scripts, each specialist kept to its commands by a `preToolCall` hook; measured results | |
| 182 | +| `demos/olala-mini-dnd/` | a role-playing NPC you talk to: Maëlle, innkeeper of a fantasy village, played by Olala-v1.0-mini on Blade (the model of `demos/olala-mini`) with one tool, `search_docs`: her character sheet, prices, rumours, trusted facts and a secret behind a condition live in `.mm/npc.md` (`agentsMd.path`), her family, story, clothes, pastimes, friends and tastes in `.mm/lore/`, which she searches before talking about them (French words in each heading for a French player); the rules of the role in `turnReminder`; not measured yet | | |
| 181 | 183 | | `demos/coding-helpers/` | interactive documentation for Go and Rust: a coordinator (MiniCPM5 2B) hands each question to a Go or a Rust specialist (Mellum2 12B thinking) with `ask_agent` and the conversation (`with_context`), so "the same thing in Rust" works; explanations and snippets, a full program only on request; measured results | |
| 182 | 184 | | `demos/programming-answers/` | a tutorial writer tuned for Mellum2.1 12B Thinking on llmman ("write me a Nu shell tutorial"), with the settings chosen and why; the original configuration kept as `agent.orig.yaml` | |
| 183 | 185 | | `demos/programming-answers-2/` | **Tuto**: an agent that answers with mini tutorials in the conversation and saves one to Markdown only when asked (`fetch_content` + `save_answer`), Mellum2.1 12B Thinking on llmman, measured results | |
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | Mini Me started as the preparation of a *Tools-in-Action* talk for **Devoxx Belgium 2026**, where I explain how an **agent loop** works with a single tool: `bash`. The model asks for a command, the agent runs it, the output goes back to the model, and so on until the model answers. | 9 | Mini Me started as the preparation of a *Tools-in-Action* talk for **Devoxx Belgium 2026**, where I explain how an **agent loop** works with a single tool: `bash`. The model asks for a command, the agent runs it, the output goes back to the model, and so on until the model answers. |
| 10 | 10 | ||
| 11 | -From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk): small enough to be read in an afternoon, and careful about what a small model does wrong: | 11 | +From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk, MLX-Serve): small enough to be read in an afternoon, and careful about what a small model does wrong: |
| 12 | 12 | ||
| 13 | - **hallucinations** — the agent shows the real output of every command before the model comments on it, and the prompt forbids stating anything a command did not return; | 13 | - **hallucinations** — the agent shows the real output of every command before the model comments on it, and the prompt forbids stating anything a command did not return; |
| 14 | - **silent failures** — a failing command, a refused edit or a rejected permission goes back to the model as text, so it reads why and tries something else; | 14 | - **silent failures** — a failing command, a refused edit or a rejected permission goes back to the model as text, so it reads why and tries something else; |
| @@ -20,7 +20,7 @@ What makes Mini Me a bit special is that it was designed from the start to be us | |||
| 20 | 20 | ||
| 21 | ## Install | 21 | ## Install |
| 22 | 22 | ||
| 23 | -You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key). | 23 | +You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), or [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key). |
| 24 | 24 | ||
| 25 | ```bash | 25 | ```bash |
| 26 | git clone https://git.rickub.com/bots-garden/mini-me.git | 26 | git clone https://git.rickub.com/bots-garden/mini-me.git |
| @@ -44,7 +44,7 @@ Then pick a configuration file. Copy one to `agent.yaml` in your project and adj | |||
| 44 | | `agent.lsp.yaml` | the same agent with a language server behind an `lsp` tool | | 44 | | `agent.lsp.yaml` | the same agent with a language server behind an `lsp` tool | |
| 45 | | `agent.mcp-example.yaml` | the same agent with MCP servers | | 45 | | `agent.mcp-example.yaml` | the same agent with MCP servers | |
| 46 | 46 | ||
| 47 | -For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`. | 47 | +For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`; for MLX-Serve, [Run mini-me on MLX-Serve](docs/en/how-to/run-with-mlx-serve.md) and `demos/mlx-gemma-4-e4b/`. |
| 48 | 48 | ||
| 49 | Or let `mm init` write the file for you: see [More features](#more-features). To keep a project's mini-me files together, put the agent in `.mm/agent.yaml`: `mm` finds it on its own, and its paths are written from the project root — see [Keep a project's mini-me files in a `.mm` folder](docs/en/how-to/keep-the-config-in-a-mm-folder.md). | 49 | Or let `mm init` write the file for you: see [More features](#more-features). To keep a project's mini-me files together, put the agent in `.mm/agent.yaml`: `mm` finds it on its own, and its paths are written from the project root — see [Keep a project's mini-me files in a `.mm` folder](docs/en/how-to/keep-the-config-in-a-mm-folder.md). |
| 50 | 50 | ||
| @@ -150,6 +150,7 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | |||
| 150 | | `demos/llmman/` | mm on llmman, and an agent that asks other agents | | 150 | | `demos/llmman/` | mm on llmman, and an agent that asks other agents | |
| 151 | | `demos/ollama/` | mm on Ollama | | 151 | | `demos/ollama/` | mm on Ollama | |
| 152 | | `demos/kronk/` | mm on Kronk, a coding agent with `mradermacher/Qwopus3.5-4B-Coder.Q8_0`, and the line to change for Qwen3.5 2B | | 152 | | `demos/kronk/` | mm on Kronk, a coding agent with `mradermacher/Qwopus3.5-4B-Coder.Q8_0`, and the line to change for Qwen3.5 2B | |
| 153 | +| `demos/mlx-gemma-4-e4b/` | mm on MLX-Serve, an agent in a `.mm` folder for `lmstudio-community/gemma-4-E4B-it-MLX-8bit` | | ||
| 153 | | `demos/smollm3-demo/` | an agent written by `mm init` for SmolLM3-3B in a `.mm` folder, with `toolFormat: xml_tools` and reasoning off | | 154 | | `demos/smollm3-demo/` | an agent written by `mm init` for SmolLM3-3B in a `.mm` folder, with `toolFormat: xml_tools` and reasoning off | |
| 154 | | `demos/structured-output/` | agents that answer in JSON, and a coordinator using them | | 155 | | `demos/structured-output/` | agents that answer in JSON, and a coordinator using them | |
| 155 | | `demos/structured-output-pizza/` | one JSON agent declared with Go types: a pizza's name → its ingredients (quantity, unit, category, allergens), whether it is vegetarian, its baking time (Gemma 4 E4B on llmman) | | 156 | | `demos/structured-output-pizza/` | one JSON agent declared with Go types: a pizza's name → its ingredients (quantity, unit, category, allergens), whether it is vegetarian, its baking time (Gemma 4 E4B on llmman) | |
| @@ -171,13 +172,14 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | |||
| 171 | | `demos/gemini-style/` | the same idea with Gemini CLI's system prompt (Research → Strategy → Execution, Directives vs Inquiries, Context Efficiency), adapted to mm and to Gemma 4 26B-A4B on llmman; reads `GEMINI.md`; measured results | | 172 | | `demos/gemini-style/` | the same idea with Gemini CLI's system prompt (Research → Strategy → Execution, Directives vs Inquiries, Context Efficiency), adapted to mm and to Gemma 4 26B-A4B on llmman; reads `GEMINI.md`; measured results | |
| 172 | | `demos/gemma-coder/` | a Go specialist for vibe coding on the same model as `gemini-style` (Gemma 4 26B-A4B, thinking on, gopls for `lsp`, `yolo: true`): writes the code and its tests, validates with `go build`/`go test`, commits without asking back; diagrams of the loop and of the settings chosen; measured 16/18 on nine Go cases | | 173 | | `demos/gemma-coder/` | a Go specialist for vibe coding on the same model as `gemini-style` (Gemma 4 26B-A4B, thinking on, gopls for `lsp`, `yolo: true`): writes the code and its tests, validates with `go build`/`go test`, commits without asking back; diagrams of the loop and of the settings chosen; measured 16/18 on nine Go cases | |
| 173 | | `demos/muse-coder/` | the Swift counterpart of `gemma-coder` on Muse-Glimmer 30B (`reasoning_strength: high`, sourcekit-lsp for `lsp`, `yolo: true`, SwiftPM + Swift Testing): measured 17/18 on nine Swift cases, the real binary run on fresh input; `lsp rename` only works across files after a build (measured), and `medium` reasoning scored 2/6 against 5/6 for `high` on the long cases | | 174 | | `demos/muse-coder/` | the Swift counterpart of `gemma-coder` on Muse-Glimmer 30B (`reasoning_strength: high`, sourcekit-lsp for `lsp`, `yolo: true`, SwiftPM + Swift Testing): measured 17/18 on nine Swift cases, the real binary run on fresh input; `lsp rename` only works across files after a build (measured), and `medium` reasoning scored 2/6 against 5/6 for `high` on the long cases | |
| 174 | -| `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/` | | 175 | +| `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/`, with Go notes for `search_docs`, Context7 and seven skills (added 2026-11-23, not measured) | |
| 175 | | `demos/codex-style/` | the same idea with Codex CLI's default instructions (preambles, plans, ambition vs. precision, final-answer format), adapted to mm and to gpt-oss 20B (harmony format, `reasoning_effort`, `model_identity`) on llmman; measured results | | 176 | | `demos/codex-style/` | the same idea with Codex CLI's default instructions (preambles, plans, ambition vs. precision, final-answer format), adapted to mm and to gpt-oss 20B (harmony format, `reasoning_effort`, `model_identity`) on llmman; measured results | |
| 176 | | `demos/news-roundup/` | a press-review agent: DuckDuckGo News through a small MCP server (Python standard library), Qwen3.5 9B on llmman, ready-made citations so no article is invented, measured results | | 177 | | `demos/news-roundup/` | a press-review agent: DuckDuckGo News through a small MCP server (Python standard library), Qwen3.5 9B on llmman, ready-made citations so no article is invented, measured results | |
| 177 | | `demos/project-wizard/` | the interactive prompts (`ask_user`) in a small agent: a four-question form (text, two choices, several choices), then a yes/no confirmation carrying the plan before any file is written; Qwen3.5 9B on llmman, measured results | | 178 | | `demos/project-wizard/` | the interactive prompts (`ask_user`) in a small agent: a four-question form (text, two choices, several choices), then a yes/no confirmation carrying the plan before any file is written; Qwen3.5 9B on llmman, measured results | |
| 178 | | `demos/hooks/` | hooks in Node.js around a small shell assistant (Gemma 4 E4B on llmman): a question holding a secret never reaches the model, today's date and the file list are added to every question, `rm -r` / `sudo` / `curl \| sh` are denied, every tool call and turn is logged to `.mm/hooks-audit.jsonl` | | 179 | | `demos/hooks/` | hooks in Node.js around a small shell assistant (Gemma 4 E4B on llmman): a question holding a secret never reaches the model, today's date and the file list are added to every question, `rm -r` / `sudo` / `curl \| sh` are denied, every tool call and turn is logged to `.mm/hooks-audit.jsonl` | |
| 179 | | `demos/hooks-ask/` | `preAsk` and `postAsk` hooks in Node.js around a help desk that hands technical questions to an expert agent (both Gemma 4 E4B on llmman): secrets masked before they leave, at most 2 `ask_agent` calls per question, standing rules added for the expert, a failed hand-off turned into an instruction, every hand-off logged to `.mm/ask-audit.jsonl` | | 180 | | `demos/hooks-ask/` | `preAsk` and `postAsk` hooks in Node.js around a help desk that hands technical questions to an expert agent (both Gemma 4 E4B on llmman): secrets masked before they leave, at most 2 `ask_agent` calls per question, standing rules added for the expert, a failed hand-off turned into an instruction, every hand-off logged to `.mm/ask-audit.jsonl` | |
| 180 | | `demos/dungeon/` | a solo role-playing game in the style of Dungeons & Dragons, same principle as `demos/team`: a Game Master hands each action to a storyteller, a referee or a scribe (Qwen3.5 4B on llmman for all four); real dice and the hero sheet in shell scripts, each specialist kept to its commands by a `preToolCall` hook; measured results | | 181 | | `demos/dungeon/` | a solo role-playing game in the style of Dungeons & Dragons, same principle as `demos/team`: a Game Master hands each action to a storyteller, a referee or a scribe (Qwen3.5 4B on llmman for all four); real dice and the hero sheet in shell scripts, each specialist kept to its commands by a `preToolCall` hook; measured results | |
| 182 | +| `demos/olala-mini-dnd/` | a role-playing NPC you talk to: Maëlle, innkeeper of a fantasy village, played by Olala-v1.0-mini on Blade (the model of `demos/olala-mini`) with one tool, `search_docs`: her character sheet, prices, rumours, trusted facts and a secret behind a condition live in `.mm/npc.md` (`agentsMd.path`), her family, story, clothes, pastimes, friends and tastes in `.mm/lore/`, which she searches before talking about them (French words in each heading for a French player); the rules of the role in `turnReminder`; not measured yet | | ||
| 181 | | `demos/coding-helpers/` | interactive documentation for Go and Rust: a coordinator (MiniCPM5 2B) hands each question to a Go or a Rust specialist (Mellum2 12B thinking) with `ask_agent` and the conversation (`with_context`), so "the same thing in Rust" works; explanations and snippets, a full program only on request; measured results | | 183 | | `demos/coding-helpers/` | interactive documentation for Go and Rust: a coordinator (MiniCPM5 2B) hands each question to a Go or a Rust specialist (Mellum2 12B thinking) with `ask_agent` and the conversation (`with_context`), so "the same thing in Rust" works; explanations and snippets, a full program only on request; measured results | |
| 182 | | `demos/programming-answers/` | a tutorial writer tuned for Mellum2.1 12B Thinking on llmman ("write me a Nu shell tutorial"), with the settings chosen and why; the original configuration kept as `agent.orig.yaml` | | 184 | | `demos/programming-answers/` | a tutorial writer tuned for Mellum2.1 12B Thinking on llmman ("write me a Nu shell tutorial"), with the settings chosen and why; the original configuration kept as `agent.orig.yaml` | |
| 183 | | `demos/programming-answers-2/` | **Tuto**: an agent that answers with mini tutorials in the conversation and saves one to Markdown only when asked (`fetch_content` + `save_answer`), Mellum2.1 12B Thinking on llmman, measured results | | 185 | | `demos/programming-answers-2/` | **Tuto**: an agent that answers with mini tutorials in the conversation and saves one to Markdown only when asked (`fetch_content` + `save_answer`), Mellum2.1 12B Thinking on llmman, measured results | |
added
demos/mlx-gemma-4-12b/.gitignore +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +!.mm | |
| 2 | +.mm/sessions | |
| 3 | +.mm/traces | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +!.mm | ||
| 2 | +.mm/sessions | ||
| 3 | +.mm/traces | ||
added
demos/mlx-gemma-4-12b/.mm/agent.yaml +105 -0 | new file mode 100644 | ||
| @@ -0,0 +1,105 @@ | ||
| 1 | +# Jane 12 🧒 — a coding agent: reads and changes the project, runs commands. | |
| 2 | +# | |
| 3 | +# Written by `mm init`. Every value says why it has that value; change | |
| 4 | +# them as you watch the agent work: | |
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | |
| 6 | +# | |
| 7 | +# model family: gemma | |
| 8 | +# usage: developer | |
| 9 | +# machine: small — a laptop, models up to about 8B | |
| 10 | +# model facts: read from mlxserve: nothing beyond the model's name | |
| 11 | +# | |
| 12 | +# Where the numbers come from (the tag before their comment): | |
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | |
| 14 | +# [guide] the settings guide's row for this machine | |
| 15 | +# [rule] a rule of thumb, not specific to this model | |
| 16 | +# | |
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | |
| 18 | + | |
| 19 | +provider: mlxserve | |
| 20 | +# The model. Chosen for it (family gemma): sampling (temperature, top_p, | |
| 21 | +# top_k, max_tokens) and sampling.chat_template_kwargs (enable_thinking). | |
| 22 | +# Change the model and redo them together — running mm init again is the | |
| 23 | +# quick way. | |
| 24 | +model: "lmstudio-community/gemma-4-12B-it-MLX-4bit" | |
| 25 | +# No baseUrl: mlxserve's defaults apply. For the record: | |
| 26 | +# baseUrl: "http://127.0.0.1:11234/v1" | |
| 27 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | |
| 28 | + | |
| 29 | +# 0 = mm asks the server for the window it serves | |
| 30 | +contextWindow: 0 | |
| 31 | +# your answer: every command and file change waits for your answer | |
| 32 | +yolo: false | |
| 33 | +# usage developer | |
| 34 | +bashTool: true | |
| 35 | +editTools: true | |
| 36 | +planTool: true | |
| 37 | +askUserTool: true | |
| 38 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | |
| 39 | +# relative to the directory mm is started from, the project root (see | |
| 40 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | |
| 41 | +skillsDir: .mm/skills | |
| 42 | +# usage developer | |
| 43 | +maxTurns: 40 | |
| 44 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 45 | +maxOutput: 8000 | |
| 46 | +firstTokenTimeout: 3m | |
| 47 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | |
| 48 | +# (section 3) | |
| 49 | +watchdogTimeout: 30s | |
| 50 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 51 | +bashTimeout: 30s | |
| 52 | + | |
| 53 | +sampling: | |
| 54 | + # [card] family gemma: Gemma 4 GGUF sampling 1.0 / 0.95 / 64 | |
| 55 | + # (demos/gemini-style); precise 0.2 measured with gemma-4-E4B (demos/hooks, | |
| 56 | + # guards); enable_thinking is off by default in the template | |
| 57 | + temperature: 1.0 | |
| 58 | + top_p: 0.95 | |
| 59 | + top_k: 64 | |
| 60 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | |
| 61 | + max_tokens: 16384 | |
| 62 | + # one tool call per reply: small models run a check before the change it | |
| 63 | + # checks has landed otherwise | |
| 64 | + parallel_tool_calls: false | |
| 65 | + chat_template_kwargs: | |
| 66 | + # reasoning on: code and multi-step work (family gemma) | |
| 67 | + enable_thinking: true | |
| 68 | + | |
| 69 | +context: | |
| 70 | + # compress the history before the window is full (settings guide, every row) | |
| 71 | + enabled: true | |
| 72 | + # mm's default: 75 % of the window the server serves, a quarter left for the | |
| 73 | + # next question and its tool outputs | |
| 74 | + threshold: 75 | |
| 75 | + | |
| 76 | +sessions: | |
| 77 | + # your answer: every conversation is saved; /sessions lists them, /resume | |
| 78 | + # reopens one | |
| 79 | + enabled: true | |
| 80 | + # relative to the directory mm is started from: one folder per project | |
| 81 | + dir: .mm/sessions | |
| 82 | + | |
| 83 | +agentsMd: | |
| 84 | + # An AGENTS.md in the project directory is added to the system prompt. | |
| 85 | + enabled: true | |
| 86 | + | |
| 87 | +acp: | |
| 88 | + name: jane 12 🧒 | |
| 89 | + title: "Jane 12 🧒 (developer)" | |
| 90 | + | |
| 91 | +system: | | |
| 92 | + Your name is Jane 12 🧒. | |
| 93 | + You are a coding agent working in a terminal, in the user's project. | |
| 94 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | |
| 95 | + plan tool. | |
| 96 | + Read before you change: look at the files and run the commands that tell | |
| 97 | + you how the project works. Make the smallest change that does the job, | |
| 98 | + then run the tests or the build to check it. | |
| 99 | + Never state the output of a command you did not run in this answer. | |
| 100 | + When a task has several steps, make a plan and update it as you go. | |
| 101 | + | |
| 102 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | |
| 103 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | |
| 104 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | |
| 105 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | |
| new file mode 100644 | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | +# Jane 12 🧒 — a coding agent: reads and changes the project, runs commands. | ||
| 2 | +# | ||
| 3 | +# Written by `mm init`. Every value says why it has that value; change | ||
| 4 | +# them as you watch the agent work: | ||
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | ||
| 6 | +# | ||
| 7 | +# model family: gemma | ||
| 8 | +# usage: developer | ||
| 9 | +# machine: small — a laptop, models up to about 8B | ||
| 10 | +# model facts: read from mlxserve: nothing beyond the model's name | ||
| 11 | +# | ||
| 12 | +# Where the numbers come from (the tag before their comment): | ||
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | ||
| 14 | +# [guide] the settings guide's row for this machine | ||
| 15 | +# [rule] a rule of thumb, not specific to this model | ||
| 16 | +# | ||
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | ||
| 18 | + | ||
| 19 | +provider: mlxserve | ||
| 20 | +# The model. Chosen for it (family gemma): sampling (temperature, top_p, | ||
| 21 | +# top_k, max_tokens) and sampling.chat_template_kwargs (enable_thinking). | ||
| 22 | +# Change the model and redo them together — running mm init again is the | ||
| 23 | +# quick way. | ||
| 24 | +model: "lmstudio-community/gemma-4-12B-it-MLX-4bit" | ||
| 25 | +# No baseUrl: mlxserve's defaults apply. For the record: | ||
| 26 | +# baseUrl: "http://127.0.0.1:11234/v1" | ||
| 27 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | ||
| 28 | + | ||
| 29 | +# 0 = mm asks the server for the window it serves | ||
| 30 | +contextWindow: 0 | ||
| 31 | +# your answer: every command and file change waits for your answer | ||
| 32 | +yolo: false | ||
| 33 | +# usage developer | ||
| 34 | +bashTool: true | ||
| 35 | +editTools: true | ||
| 36 | +planTool: true | ||
| 37 | +askUserTool: true | ||
| 38 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | ||
| 39 | +# relative to the directory mm is started from, the project root (see | ||
| 40 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | ||
| 41 | +skillsDir: .mm/skills | ||
| 42 | +# usage developer | ||
| 43 | +maxTurns: 40 | ||
| 44 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 45 | +maxOutput: 8000 | ||
| 46 | +firstTokenTimeout: 3m | ||
| 47 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | ||
| 48 | +# (section 3) | ||
| 49 | +watchdogTimeout: 30s | ||
| 50 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 51 | +bashTimeout: 30s | ||
| 52 | + | ||
| 53 | +sampling: | ||
| 54 | + # [card] family gemma: Gemma 4 GGUF sampling 1.0 / 0.95 / 64 | ||
| 55 | + # (demos/gemini-style); precise 0.2 measured with gemma-4-E4B (demos/hooks, | ||
| 56 | + # guards); enable_thinking is off by default in the template | ||
| 57 | + temperature: 1.0 | ||
| 58 | + top_p: 0.95 | ||
| 59 | + top_k: 64 | ||
| 60 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | ||
| 61 | + max_tokens: 16384 | ||
| 62 | + # one tool call per reply: small models run a check before the change it | ||
| 63 | + # checks has landed otherwise | ||
| 64 | + parallel_tool_calls: false | ||
| 65 | + chat_template_kwargs: | ||
| 66 | + # reasoning on: code and multi-step work (family gemma) | ||
| 67 | + enable_thinking: true | ||
| 68 | + | ||
| 69 | +context: | ||
| 70 | + # compress the history before the window is full (settings guide, every row) | ||
| 71 | + enabled: true | ||
| 72 | + # mm's default: 75 % of the window the server serves, a quarter left for the | ||
| 73 | + # next question and its tool outputs | ||
| 74 | + threshold: 75 | ||
| 75 | + | ||
| 76 | +sessions: | ||
| 77 | + # your answer: every conversation is saved; /sessions lists them, /resume | ||
| 78 | + # reopens one | ||
| 79 | + enabled: true | ||
| 80 | + # relative to the directory mm is started from: one folder per project | ||
| 81 | + dir: .mm/sessions | ||
| 82 | + | ||
| 83 | +agentsMd: | ||
| 84 | + # An AGENTS.md in the project directory is added to the system prompt. | ||
| 85 | + enabled: true | ||
| 86 | + | ||
| 87 | +acp: | ||
| 88 | + name: jane 12 🧒 | ||
| 89 | + title: "Jane 12 🧒 (developer)" | ||
| 90 | + | ||
| 91 | +system: | | ||
| 92 | + Your name is Jane 12 🧒. | ||
| 93 | + You are a coding agent working in a terminal, in the user's project. | ||
| 94 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | ||
| 95 | + plan tool. | ||
| 96 | + Read before you change: look at the files and run the commands that tell | ||
| 97 | + you how the project works. Make the smallest change that does the job, | ||
| 98 | + then run the tests or the build to check it. | ||
| 99 | + Never state the output of a command you did not run in this answer. | ||
| 100 | + When a task has several steps, make a plan and update it as you go. | ||
| 101 | + | ||
| 102 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | ||
| 103 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | ||
| 104 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | ||
| 105 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | ||
added
demos/mlx-gemma-4-12b/todo_api_spec.md +66 -0 | new file mode 100644 | ||
| @@ -0,0 +1,66 @@ | ||
| 1 | +# REST API Project Specification: Todo List (Go & JSON Storage) | |
| 2 | + | |
| 3 | +## Overview | |
| 4 | +A RESTful API built in Go to manage a "To-Do" list. The application will provide standard CRUD operations. Data will be persisted in JSON files instead of a traditional database. | |
| 5 | + | |
| 6 | +## Requirements | |
| 7 | +- **Language**: Go | |
| 8 | +- **Storage**: JSON Files | |
| 9 | +- **Features**: | |
| 10 | + - Create a new todo item. | |
| 11 | + - Read all todo items. | |
| 12 | + - Read a specific todo item by ID. | |
| 13 | + - Update an existing todo item. | |
| 14 | + - Delete a todo item. | |
| 15 | + | |
| 16 | +## API Endpoints | |
| 17 | + | |
| 18 | +### 1. Create a Todo | |
| 19 | +- **URL**: `/api/v1/todos` | |
| 20 | +- **Method**: `POST` | |
| 21 | +- **Request Body**: | |
| 22 | + ```json | |
| 23 | + { | |
| 24 | + "title": "String", | |
| 25 | + "description": "String", | |
| 26 | + "completed": "Boolean" | |
| 27 | + } | |
| 28 | + ``` | |
| 29 | +- **Response**: `201 Created` with the created object (including ID). | |
| 30 | + | |
| 31 | +### 2. Get All Todos | |
| 32 | +- **URL**: `/api/v1/todos` | |
| 33 | +- **Method**: `GET` | |
| 34 | +- **Response**: `200 OK` with a list of all todos. | |
| 35 | + | |
| 36 | +### 3. Get a Todo by ID | |
| 37 | +- **URL**: `/api/v1/todos/{id}` | |
| 38 | +- **Method**: `GET` | |
| 39 | +- **Response**: `200 OK` with the todo object or `404 Not Found`. | |
| 40 | + | |
| 41 | +### 4. Update a Todo | |
| 42 | +- **URL**: `/api/v1/todos/{id}` | |
| 43 | +- **Method**: `PUT` | |
| 44 | +- **Request Body**: | |
| 45 | + ```json | |
| 46 | + { | |
| 47 | + "title": "String", | |
| 48 | + "description": "String", | |
| 49 | + "completed": "Boolean" | |
| 50 | + } | |
| 51 | + ``` | |
| 52 | +- **Response**: `200 OK` with the updated object or `404 Not Found`. | |
| 53 | + | |
| 54 | +### 5. Delete a Todo | |
| 55 | +- **URL**: `/api/v1/todos/{id}` | |
| 56 | +- **Method**: `DELETE` | |
| 57 | +- **Response**: `200 OK` or `404 Not Found`. | |
| 58 | + | |
| 59 | +## Project Plan | |
| 60 | + | |
| 61 | +1. **Define API Specification and Project Plan in a markdown file.** | |
| 62 | +2. **Project Initialization**: Set up Go module and directory structure. | |
| 63 | +3. **Model Definition**: Define the `Todo` struct and JSON serialization. | |
| 64 | +4. **Storage Layer**: Implement file I/O for JSON storage. | |
| 65 | +5. **Routing and Handlers**: Implement CRUD endpoints. | |
| 66 | +6. **Testing**: Create unit and integration tests. | |
| new file mode 100644 | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | +# REST API Project Specification: Todo List (Go & JSON Storage) | ||
| 2 | + | ||
| 3 | +## Overview | ||
| 4 | +A RESTful API built in Go to manage a "To-Do" list. The application will provide standard CRUD operations. Data will be persisted in JSON files instead of a traditional database. | ||
| 5 | + | ||
| 6 | +## Requirements | ||
| 7 | +- **Language**: Go | ||
| 8 | +- **Storage**: JSON Files | ||
| 9 | +- **Features**: | ||
| 10 | + - Create a new todo item. | ||
| 11 | + - Read all todo items. | ||
| 12 | + - Read a specific todo item by ID. | ||
| 13 | + - Update an existing todo item. | ||
| 14 | + - Delete a todo item. | ||
| 15 | + | ||
| 16 | +## API Endpoints | ||
| 17 | + | ||
| 18 | +### 1. Create a Todo | ||
| 19 | +- **URL**: `/api/v1/todos` | ||
| 20 | +- **Method**: `POST` | ||
| 21 | +- **Request Body**: | ||
| 22 | + ```json | ||
| 23 | + { | ||
| 24 | + "title": "String", | ||
| 25 | + "description": "String", | ||
| 26 | + "completed": "Boolean" | ||
| 27 | + } | ||
| 28 | + ``` | ||
| 29 | +- **Response**: `201 Created` with the created object (including ID). | ||
| 30 | + | ||
| 31 | +### 2. Get All Todos | ||
| 32 | +- **URL**: `/api/v1/todos` | ||
| 33 | +- **Method**: `GET` | ||
| 34 | +- **Response**: `200 OK` with a list of all todos. | ||
| 35 | + | ||
| 36 | +### 3. Get a Todo by ID | ||
| 37 | +- **URL**: `/api/v1/todos/{id}` | ||
| 38 | +- **Method**: `GET` | ||
| 39 | +- **Response**: `200 OK` with the todo object or `404 Not Found`. | ||
| 40 | + | ||
| 41 | +### 4. Update a Todo | ||
| 42 | +- **URL**: `/api/v1/todos/{id}` | ||
| 43 | +- **Method**: `PUT` | ||
| 44 | +- **Request Body**: | ||
| 45 | + ```json | ||
| 46 | + { | ||
| 47 | + "title": "String", | ||
| 48 | + "description": "String", | ||
| 49 | + "completed": "Boolean" | ||
| 50 | + } | ||
| 51 | + ``` | ||
| 52 | +- **Response**: `200 OK` with the updated object or `404 Not Found`. | ||
| 53 | + | ||
| 54 | +### 5. Delete a Todo | ||
| 55 | +- **URL**: `/api/v1/todos/{id}` | ||
| 56 | +- **Method**: `DELETE` | ||
| 57 | +- **Response**: `200 OK` or `404 Not Found`. | ||
| 58 | + | ||
| 59 | +## Project Plan | ||
| 60 | + | ||
| 61 | +1. **Define API Specification and Project Plan in a markdown file.** | ||
| 62 | +2. **Project Initialization**: Set up Go module and directory structure. | ||
| 63 | +3. **Model Definition**: Define the `Todo` struct and JSON serialization. | ||
| 64 | +4. **Storage Layer**: Implement file I/O for JSON storage. | ||
| 65 | +5. **Routing and Handlers**: Implement CRUD endpoints. | ||
| 66 | +6. **Testing**: Create unit and integration tests. | ||
added
demos/mlx-gemma-4-26b-a4b/.gitignore +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +!.mm | |
| 2 | +.mm/sessions | |
| 3 | +.mm/traces | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +!.mm | ||
| 2 | +.mm/sessions | ||
| 3 | +.mm/traces | ||
added
demos/mlx-gemma-4-26b-a4b/.mm/agent.yaml +105 -0 | new file mode 100644 | ||
| @@ -0,0 +1,105 @@ | ||
| 1 | +# Jane 26 👧🏻 — a coding agent: reads and changes the project, runs commands. | |
| 2 | +# | |
| 3 | +# Written by `mm init`. Every value says why it has that value; change | |
| 4 | +# them as you watch the agent work: | |
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | |
| 6 | +# | |
| 7 | +# model family: gemma | |
| 8 | +# usage: developer | |
| 9 | +# machine: small — a laptop, models up to about 8B | |
| 10 | +# model facts: read from mlxserve: nothing beyond the model's name | |
| 11 | +# | |
| 12 | +# Where the numbers come from (the tag before their comment): | |
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | |
| 14 | +# [guide] the settings guide's row for this machine | |
| 15 | +# [rule] a rule of thumb, not specific to this model | |
| 16 | +# | |
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | |
| 18 | + | |
| 19 | +provider: mlxserve | |
| 20 | +# The model. Chosen for it (family gemma): sampling (temperature, top_p, | |
| 21 | +# top_k, max_tokens) and sampling.chat_template_kwargs (enable_thinking). | |
| 22 | +# Change the model and redo them together — running mm init again is the | |
| 23 | +# quick way. | |
| 24 | +model: "lmstudio-community/gemma-4-26B-A4B-it-QAT-MLX-4bit" | |
| 25 | +# No baseUrl: mlxserve's defaults apply. For the record: | |
| 26 | +# baseUrl: "http://127.0.0.1:11234/v1" | |
| 27 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | |
| 28 | + | |
| 29 | +# 0 = mm asks the server for the window it serves | |
| 30 | +contextWindow: 0 | |
| 31 | +# your answer: every command and file change waits for your answer | |
| 32 | +yolo: false | |
| 33 | +# usage developer | |
| 34 | +bashTool: true | |
| 35 | +editTools: true | |
| 36 | +planTool: true | |
| 37 | +askUserTool: true | |
| 38 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | |
| 39 | +# relative to the directory mm is started from, the project root (see | |
| 40 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | |
| 41 | +skillsDir: .mm/skills | |
| 42 | +# usage developer | |
| 43 | +maxTurns: 40 | |
| 44 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 45 | +maxOutput: 8000 | |
| 46 | +firstTokenTimeout: 3m | |
| 47 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | |
| 48 | +# (section 3) | |
| 49 | +watchdogTimeout: 30s | |
| 50 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 51 | +bashTimeout: 30s | |
| 52 | + | |
| 53 | +sampling: | |
| 54 | + # [card] family gemma: Gemma 4 GGUF sampling 1.0 / 0.95 / 64 | |
| 55 | + # (demos/gemini-style); precise 0.2 measured with gemma-4-E4B (demos/hooks, | |
| 56 | + # guards); enable_thinking is off by default in the template | |
| 57 | + temperature: 1.0 | |
| 58 | + top_p: 0.95 | |
| 59 | + top_k: 64 | |
| 60 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | |
| 61 | + max_tokens: 16384 | |
| 62 | + # one tool call per reply: small models run a check before the change it | |
| 63 | + # checks has landed otherwise | |
| 64 | + parallel_tool_calls: false | |
| 65 | + chat_template_kwargs: | |
| 66 | + # reasoning on: code and multi-step work (family gemma) | |
| 67 | + enable_thinking: true | |
| 68 | + | |
| 69 | +context: | |
| 70 | + # compress the history before the window is full (settings guide, every row) | |
| 71 | + enabled: true | |
| 72 | + # mm's default: 75 % of the window the server serves, a quarter left for the | |
| 73 | + # next question and its tool outputs | |
| 74 | + threshold: 75 | |
| 75 | + | |
| 76 | +sessions: | |
| 77 | + # your answer: every conversation is saved; /sessions lists them, /resume | |
| 78 | + # reopens one | |
| 79 | + enabled: true | |
| 80 | + # relative to the directory mm is started from: one folder per project | |
| 81 | + dir: .mm/sessions | |
| 82 | + | |
| 83 | +agentsMd: | |
| 84 | + # An AGENTS.md in the project directory is added to the system prompt. | |
| 85 | + enabled: true | |
| 86 | + | |
| 87 | +acp: | |
| 88 | + name: jane 26 👧🏻 | |
| 89 | + title: "Jane 26 👧🏻 (developer)" | |
| 90 | + | |
| 91 | +system: | | |
| 92 | + Your name is Jane 26 👧🏻. | |
| 93 | + You are a coding agent working in a terminal, in the user's project. | |
| 94 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | |
| 95 | + plan tool. | |
| 96 | + Read before you change: look at the files and run the commands that tell | |
| 97 | + you how the project works. Make the smallest change that does the job, | |
| 98 | + then run the tests or the build to check it. | |
| 99 | + Never state the output of a command you did not run in this answer. | |
| 100 | + When a task has several steps, make a plan and update it as you go. | |
| 101 | + | |
| 102 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | |
| 103 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | |
| 104 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | |
| 105 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | |
| new file mode 100644 | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | +# Jane 26 👧🏻 — a coding agent: reads and changes the project, runs commands. | ||
| 2 | +# | ||
| 3 | +# Written by `mm init`. Every value says why it has that value; change | ||
| 4 | +# them as you watch the agent work: | ||
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | ||
| 6 | +# | ||
| 7 | +# model family: gemma | ||
| 8 | +# usage: developer | ||
| 9 | +# machine: small — a laptop, models up to about 8B | ||
| 10 | +# model facts: read from mlxserve: nothing beyond the model's name | ||
| 11 | +# | ||
| 12 | +# Where the numbers come from (the tag before their comment): | ||
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | ||
| 14 | +# [guide] the settings guide's row for this machine | ||
| 15 | +# [rule] a rule of thumb, not specific to this model | ||
| 16 | +# | ||
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | ||
| 18 | + | ||
| 19 | +provider: mlxserve | ||
| 20 | +# The model. Chosen for it (family gemma): sampling (temperature, top_p, | ||
| 21 | +# top_k, max_tokens) and sampling.chat_template_kwargs (enable_thinking). | ||
| 22 | +# Change the model and redo them together — running mm init again is the | ||
| 23 | +# quick way. | ||
| 24 | +model: "lmstudio-community/gemma-4-26B-A4B-it-QAT-MLX-4bit" | ||
| 25 | +# No baseUrl: mlxserve's defaults apply. For the record: | ||
| 26 | +# baseUrl: "http://127.0.0.1:11234/v1" | ||
| 27 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | ||
| 28 | + | ||
| 29 | +# 0 = mm asks the server for the window it serves | ||
| 30 | +contextWindow: 0 | ||
| 31 | +# your answer: every command and file change waits for your answer | ||
| 32 | +yolo: false | ||
| 33 | +# usage developer | ||
| 34 | +bashTool: true | ||
| 35 | +editTools: true | ||
| 36 | +planTool: true | ||
| 37 | +askUserTool: true | ||
| 38 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | ||
| 39 | +# relative to the directory mm is started from, the project root (see | ||
| 40 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | ||
| 41 | +skillsDir: .mm/skills | ||
| 42 | +# usage developer | ||
| 43 | +maxTurns: 40 | ||
| 44 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 45 | +maxOutput: 8000 | ||
| 46 | +firstTokenTimeout: 3m | ||
| 47 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | ||
| 48 | +# (section 3) | ||
| 49 | +watchdogTimeout: 30s | ||
| 50 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 51 | +bashTimeout: 30s | ||
| 52 | + | ||
| 53 | +sampling: | ||
| 54 | + # [card] family gemma: Gemma 4 GGUF sampling 1.0 / 0.95 / 64 | ||
| 55 | + # (demos/gemini-style); precise 0.2 measured with gemma-4-E4B (demos/hooks, | ||
| 56 | + # guards); enable_thinking is off by default in the template | ||
| 57 | + temperature: 1.0 | ||
| 58 | + top_p: 0.95 | ||
| 59 | + top_k: 64 | ||
| 60 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | ||
| 61 | + max_tokens: 16384 | ||
| 62 | + # one tool call per reply: small models run a check before the change it | ||
| 63 | + # checks has landed otherwise | ||
| 64 | + parallel_tool_calls: false | ||
| 65 | + chat_template_kwargs: | ||
| 66 | + # reasoning on: code and multi-step work (family gemma) | ||
| 67 | + enable_thinking: true | ||
| 68 | + | ||
| 69 | +context: | ||
| 70 | + # compress the history before the window is full (settings guide, every row) | ||
| 71 | + enabled: true | ||
| 72 | + # mm's default: 75 % of the window the server serves, a quarter left for the | ||
| 73 | + # next question and its tool outputs | ||
| 74 | + threshold: 75 | ||
| 75 | + | ||
| 76 | +sessions: | ||
| 77 | + # your answer: every conversation is saved; /sessions lists them, /resume | ||
| 78 | + # reopens one | ||
| 79 | + enabled: true | ||
| 80 | + # relative to the directory mm is started from: one folder per project | ||
| 81 | + dir: .mm/sessions | ||
| 82 | + | ||
| 83 | +agentsMd: | ||
| 84 | + # An AGENTS.md in the project directory is added to the system prompt. | ||
| 85 | + enabled: true | ||
| 86 | + | ||
| 87 | +acp: | ||
| 88 | + name: jane 26 👧🏻 | ||
| 89 | + title: "Jane 26 👧🏻 (developer)" | ||
| 90 | + | ||
| 91 | +system: | | ||
| 92 | + Your name is Jane 26 👧🏻. | ||
| 93 | + You are a coding agent working in a terminal, in the user's project. | ||
| 94 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | ||
| 95 | + plan tool. | ||
| 96 | + Read before you change: look at the files and run the commands that tell | ||
| 97 | + you how the project works. Make the smallest change that does the job, | ||
| 98 | + then run the tests or the build to check it. | ||
| 99 | + Never state the output of a command you did not run in this answer. | ||
| 100 | + When a task has several steps, make a plan and update it as you go. | ||
| 101 | + | ||
| 102 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | ||
| 103 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | ||
| 104 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | ||
| 105 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | ||
added
demos/mlx-gemma-4-26b-a4b/todo_api_spec.md +66 -0 | new file mode 100644 | ||
| @@ -0,0 +1,66 @@ | ||
| 1 | +# REST API Project Specification: Todo List (Go & JSON Storage) | |
| 2 | + | |
| 3 | +## Overview | |
| 4 | +A RESTful API built in Go to manage a "To-Do" list. The application will provide standard CRUD operations. Data will be persisted in JSON files instead of a traditional database. | |
| 5 | + | |
| 6 | +## Requirements | |
| 7 | +- **Language**: Go | |
| 8 | +- **Storage**: JSON Files | |
| 9 | +- **Features**: | |
| 10 | + - Create a new todo item. | |
| 11 | + - Read all todo items. | |
| 12 | + - Read a specific todo item by ID. | |
| 13 | + - Update an existing todo item. | |
| 14 | + - Delete a todo item. | |
| 15 | + | |
| 16 | +## API Endpoints | |
| 17 | + | |
| 18 | +### 1. Create a Todo | |
| 19 | +- **URL**: `/api/v1/todos` | |
| 20 | +- **Method**: `POST` | |
| 21 | +- **Request Body**: | |
| 22 | + ```json | |
| 23 | + { | |
| 24 | + "title": "String", | |
| 25 | + "description": "String", | |
| 26 | + "completed": "Boolean" | |
| 27 | + } | |
| 28 | + ``` | |
| 29 | +- **Response**: `201 Created` with the created object (including ID). | |
| 30 | + | |
| 31 | +### 2. Get All Todos | |
| 32 | +- **URL**: `/api/v1/todos` | |
| 33 | +- **Method**: `GET` | |
| 34 | +- **Response**: `200 OK` with a list of all todos. | |
| 35 | + | |
| 36 | +### 3. Get a Todo by ID | |
| 37 | +- **URL**: `/api/v1/todos/{id}` | |
| 38 | +- **Method**: `GET` | |
| 39 | +- **Response**: `200 OK` with the todo object or `404 Not Found`. | |
| 40 | + | |
| 41 | +### 4. Update a Todo | |
| 42 | +- **URL**: `/api/v1/todos/{id}` | |
| 43 | +- **Method**: `PUT` | |
| 44 | +- **Request Body**: | |
| 45 | + ```json | |
| 46 | + { | |
| 47 | + "title": "String", | |
| 48 | + "description": "String", | |
| 49 | + "completed": "Boolean" | |
| 50 | + } | |
| 51 | + ``` | |
| 52 | +- **Response**: `200 OK` with the updated object or `404 Not Found`. | |
| 53 | + | |
| 54 | +### 5. Delete a Todo | |
| 55 | +- **URL**: `/api/v1/todos/{id}` | |
| 56 | +- **Method**: `DELETE` | |
| 57 | +- **Response**: `200 OK` or `404 Not Found`. | |
| 58 | + | |
| 59 | +## Project Plan | |
| 60 | + | |
| 61 | +1. **Define API Specification and Project Plan in a markdown file.** | |
| 62 | +2. **Project Initialization**: Set up Go module and directory structure. | |
| 63 | +3. **Model Definition**: Define the `Todo` struct and JSON serialization. | |
| 64 | +4. **Storage Layer**: Implement file I/O for JSON storage. | |
| 65 | +5. **Routing and Handlers**: Implement CRUD endpoints. | |
| 66 | +6. **Testing**: Create unit and integration tests. | |
| new file mode 100644 | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | +# REST API Project Specification: Todo List (Go & JSON Storage) | ||
| 2 | + | ||
| 3 | +## Overview | ||
| 4 | +A RESTful API built in Go to manage a "To-Do" list. The application will provide standard CRUD operations. Data will be persisted in JSON files instead of a traditional database. | ||
| 5 | + | ||
| 6 | +## Requirements | ||
| 7 | +- **Language**: Go | ||
| 8 | +- **Storage**: JSON Files | ||
| 9 | +- **Features**: | ||
| 10 | + - Create a new todo item. | ||
| 11 | + - Read all todo items. | ||
| 12 | + - Read a specific todo item by ID. | ||
| 13 | + - Update an existing todo item. | ||
| 14 | + - Delete a todo item. | ||
| 15 | + | ||
| 16 | +## API Endpoints | ||
| 17 | + | ||
| 18 | +### 1. Create a Todo | ||
| 19 | +- **URL**: `/api/v1/todos` | ||
| 20 | +- **Method**: `POST` | ||
| 21 | +- **Request Body**: | ||
| 22 | + ```json | ||
| 23 | + { | ||
| 24 | + "title": "String", | ||
| 25 | + "description": "String", | ||
| 26 | + "completed": "Boolean" | ||
| 27 | + } | ||
| 28 | + ``` | ||
| 29 | +- **Response**: `201 Created` with the created object (including ID). | ||
| 30 | + | ||
| 31 | +### 2. Get All Todos | ||
| 32 | +- **URL**: `/api/v1/todos` | ||
| 33 | +- **Method**: `GET` | ||
| 34 | +- **Response**: `200 OK` with a list of all todos. | ||
| 35 | + | ||
| 36 | +### 3. Get a Todo by ID | ||
| 37 | +- **URL**: `/api/v1/todos/{id}` | ||
| 38 | +- **Method**: `GET` | ||
| 39 | +- **Response**: `200 OK` with the todo object or `404 Not Found`. | ||
| 40 | + | ||
| 41 | +### 4. Update a Todo | ||
| 42 | +- **URL**: `/api/v1/todos/{id}` | ||
| 43 | +- **Method**: `PUT` | ||
| 44 | +- **Request Body**: | ||
| 45 | + ```json | ||
| 46 | + { | ||
| 47 | + "title": "String", | ||
| 48 | + "description": "String", | ||
| 49 | + "completed": "Boolean" | ||
| 50 | + } | ||
| 51 | + ``` | ||
| 52 | +- **Response**: `200 OK` with the updated object or `404 Not Found`. | ||
| 53 | + | ||
| 54 | +### 5. Delete a Todo | ||
| 55 | +- **URL**: `/api/v1/todos/{id}` | ||
| 56 | +- **Method**: `DELETE` | ||
| 57 | +- **Response**: `200 OK` or `404 Not Found`. | ||
| 58 | + | ||
| 59 | +## Project Plan | ||
| 60 | + | ||
| 61 | +1. **Define API Specification and Project Plan in a markdown file.** | ||
| 62 | +2. **Project Initialization**: Set up Go module and directory structure. | ||
| 63 | +3. **Model Definition**: Define the `Todo` struct and JSON serialization. | ||
| 64 | +4. **Storage Layer**: Implement file I/O for JSON storage. | ||
| 65 | +5. **Routing and Handlers**: Implement CRUD endpoints. | ||
| 66 | +6. **Testing**: Create unit and integration tests. | ||
added
demos/mlx-gemma-4-e4b/.gitignore +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +!.mm | |
| 2 | +.mm/sessions | |
| 3 | +.mm/traces | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +!.mm | ||
| 2 | +.mm/sessions | ||
| 3 | +.mm/traces | ||
added
demos/mlx-gemma-4-e4b/.mm/agent.yaml +105 -0 | new file mode 100644 | ||
| @@ -0,0 +1,105 @@ | ||
| 1 | +# Jamie — a coding agent: reads and changes the project, runs commands. | |
| 2 | +# | |
| 3 | +# Written by `mm init`. Every value says why it has that value; change | |
| 4 | +# them as you watch the agent work: | |
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | |
| 6 | +# | |
| 7 | +# model family: gemma | |
| 8 | +# usage: developer | |
| 9 | +# machine: small — a laptop, models up to about 8B | |
| 10 | +# model facts: read from mlxserve: native window 73728 tokens; GGUF sampling temperature 1.0, top_p 0.95, top_k 64; reasoning switch enable_thinking (default off) | |
| 11 | +# | |
| 12 | +# Where the numbers come from (the tag before their comment): | |
| 13 | +# [server] read from the server — run mm init again after a change | |
| 14 | +# [guide] the settings guide's row for this machine | |
| 15 | +# [rule] a rule of thumb, not specific to this model | |
| 16 | +# | |
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | |
| 18 | + | |
| 19 | +provider: mlxserve | |
| 20 | +# The model. Chosen for it (family gemma): sampling (temperature, top_p, | |
| 21 | +# top_k, max_tokens) and sampling.chat_template_kwargs (enable_thinking). | |
| 22 | +# Change the model and redo them together — running mm init again is the | |
| 23 | +# quick way. | |
| 24 | +model: "lmstudio-community/gemma-4-E4B-it-MLX-8bit" | |
| 25 | +# No baseUrl: mlxserve's defaults apply. For the record: | |
| 26 | +# baseUrl: "http://127.0.0.1:11234/v1" | |
| 27 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | |
| 28 | + | |
| 29 | +# 0 = mm asks the server for the window it serves (the model's native window | |
| 30 | +# is 73728 tokens; the server may serve less) | |
| 31 | +contextWindow: 0 | |
| 32 | +# your answer: every command and file change waits for your answer | |
| 33 | +yolo: false | |
| 34 | +# usage developer | |
| 35 | +bashTool: true | |
| 36 | +editTools: true | |
| 37 | +planTool: true | |
| 38 | +askUserTool: true | |
| 39 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | |
| 40 | +# relative to the directory mm is started from, the project root (see | |
| 41 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | |
| 42 | +skillsDir: .mm/skills | |
| 43 | +# usage developer | |
| 44 | +maxTurns: 40 | |
| 45 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 46 | +maxOutput: 8000 | |
| 47 | +firstTokenTimeout: 3m | |
| 48 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | |
| 49 | +# (section 3) | |
| 50 | +watchdogTimeout: 30s | |
| 51 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 52 | +bashTimeout: 30s | |
| 53 | + | |
| 54 | +sampling: | |
| 55 | + # [server] the GGUF's own sampling, read from the server | |
| 56 | + temperature: 1.0 | |
| 57 | + top_p: 0.95 | |
| 58 | + top_k: 64 | |
| 59 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | |
| 60 | + max_tokens: 16384 | |
| 61 | + # one tool call per reply: small models run a check before the change it | |
| 62 | + # checks has landed otherwise | |
| 63 | + parallel_tool_calls: false | |
| 64 | + chat_template_kwargs: | |
| 65 | + # reasoning on: code and multi-step work; the template's default is off | |
| 66 | + # (read from the chat template) | |
| 67 | + enable_thinking: true | |
| 68 | + | |
| 69 | +context: | |
| 70 | + # compress the history before the window is full (settings guide, every row) | |
| 71 | + enabled: true | |
| 72 | + # mm's default: 75 % of the window the server serves, a quarter left for the | |
| 73 | + # next question and its tool outputs | |
| 74 | + threshold: 75 | |
| 75 | + | |
| 76 | +sessions: | |
| 77 | + # your answer: every conversation is saved; /sessions lists them, /resume | |
| 78 | + # reopens one | |
| 79 | + enabled: true | |
| 80 | + # relative to the directory mm is started from: one folder per project | |
| 81 | + dir: .mm/sessions | |
| 82 | + | |
| 83 | +agentsMd: | |
| 84 | + # An AGENTS.md in the project directory is added to the system prompt. | |
| 85 | + enabled: true | |
| 86 | + | |
| 87 | +acp: | |
| 88 | + name: jamie | |
| 89 | + title: "Jamie (developer)" | |
| 90 | + | |
| 91 | +system: | | |
| 92 | + Your name is Jamie. | |
| 93 | + You are a coding agent working in a terminal, in the user's project. | |
| 94 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | |
| 95 | + plan tool. | |
| 96 | + Read before you change: look at the files and run the commands that tell | |
| 97 | + you how the project works. Make the smallest change that does the job, | |
| 98 | + then run the tests or the build to check it. | |
| 99 | + Never state the output of a command you did not run in this answer. | |
| 100 | + When a task has several steps, make a plan and update it as you go. | |
| 101 | + | |
| 102 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | |
| 103 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | |
| 104 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | |
| 105 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | |
| new file mode 100644 | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | +# Jamie — a coding agent: reads and changes the project, runs commands. | ||
| 2 | +# | ||
| 3 | +# Written by `mm init`. Every value says why it has that value; change | ||
| 4 | +# them as you watch the agent work: | ||
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | ||
| 6 | +# | ||
| 7 | +# model family: gemma | ||
| 8 | +# usage: developer | ||
| 9 | +# machine: small — a laptop, models up to about 8B | ||
| 10 | +# model facts: read from mlxserve: native window 73728 tokens; GGUF sampling temperature 1.0, top_p 0.95, top_k 64; reasoning switch enable_thinking (default off) | ||
| 11 | +# | ||
| 12 | +# Where the numbers come from (the tag before their comment): | ||
| 13 | +# [server] read from the server — run mm init again after a change | ||
| 14 | +# [guide] the settings guide's row for this machine | ||
| 15 | +# [rule] a rule of thumb, not specific to this model | ||
| 16 | +# | ||
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | ||
| 18 | + | ||
| 19 | +provider: mlxserve | ||
| 20 | +# The model. Chosen for it (family gemma): sampling (temperature, top_p, | ||
| 21 | +# top_k, max_tokens) and sampling.chat_template_kwargs (enable_thinking). | ||
| 22 | +# Change the model and redo them together — running mm init again is the | ||
| 23 | +# quick way. | ||
| 24 | +model: "lmstudio-community/gemma-4-E4B-it-MLX-8bit" | ||
| 25 | +# No baseUrl: mlxserve's defaults apply. For the record: | ||
| 26 | +# baseUrl: "http://127.0.0.1:11234/v1" | ||
| 27 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | ||
| 28 | + | ||
| 29 | +# 0 = mm asks the server for the window it serves (the model's native window | ||
| 30 | +# is 73728 tokens; the server may serve less) | ||
| 31 | +contextWindow: 0 | ||
| 32 | +# your answer: every command and file change waits for your answer | ||
| 33 | +yolo: false | ||
| 34 | +# usage developer | ||
| 35 | +bashTool: true | ||
| 36 | +editTools: true | ||
| 37 | +planTool: true | ||
| 38 | +askUserTool: true | ||
| 39 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | ||
| 40 | +# relative to the directory mm is started from, the project root (see | ||
| 41 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | ||
| 42 | +skillsDir: .mm/skills | ||
| 43 | +# usage developer | ||
| 44 | +maxTurns: 40 | ||
| 45 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 46 | +maxOutput: 8000 | ||
| 47 | +firstTokenTimeout: 3m | ||
| 48 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | ||
| 49 | +# (section 3) | ||
| 50 | +watchdogTimeout: 30s | ||
| 51 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 52 | +bashTimeout: 30s | ||
| 53 | + | ||
| 54 | +sampling: | ||
| 55 | + # [server] the GGUF's own sampling, read from the server | ||
| 56 | + temperature: 1.0 | ||
| 57 | + top_p: 0.95 | ||
| 58 | + top_k: 64 | ||
| 59 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | ||
| 60 | + max_tokens: 16384 | ||
| 61 | + # one tool call per reply: small models run a check before the change it | ||
| 62 | + # checks has landed otherwise | ||
| 63 | + parallel_tool_calls: false | ||
| 64 | + chat_template_kwargs: | ||
| 65 | + # reasoning on: code and multi-step work; the template's default is off | ||
| 66 | + # (read from the chat template) | ||
| 67 | + enable_thinking: true | ||
| 68 | + | ||
| 69 | +context: | ||
| 70 | + # compress the history before the window is full (settings guide, every row) | ||
| 71 | + enabled: true | ||
| 72 | + # mm's default: 75 % of the window the server serves, a quarter left for the | ||
| 73 | + # next question and its tool outputs | ||
| 74 | + threshold: 75 | ||
| 75 | + | ||
| 76 | +sessions: | ||
| 77 | + # your answer: every conversation is saved; /sessions lists them, /resume | ||
| 78 | + # reopens one | ||
| 79 | + enabled: true | ||
| 80 | + # relative to the directory mm is started from: one folder per project | ||
| 81 | + dir: .mm/sessions | ||
| 82 | + | ||
| 83 | +agentsMd: | ||
| 84 | + # An AGENTS.md in the project directory is added to the system prompt. | ||
| 85 | + enabled: true | ||
| 86 | + | ||
| 87 | +acp: | ||
| 88 | + name: jamie | ||
| 89 | + title: "Jamie (developer)" | ||
| 90 | + | ||
| 91 | +system: | | ||
| 92 | + Your name is Jamie. | ||
| 93 | + You are a coding agent working in a terminal, in the user's project. | ||
| 94 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | ||
| 95 | + plan tool. | ||
| 96 | + Read before you change: look at the files and run the commands that tell | ||
| 97 | + you how the project works. Make the smallest change that does the job, | ||
| 98 | + then run the tests or the build to check it. | ||
| 99 | + Never state the output of a command you did not run in this answer. | ||
| 100 | + When a task has several steps, make a plan and update it as you go. | ||
| 101 | + | ||
| 102 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | ||
| 103 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | ||
| 104 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | ||
| 105 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | ||
added
demos/mlx-gemma-4-e4b/README.en.md +35 -0 | new file mode 100644 | ||
| @@ -0,0 +1,35 @@ | ||
| 1 | +# mini-me on MLX-Serve — Gemma 4 E4B | |
| 2 | + | |
| 3 | +This folder runs mini-me on [MLX-Serve](https://github.com/ddalcu/mlx-serve), a local model server for Apple Silicon, with `lmstudio-community/gemma-4-E4B-it-MLX-8bit` (Gemma 4 E4B, 8-bit). The agent, Jamie, is a coding agent written by `mm init` (usage `developer`) in a `.mm` folder: | |
| 4 | + | |
| 5 | +| File | What it is | | |
| 6 | +|------|------------| | |
| 7 | +| `.mm/agent.yaml` | the agent: `provider: mlxserve`, the model's own sampling (`temperature: 1.0`, `top_p: 0.95`, `top_k: 64`) and its window, both read from the server, reasoning on (`enable_thinking: true`) | | |
| 8 | +| `.mm/skills/` | the agent's skills (`skillsDir: .mm/skills`) | | |
| 9 | +| `.mm/sessions/` | every conversation, saved (`sessions.enabled: true`) | | |
| 10 | + | |
| 11 | +Version française : [README.fr.md](README.fr.md). | |
| 12 | + | |
| 13 | +## Run it | |
| 14 | + | |
| 15 | +```bash | |
| 16 | +mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | |
| 17 | +mlx-serve serve # 0.0.0.0:11234 | |
| 18 | +cd demos/mlx-gemma-4-e4b | |
| 19 | +../../mm # finds .mm/agent.yaml | |
| 20 | +``` | |
| 21 | + | |
| 22 | +The file has `yolo: false`: every command and file change waits for your answer. From a Docker sandbox, allow `localhost:11234` in the sandbox policy: `mm` falls back to `host.docker.internal:11234` by itself. | |
| 23 | + | |
| 24 | +## What was checked (2026-11-24, mlx-serve 26.11.3, from an sbx sandbox) | |
| 25 | + | |
| 26 | +These checks were run with an agent file that `mm init` wrote for the same model and usage. It had the same provider, model, sampling and reasoning switch, but not this folder's `.mm` layout or sessions. | |
| 27 | + | |
| 28 | +- `mm init --provider mlxserve … --check` wrote the file and the model answered. | |
| 29 | +- `-p` questions, reasoning shown (`💭`), and a turn with tools: the agent wrote `hello.go`, ran it with `go run` and reported `hello mlx`. | |
| 30 | +- Every first request used to break with `unexpected end of JSON input`: MLX-Serve sends `: keepalive` SSE comments while it reads the prompt, which openai-go cannot read. Fixed in `mm` (`internal/engine/ssecomments.go`). | |
| 31 | +- With `curl`: the reasoning switches, `/api/pull` (a model it has, a model that does not exist), `/v1/unload-model`, and a model it does not have (answered by its default model, HTTP 200 — watch the start-up warning). | |
| 32 | + | |
| 33 | +Not checked live through `mm`: a compaction, a real download through `autoPull`, `/unload`, and a protected server (`--api-key`, `MLX_SERVE_API_KEY`). | |
| 34 | + | |
| 35 | +See [How to run mini-me on MLX-Serve](../../docs/en/how-to/run-with-mlx-serve.md). | |
| new file mode 100644 | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | +# mini-me on MLX-Serve — Gemma 4 E4B | ||
| 2 | + | ||
| 3 | +This folder runs mini-me on [MLX-Serve](https://github.com/ddalcu/mlx-serve), a local model server for Apple Silicon, with `lmstudio-community/gemma-4-E4B-it-MLX-8bit` (Gemma 4 E4B, 8-bit). The agent, Jamie, is a coding agent written by `mm init` (usage `developer`) in a `.mm` folder: | ||
| 4 | + | ||
| 5 | +| File | What it is | | ||
| 6 | +|------|------------| | ||
| 7 | +| `.mm/agent.yaml` | the agent: `provider: mlxserve`, the model's own sampling (`temperature: 1.0`, `top_p: 0.95`, `top_k: 64`) and its window, both read from the server, reasoning on (`enable_thinking: true`) | | ||
| 8 | +| `.mm/skills/` | the agent's skills (`skillsDir: .mm/skills`) | | ||
| 9 | +| `.mm/sessions/` | every conversation, saved (`sessions.enabled: true`) | | ||
| 10 | + | ||
| 11 | +Version française : [README.fr.md](README.fr.md). | ||
| 12 | + | ||
| 13 | +## Run it | ||
| 14 | + | ||
| 15 | +```bash | ||
| 16 | +mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | ||
| 17 | +mlx-serve serve # 0.0.0.0:11234 | ||
| 18 | +cd demos/mlx-gemma-4-e4b | ||
| 19 | +../../mm # finds .mm/agent.yaml | ||
| 20 | +``` | ||
| 21 | + | ||
| 22 | +The file has `yolo: false`: every command and file change waits for your answer. From a Docker sandbox, allow `localhost:11234` in the sandbox policy: `mm` falls back to `host.docker.internal:11234` by itself. | ||
| 23 | + | ||
| 24 | +## What was checked (2026-11-24, mlx-serve 26.11.3, from an sbx sandbox) | ||
| 25 | + | ||
| 26 | +These checks were run with an agent file that `mm init` wrote for the same model and usage. It had the same provider, model, sampling and reasoning switch, but not this folder's `.mm` layout or sessions. | ||
| 27 | + | ||
| 28 | +- `mm init --provider mlxserve … --check` wrote the file and the model answered. | ||
| 29 | +- `-p` questions, reasoning shown (`💭`), and a turn with tools: the agent wrote `hello.go`, ran it with `go run` and reported `hello mlx`. | ||
| 30 | +- Every first request used to break with `unexpected end of JSON input`: MLX-Serve sends `: keepalive` SSE comments while it reads the prompt, which openai-go cannot read. Fixed in `mm` (`internal/engine/ssecomments.go`). | ||
| 31 | +- With `curl`: the reasoning switches, `/api/pull` (a model it has, a model that does not exist), `/v1/unload-model`, and a model it does not have (answered by its default model, HTTP 200 — watch the start-up warning). | ||
| 32 | + | ||
| 33 | +Not checked live through `mm`: a compaction, a real download through `autoPull`, `/unload`, and a protected server (`--api-key`, `MLX_SERVE_API_KEY`). | ||
| 34 | + | ||
| 35 | +See [How to run mini-me on MLX-Serve](../../docs/en/how-to/run-with-mlx-serve.md). | ||
added
demos/mlx-gemma-4-e4b/README.fr.md +35 -0 | new file mode 100644 | ||
| @@ -0,0 +1,35 @@ | ||
| 1 | +# mini-me sur MLX-Serve — Gemma 4 E4B | |
| 2 | + | |
| 3 | +Ce dossier fait tourner mini-me sur [MLX-Serve](https://github.com/ddalcu/mlx-serve), un serveur de modèles local pour Apple Silicon, avec `lmstudio-community/gemma-4-E4B-it-MLX-8bit` (Gemma 4 E4B, 8 bits). L'agent, Jamie, est un agent de code écrit par `mm init` (usage `developer`) dans un dossier `.mm` : | |
| 4 | + | |
| 5 | +| Fichier | Ce que c'est | | |
| 6 | +|---------|--------------| | |
| 7 | +| `.mm/agent.yaml` | l'agent : `provider: mlxserve`, l'échantillonnage propre au modèle (`temperature: 1.0`, `top_p: 0.95`, `top_k: 64`) et sa fenêtre, tous deux lus sur le serveur, raisonnement activé (`enable_thinking: true`) | | |
| 8 | +| `.mm/skills/` | les skills de l'agent (`skillsDir: .mm/skills`) | | |
| 9 | +| `.mm/sessions/` | chaque conversation, enregistrée (`sessions.enabled: true`) | | |
| 10 | + | |
| 11 | +English version: [README.en.md](README.en.md). | |
| 12 | + | |
| 13 | +## Lancer | |
| 14 | + | |
| 15 | +```bash | |
| 16 | +mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | |
| 17 | +mlx-serve serve # 0.0.0.0:11234 | |
| 18 | +cd demos/mlx-gemma-4-e4b | |
| 19 | +../../mm # trouve .mm/agent.yaml | |
| 20 | +``` | |
| 21 | + | |
| 22 | +Le fichier a `yolo: false` : chaque commande et chaque modification de fichier attend votre réponse. Depuis un Docker Sandbox, autorisez `localhost:11234` dans la politique du sandbox : `mm` se rabat tout seul sur `host.docker.internal:11234`. | |
| 23 | + | |
| 24 | +## Ce qui a été vérifié (2026-11-24, mlx-serve 26.11.3, depuis un sandbox sbx) | |
| 25 | + | |
| 26 | +Ces vérifications ont été faites avec un fichier d'agent que `mm init` a écrit pour le même modèle et le même usage. Il avait le même provider, le même modèle, le même échantillonnage et le même interrupteur de raisonnement, mais pas la disposition `.mm` de ce dossier ni les sessions. | |
| 27 | + | |
| 28 | +- `mm init --provider mlxserve … --check` a écrit le fichier et le modèle a répondu. | |
| 29 | +- Des questions en `-p`, le raisonnement affiché (`💭`), et un tour avec outils : l'agent a écrit `hello.go`, l'a lancé avec `go run` et a rapporté `hello mlx`. | |
| 30 | +- Chaque première requête cassait avec `unexpected end of JSON input` : MLX-Serve envoie des commentaires SSE `: keepalive` pendant qu'il lit le prompt, ce qu'openai-go ne sait pas lire. Corrigé dans `mm` (`internal/engine/ssecomments.go`). | |
| 31 | +- Avec `curl` : les interrupteurs de raisonnement, `/api/pull` (un modèle qu'il a, un modèle qui n'existe pas), `/v1/unload-model`, et un modèle qu'il n'a pas (servi par son modèle par défaut, HTTP 200 — surveillez l'avertissement du démarrage). | |
| 32 | + | |
| 33 | +Non vérifié en direct à travers `mm` : une compaction, un vrai téléchargement par `autoPull`, `/unload`, et un serveur protégé (`--api-key`, `MLX_SERVE_API_KEY`). | |
| 34 | + | |
| 35 | +Voir [Comment faire tourner mini-me sur MLX-Serve](../../docs/fr/how-to/run-with-mlx-serve.md). | |
| new file mode 100644 | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | +# mini-me sur MLX-Serve — Gemma 4 E4B | ||
| 2 | + | ||
| 3 | +Ce dossier fait tourner mini-me sur [MLX-Serve](https://github.com/ddalcu/mlx-serve), un serveur de modèles local pour Apple Silicon, avec `lmstudio-community/gemma-4-E4B-it-MLX-8bit` (Gemma 4 E4B, 8 bits). L'agent, Jamie, est un agent de code écrit par `mm init` (usage `developer`) dans un dossier `.mm` : | ||
| 4 | + | ||
| 5 | +| Fichier | Ce que c'est | | ||
| 6 | +|---------|--------------| | ||
| 7 | +| `.mm/agent.yaml` | l'agent : `provider: mlxserve`, l'échantillonnage propre au modèle (`temperature: 1.0`, `top_p: 0.95`, `top_k: 64`) et sa fenêtre, tous deux lus sur le serveur, raisonnement activé (`enable_thinking: true`) | | ||
| 8 | +| `.mm/skills/` | les skills de l'agent (`skillsDir: .mm/skills`) | | ||
| 9 | +| `.mm/sessions/` | chaque conversation, enregistrée (`sessions.enabled: true`) | | ||
| 10 | + | ||
| 11 | +English version: [README.en.md](README.en.md). | ||
| 12 | + | ||
| 13 | +## Lancer | ||
| 14 | + | ||
| 15 | +```bash | ||
| 16 | +mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | ||
| 17 | +mlx-serve serve # 0.0.0.0:11234 | ||
| 18 | +cd demos/mlx-gemma-4-e4b | ||
| 19 | +../../mm # trouve .mm/agent.yaml | ||
| 20 | +``` | ||
| 21 | + | ||
| 22 | +Le fichier a `yolo: false` : chaque commande et chaque modification de fichier attend votre réponse. Depuis un Docker Sandbox, autorisez `localhost:11234` dans la politique du sandbox : `mm` se rabat tout seul sur `host.docker.internal:11234`. | ||
| 23 | + | ||
| 24 | +## Ce qui a été vérifié (2026-11-24, mlx-serve 26.11.3, depuis un sandbox sbx) | ||
| 25 | + | ||
| 26 | +Ces vérifications ont été faites avec un fichier d'agent que `mm init` a écrit pour le même modèle et le même usage. Il avait le même provider, le même modèle, le même échantillonnage et le même interrupteur de raisonnement, mais pas la disposition `.mm` de ce dossier ni les sessions. | ||
| 27 | + | ||
| 28 | +- `mm init --provider mlxserve … --check` a écrit le fichier et le modèle a répondu. | ||
| 29 | +- Des questions en `-p`, le raisonnement affiché (`💭`), et un tour avec outils : l'agent a écrit `hello.go`, l'a lancé avec `go run` et a rapporté `hello mlx`. | ||
| 30 | +- Chaque première requête cassait avec `unexpected end of JSON input` : MLX-Serve envoie des commentaires SSE `: keepalive` pendant qu'il lit le prompt, ce qu'openai-go ne sait pas lire. Corrigé dans `mm` (`internal/engine/ssecomments.go`). | ||
| 31 | +- Avec `curl` : les interrupteurs de raisonnement, `/api/pull` (un modèle qu'il a, un modèle qui n'existe pas), `/v1/unload-model`, et un modèle qu'il n'a pas (servi par son modèle par défaut, HTTP 200 — surveillez l'avertissement du démarrage). | ||
| 32 | + | ||
| 33 | +Non vérifié en direct à travers `mm` : une compaction, un vrai téléchargement par `autoPull`, `/unload`, et un serveur protégé (`--api-key`, `MLX_SERVE_API_KEY`). | ||
| 34 | + | ||
| 35 | +Voir [Comment faire tourner mini-me sur MLX-Serve](../../docs/fr/how-to/run-with-mlx-serve.md). | ||
added
demos/mlx-qwen/.gitignore +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +!.mm | |
| 2 | +.mm/sessions | |
| 3 | +.mm/traces | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +!.mm | ||
| 2 | +.mm/sessions | ||
| 3 | +.mm/traces | ||
added
demos/mlx-qwen/.mm/agent.yaml +104 -0 | new file mode 100644 | ||
| @@ -0,0 +1,104 @@ | ||
| 1 | +# Johnny — a coding agent: reads and changes the project, runs commands. | |
| 2 | +# | |
| 3 | +# Written by `mm init`. Every value says why it has that value; change | |
| 4 | +# them as you watch the agent work: | |
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | |
| 6 | +# | |
| 7 | +# model family: qwen | |
| 8 | +# usage: developer | |
| 9 | +# machine: small — a laptop, models up to about 8B | |
| 10 | +# model facts: read from mlxserve: nothing beyond the model's name | |
| 11 | +# | |
| 12 | +# Where the numbers come from (the tag before their comment): | |
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | |
| 14 | +# [guide] the settings guide's row for this machine | |
| 15 | +# [rule] a rule of thumb, not specific to this model | |
| 16 | +# | |
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | |
| 18 | + | |
| 19 | +provider: mlxserve | |
| 20 | +# The model. Chosen for it (family qwen): sampling (temperature, top_p, top_k, | |
| 21 | +# max_tokens) and sampling.chat_template_kwargs (enable_thinking). Change the | |
| 22 | +# model and redo them together — running mm init again is the quick way. | |
| 23 | +model: "lmstudio-community/Qwen3.8-27B-MLX-4bit" | |
| 24 | +# No baseUrl: mlxserve's defaults apply. For the record: | |
| 25 | +# baseUrl: "http://127.0.0.1:11234/v1" | |
| 26 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | |
| 27 | + | |
| 28 | +# 0 = mm asks the server for the window it serves | |
| 29 | +contextWindow: 0 | |
| 30 | +# your answer: every command and file change waits for your answer | |
| 31 | +yolo: false | |
| 32 | +# usage developer | |
| 33 | +bashTool: true | |
| 34 | +editTools: true | |
| 35 | +planTool: true | |
| 36 | +askUserTool: true | |
| 37 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | |
| 38 | +# relative to the directory mm is started from, the project root (see | |
| 39 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | |
| 40 | +skillsDir: .mm/skills | |
| 41 | +# usage developer | |
| 42 | +maxTurns: 40 | |
| 43 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 44 | +maxOutput: 8000 | |
| 45 | +firstTokenTimeout: 3m | |
| 46 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | |
| 47 | +# (section 3) | |
| 48 | +watchdogTimeout: 30s | |
| 49 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 50 | +bashTimeout: 30s | |
| 51 | + | |
| 52 | +sampling: | |
| 53 | + # [card] family qwen: Qwen model cards (thinking 0.6 / 0.95 / 20, | |
| 54 | + # non-thinking 0.7 / 0.8 / 20); precise 0.0 measured with Qwen3.5 4B, | |
| 55 | + # thinking off (demos/docs-search, memory-search, plans) | |
| 56 | + temperature: 0.6 | |
| 57 | + top_p: 0.95 | |
| 58 | + top_k: 20 | |
| 59 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | |
| 60 | + max_tokens: 16384 | |
| 61 | + # one tool call per reply: small models run a check before the change it | |
| 62 | + # checks has landed otherwise | |
| 63 | + parallel_tool_calls: false | |
| 64 | + chat_template_kwargs: | |
| 65 | + # reasoning on: code and multi-step work (family qwen) | |
| 66 | + enable_thinking: true | |
| 67 | + | |
| 68 | +context: | |
| 69 | + # compress the history before the window is full (settings guide, every row) | |
| 70 | + enabled: true | |
| 71 | + # mm's default: 75 % of the window the server serves, a quarter left for the | |
| 72 | + # next question and its tool outputs | |
| 73 | + threshold: 75 | |
| 74 | + | |
| 75 | +sessions: | |
| 76 | + # your answer: every conversation is saved; /sessions lists them, /resume | |
| 77 | + # reopens one | |
| 78 | + enabled: true | |
| 79 | + # relative to the directory mm is started from: one folder per project | |
| 80 | + dir: .mm/sessions | |
| 81 | + | |
| 82 | +agentsMd: | |
| 83 | + # An AGENTS.md in the project directory is added to the system prompt. | |
| 84 | + enabled: true | |
| 85 | + | |
| 86 | +acp: | |
| 87 | + name: johnny | |
| 88 | + title: "Johnny (developer)" | |
| 89 | + | |
| 90 | +system: | | |
| 91 | + Your name is Johnny. | |
| 92 | + You are a coding agent working in a terminal, in the user's project. | |
| 93 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | |
| 94 | + plan tool. | |
| 95 | + Read before you change: look at the files and run the commands that tell | |
| 96 | + you how the project works. Make the smallest change that does the job, | |
| 97 | + then run the tests or the build to check it. | |
| 98 | + Never state the output of a command you did not run in this answer. | |
| 99 | + When a task has several steps, make a plan and update it as you go. | |
| 100 | + | |
| 101 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | |
| 102 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | |
| 103 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | |
| 104 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | |
| new file mode 100644 | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | +# Johnny — a coding agent: reads and changes the project, runs commands. | ||
| 2 | +# | ||
| 3 | +# Written by `mm init`. Every value says why it has that value; change | ||
| 4 | +# them as you watch the agent work: | ||
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | ||
| 6 | +# | ||
| 7 | +# model family: qwen | ||
| 8 | +# usage: developer | ||
| 9 | +# machine: small — a laptop, models up to about 8B | ||
| 10 | +# model facts: read from mlxserve: nothing beyond the model's name | ||
| 11 | +# | ||
| 12 | +# Where the numbers come from (the tag before their comment): | ||
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | ||
| 14 | +# [guide] the settings guide's row for this machine | ||
| 15 | +# [rule] a rule of thumb, not specific to this model | ||
| 16 | +# | ||
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | ||
| 18 | + | ||
| 19 | +provider: mlxserve | ||
| 20 | +# The model. Chosen for it (family qwen): sampling (temperature, top_p, top_k, | ||
| 21 | +# max_tokens) and sampling.chat_template_kwargs (enable_thinking). Change the | ||
| 22 | +# model and redo them together — running mm init again is the quick way. | ||
| 23 | +model: "lmstudio-community/Qwen3.8-27B-MLX-4bit" | ||
| 24 | +# No baseUrl: mlxserve's defaults apply. For the record: | ||
| 25 | +# baseUrl: "http://127.0.0.1:11234/v1" | ||
| 26 | +# fallback: "http://host.docker.internal:11234/v1" # tried when baseUrl does not answer | ||
| 27 | + | ||
| 28 | +# 0 = mm asks the server for the window it serves | ||
| 29 | +contextWindow: 0 | ||
| 30 | +# your answer: every command and file change waits for your answer | ||
| 31 | +yolo: false | ||
| 32 | +# usage developer | ||
| 33 | +bashTool: true | ||
| 34 | +editTools: true | ||
| 35 | +planTool: true | ||
| 36 | +askUserTool: true | ||
| 37 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | ||
| 38 | +# relative to the directory mm is started from, the project root (see | ||
| 39 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | ||
| 40 | +skillsDir: .mm/skills | ||
| 41 | +# usage developer | ||
| 42 | +maxTurns: 40 | ||
| 43 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 44 | +maxOutput: 8000 | ||
| 45 | +firstTokenTimeout: 3m | ||
| 46 | +# [guide] aligned on bashTimeout, as the settings guide says when bash is on | ||
| 47 | +# (section 3) | ||
| 48 | +watchdogTimeout: 30s | ||
| 49 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 50 | +bashTimeout: 30s | ||
| 51 | + | ||
| 52 | +sampling: | ||
| 53 | + # [card] family qwen: Qwen model cards (thinking 0.6 / 0.95 / 20, | ||
| 54 | + # non-thinking 0.7 / 0.8 / 20); precise 0.0 measured with Qwen3.5 4B, | ||
| 55 | + # thinking off (demos/docs-search, memory-search, plans) | ||
| 56 | + temperature: 0.6 | ||
| 57 | + top_p: 0.95 | ||
| 58 | + top_k: 20 | ||
| 59 | + # [rule] reasoning on: room for the thoughts plus a whole tool call | ||
| 60 | + max_tokens: 16384 | ||
| 61 | + # one tool call per reply: small models run a check before the change it | ||
| 62 | + # checks has landed otherwise | ||
| 63 | + parallel_tool_calls: false | ||
| 64 | + chat_template_kwargs: | ||
| 65 | + # reasoning on: code and multi-step work (family qwen) | ||
| 66 | + enable_thinking: true | ||
| 67 | + | ||
| 68 | +context: | ||
| 69 | + # compress the history before the window is full (settings guide, every row) | ||
| 70 | + enabled: true | ||
| 71 | + # mm's default: 75 % of the window the server serves, a quarter left for the | ||
| 72 | + # next question and its tool outputs | ||
| 73 | + threshold: 75 | ||
| 74 | + | ||
| 75 | +sessions: | ||
| 76 | + # your answer: every conversation is saved; /sessions lists them, /resume | ||
| 77 | + # reopens one | ||
| 78 | + enabled: true | ||
| 79 | + # relative to the directory mm is started from: one folder per project | ||
| 80 | + dir: .mm/sessions | ||
| 81 | + | ||
| 82 | +agentsMd: | ||
| 83 | + # An AGENTS.md in the project directory is added to the system prompt. | ||
| 84 | + enabled: true | ||
| 85 | + | ||
| 86 | +acp: | ||
| 87 | + name: johnny | ||
| 88 | + title: "Johnny (developer)" | ||
| 89 | + | ||
| 90 | +system: | | ||
| 91 | + Your name is Johnny. | ||
| 92 | + You are a coding agent working in a terminal, in the user's project. | ||
| 93 | + You have a bash tool, file tools (read_file, write_file, edit_file) and a | ||
| 94 | + plan tool. | ||
| 95 | + Read before you change: look at the files and run the commands that tell | ||
| 96 | + you how the project works. Make the smallest change that does the job, | ||
| 97 | + then run the tests or the build to check it. | ||
| 98 | + Never state the output of a command you did not run in this answer. | ||
| 99 | + When a task has several steps, make a plan and update it as you go. | ||
| 100 | + | ||
| 101 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | ||
| 102 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | ||
| 103 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | ||
| 104 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | ||
modified
docs/en/README.md +1 -0 | @@ -17,6 +17,7 @@ This documentation is organised along the four [Diátaxis](https://diataxis.fr) | ||
| 17 | 17 | - [Run mini-me on llmman](how-to/run-with-llmman.md) — `provider: llmman`, the demo config in `demos/llmman/` |
| 18 | 18 | - [Run mini-me on Ollama](how-to/run-with-ollama.md) — `provider: ollama`, the demo config in `demos/ollama/` |
| 19 | 19 | - [Run mini-me on Kronk](how-to/run-with-kronk.md) — `provider: kronk`, the demo config in `demos/kronk/` |
| 20 | +- [Run mini-me on MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, the demo config in `demos/mlx-gemma-4-e4b/` | |
| 20 | 21 | - [Use any OpenAI-compatible server](how-to/run-with-an-openai-compatible-server.md) — `provider: openai`: the OpenAI API, vLLM, LM Studio, a gateway |
| 21 | 22 | - [Keep reasoning and tools together with OpenAI's Responses API](how-to/use-the-openai-responses-api.md) — `provider: openai-responses`: OpenAI's reasoning models with tools |
| 22 | 23 | - [Ask another mm agent from your session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<name>`, `/ask-with-context-<name>` |
| @@ -17,6 +17,7 @@ This documentation is organised along the four [Diátaxis](https://diataxis.fr) | |||
| 17 | - [Run mini-me on llmman](how-to/run-with-llmman.md) — `provider: llmman`, the demo config in `demos/llmman/` | 17 | - [Run mini-me on llmman](how-to/run-with-llmman.md) — `provider: llmman`, the demo config in `demos/llmman/` |
| 18 | - [Run mini-me on Ollama](how-to/run-with-ollama.md) — `provider: ollama`, the demo config in `demos/ollama/` | 18 | - [Run mini-me on Ollama](how-to/run-with-ollama.md) — `provider: ollama`, the demo config in `demos/ollama/` |
| 19 | - [Run mini-me on Kronk](how-to/run-with-kronk.md) — `provider: kronk`, the demo config in `demos/kronk/` | 19 | - [Run mini-me on Kronk](how-to/run-with-kronk.md) — `provider: kronk`, the demo config in `demos/kronk/` |
| 20 | +- [Run mini-me on MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, the demo config in `demos/mlx-gemma-4-e4b/` | ||
| 20 | - [Use any OpenAI-compatible server](how-to/run-with-an-openai-compatible-server.md) — `provider: openai`: the OpenAI API, vLLM, LM Studio, a gateway | 21 | - [Use any OpenAI-compatible server](how-to/run-with-an-openai-compatible-server.md) — `provider: openai`: the OpenAI API, vLLM, LM Studio, a gateway |
| 21 | - [Keep reasoning and tools together with OpenAI's Responses API](how-to/use-the-openai-responses-api.md) — `provider: openai-responses`: OpenAI's reasoning models with tools | 22 | - [Keep reasoning and tools together with OpenAI's Responses API](how-to/use-the-openai-responses-api.md) — `provider: openai-responses`: OpenAI's reasoning models with tools |
| 22 | - [Ask another mm agent from your session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<name>`, `/ask-with-context-<name>` | 23 | - [Ask another mm agent from your session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<name>`, `/ask-with-context-<name>` |
modified
docs/en/explanation/mm-init.md +1 -0 | @@ -17,6 +17,7 @@ The server knows the exact model that is loaded, so it is the most specific sour | ||
| 17 | 17 | | `llmman`, `ollama` | `/api/tags`, then `/api/show` | the model list, the family the server reports (`details.family`), the native context window, the sampling written in the GGUF (`temperature`, `top_p`, `top_k`, `min_p`), the chat template | |
| 18 | 18 | | `llamacpp` | `/props` | the window and the chat template | |
| 19 | 19 | | `kronk` | `/models`, then `/v1/kronk/models/<id>` | the model list, the architecture, the window the model is configured with (the trained one when none), the sampling written in the GGUF, the chat template; for a profile, its own sampling, which wins over every other source: `mm` sends its sampling with every request and a request's value replaces a profile's, so the profile's values would otherwise never apply | |
| 20 | +| `mlxserve` | `/models`, then `/api/show` | the model list, the family, the window (the served one when the model is loaded), the chat template, and the model's own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`) | | |
| 20 | 21 | | `dmr` | `/models` | the model list only | |
| 21 | 22 | | `openai`, `openai-responses` | `/models` (with the key) | the model list only | |
| 22 | 23 | |
| @@ -17,6 +17,7 @@ The server knows the exact model that is loaded, so it is the most specific sour | |||
| 17 | | `llmman`, `ollama` | `/api/tags`, then `/api/show` | the model list, the family the server reports (`details.family`), the native context window, the sampling written in the GGUF (`temperature`, `top_p`, `top_k`, `min_p`), the chat template | | 17 | | `llmman`, `ollama` | `/api/tags`, then `/api/show` | the model list, the family the server reports (`details.family`), the native context window, the sampling written in the GGUF (`temperature`, `top_p`, `top_k`, `min_p`), the chat template | |
| 18 | | `llamacpp` | `/props` | the window and the chat template | | 18 | | `llamacpp` | `/props` | the window and the chat template | |
| 19 | | `kronk` | `/models`, then `/v1/kronk/models/<id>` | the model list, the architecture, the window the model is configured with (the trained one when none), the sampling written in the GGUF, the chat template; for a profile, its own sampling, which wins over every other source: `mm` sends its sampling with every request and a request's value replaces a profile's, so the profile's values would otherwise never apply | | 19 | | `kronk` | `/models`, then `/v1/kronk/models/<id>` | the model list, the architecture, the window the model is configured with (the trained one when none), the sampling written in the GGUF, the chat template; for a profile, its own sampling, which wins over every other source: `mm` sends its sampling with every request and a request's value replaces a profile's, so the profile's values would otherwise never apply | |
| 20 | +| `mlxserve` | `/models`, then `/api/show` | the model list, the family, the window (the served one when the model is loaded), the chat template, and the model's own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`) | | ||
| 20 | | `dmr` | `/models` | the model list only | | 21 | | `dmr` | `/models` | the model list only | |
| 21 | | `openai`, `openai-responses` | `/models` (with the key) | the model list only | | 22 | | `openai`, `openai-responses` | `/models` (with the key) | the model list only | |
| 22 | 23 | ||
modified
docs/en/explanation/providers.md +4 -2 | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | ## What is this about? |
| 4 | 4 | |
| 5 | -`mm` talks to a local model server through the OpenAI chat-completions API. Five servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama and Kronk, under the names `dmr`, `llamacpp`, `llmman`, `ollama` and `kronk`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it. | |
| 5 | +`mm` talks to a local model server through the OpenAI chat-completions API. Six servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama, Kronk and MLX-Serve, under the names `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` and `mlxserve`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it. | |
| 6 | 6 | |
| 7 | 7 | ## Why it is designed this way |
| 8 | 8 | |
| @@ -22,6 +22,8 @@ | ||
| 22 | 22 | |
| 23 | 23 | **Kronk is a fifth entry, with its own routes beside the OpenAI ones.** [Kronk](https://www.kronkai.com) (`kronk server start`, port 11435, ticket 75) is a Go server that embeds llama.cpp directly, without a `llama-server` process. Measured on Kronk 1.33.2, it behaves like llama.cpp where it matters to `mm`: reasoning streams as `reasoning_content`, and `chat_template_kwargs` turns it off, while `reasoning_effort: "none"` is ignored. Like Ollama, it sends no prompt progress. The window, the pull and the unload have their own routes under `/v1/kronk/…`. `GET /v1/kronk/models/<id>` reports the window the model is configured with, loaded or not, so it is known at start-up. The id contains a `/` (`provider/modelID`), so it travels escaped: a raw `/` splits the path. The pull, `POST /v1/kronk/models/pull`, answers 200 even when it fails, so only the stream's last record (`"downloaded": true`, or the reason) says how it ended. An installed model loads on the first request; a missing one is a 404, hence the probe's `kronk model pull` warning. Kronk listens on the loopback only, so the sandbox fallback works only once the host starts it with `--api-host 0.0.0.0:11435`. Kronk also lists configuration profiles (`provider/modelID/PROFILE`, the same weights with their own `model_config.yaml` settings); `mm` treats them as models, and the probe reads the profile's own window. A profile's sampling only fills in what the request leaves out, so `mm`'s own `sampling` wins: measured with `temperature` and `max_tokens`. |
| 24 | 24 | |
| 25 | +**MLX-Serve is a sixth entry, and the first whose silence is the trap.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) runs MLX models on Apple Silicon and speaks the OpenAI, Anthropic and Ollama APIs on one port; `mm` uses the OpenAI side, and Ollama's `/api/pull` for `autoPull`. Measured on mlx-serve 26.11.3: reasoning streams as `reasoning_content` and is on when **either** `enable_thinking` **or** `reasoning_effort` asks for it, so a summary is sent with both off (a third way of turning reasoning off, beside the template and the effort). No prompt progress. `GET /v1/models` lists every downloaded model with `loaded` and `context_length`: loaded, that is the window it is served with (it changed from 101376 to 73728 between two loads, with less free memory), unloaded, the trained length — so the probe trusts it only for a loaded model. A model the server does not have is answered anyway, with HTTP 200, by its default model: no 404 will ever tell, so the start-up warning is the only place it shows. And while it reads a long prompt it sends SSE comments (`: keepalive`); openai-go turns the blank line after one into an empty event and fails on it (`unexpected end of JSON input`). `mm` now removes comment-only blocks from every stream before openai-go sees them. | |
| 26 | + | |
| 25 | 27 | **Errors are rewritten in the server's own words.** A stack of wrapped messages is noise; "tool calls need llama-server started with --jinja" is the whole diagnosis. The provider recognises connection refusals, the missing `--jinja` flag, 401/403, 404 with a pull or alias hint, 429 and 5xx. Unknown errors come back unchanged: a raw message beats a wrong hint. |
| 26 | 28 | |
| 27 | 29 | **A stream the server breaks is retried, and its words are kept.** llama.cpp reports a failure in the middle of a streamed answer as an SSE `error:` event (the 200 status is already sent). openai-go only reads `data:` lines, so the message used to vanish behind `unexpected end of JSON input`. The tap that reads the stream for reasoning also picks up those events, and the model call that broke is retried once — that call only: the tools that ran earlier in the turn are not replayed, and text the broken attempt already streamed is not taken back. If it breaks again, the error shows the server's own message (`the model server reported an error while generating: Failed to parse input at pos …`), or says the connection broke. Either way the history is kept: asking to continue picks the work up. |
| @@ -40,5 +42,5 @@ | ||
| 40 | 42 | |
| 41 | 43 | - The two configuration files that parametrise each provider are listed in the [configuration reference](../reference/configuration.md). |
| 42 | 44 | - The window the probe learns is what [context compression](context-compression.md) measures against. |
| 43 | -- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) and [how to run on Kronk](../how-to/run-with-kronk.md). | |
| 45 | +- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) [how to run on Kronk](../how-to/run-with-kronk.md) and [how to run on MLX-Serve](../how-to/run-with-mlx-serve.md). | |
| 44 | 46 | - Checking the tool order and measuring the cache gain on your own server: [how to check that the tools go out in a stable order](../how-to/verify-tool-order.md). |
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | ## What is this about? | 3 | ## What is this about? |
| 4 | 4 | ||
| 5 | -`mm` talks to a local model server through the OpenAI chat-completions API. Five servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama and Kronk, under the names `dmr`, `llamacpp`, `llmman`, `ollama` and `kronk`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it. | 5 | +`mm` talks to a local model server through the OpenAI chat-completions API. Six servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama, Kronk and MLX-Serve, under the names `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` and `mlxserve`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it. |
| 6 | 6 | ||
| 7 | ## Why it is designed this way | 7 | ## Why it is designed this way |
| 8 | 8 | ||
| @@ -22,6 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | **Kronk is a fifth entry, with its own routes beside the OpenAI ones.** [Kronk](https://www.kronkai.com) (`kronk server start`, port 11435, ticket 75) is a Go server that embeds llama.cpp directly, without a `llama-server` process. Measured on Kronk 1.33.2, it behaves like llama.cpp where it matters to `mm`: reasoning streams as `reasoning_content`, and `chat_template_kwargs` turns it off, while `reasoning_effort: "none"` is ignored. Like Ollama, it sends no prompt progress. The window, the pull and the unload have their own routes under `/v1/kronk/…`. `GET /v1/kronk/models/<id>` reports the window the model is configured with, loaded or not, so it is known at start-up. The id contains a `/` (`provider/modelID`), so it travels escaped: a raw `/` splits the path. The pull, `POST /v1/kronk/models/pull`, answers 200 even when it fails, so only the stream's last record (`"downloaded": true`, or the reason) says how it ended. An installed model loads on the first request; a missing one is a 404, hence the probe's `kronk model pull` warning. Kronk listens on the loopback only, so the sandbox fallback works only once the host starts it with `--api-host 0.0.0.0:11435`. Kronk also lists configuration profiles (`provider/modelID/PROFILE`, the same weights with their own `model_config.yaml` settings); `mm` treats them as models, and the probe reads the profile's own window. A profile's sampling only fills in what the request leaves out, so `mm`'s own `sampling` wins: measured with `temperature` and `max_tokens`. | 23 | **Kronk is a fifth entry, with its own routes beside the OpenAI ones.** [Kronk](https://www.kronkai.com) (`kronk server start`, port 11435, ticket 75) is a Go server that embeds llama.cpp directly, without a `llama-server` process. Measured on Kronk 1.33.2, it behaves like llama.cpp where it matters to `mm`: reasoning streams as `reasoning_content`, and `chat_template_kwargs` turns it off, while `reasoning_effort: "none"` is ignored. Like Ollama, it sends no prompt progress. The window, the pull and the unload have their own routes under `/v1/kronk/…`. `GET /v1/kronk/models/<id>` reports the window the model is configured with, loaded or not, so it is known at start-up. The id contains a `/` (`provider/modelID`), so it travels escaped: a raw `/` splits the path. The pull, `POST /v1/kronk/models/pull`, answers 200 even when it fails, so only the stream's last record (`"downloaded": true`, or the reason) says how it ended. An installed model loads on the first request; a missing one is a 404, hence the probe's `kronk model pull` warning. Kronk listens on the loopback only, so the sandbox fallback works only once the host starts it with `--api-host 0.0.0.0:11435`. Kronk also lists configuration profiles (`provider/modelID/PROFILE`, the same weights with their own `model_config.yaml` settings); `mm` treats them as models, and the probe reads the profile's own window. A profile's sampling only fills in what the request leaves out, so `mm`'s own `sampling` wins: measured with `temperature` and `max_tokens`. |
| 24 | 24 | ||
| 25 | +**MLX-Serve is a sixth entry, and the first whose silence is the trap.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) runs MLX models on Apple Silicon and speaks the OpenAI, Anthropic and Ollama APIs on one port; `mm` uses the OpenAI side, and Ollama's `/api/pull` for `autoPull`. Measured on mlx-serve 26.11.3: reasoning streams as `reasoning_content` and is on when **either** `enable_thinking` **or** `reasoning_effort` asks for it, so a summary is sent with both off (a third way of turning reasoning off, beside the template and the effort). No prompt progress. `GET /v1/models` lists every downloaded model with `loaded` and `context_length`: loaded, that is the window it is served with (it changed from 101376 to 73728 between two loads, with less free memory), unloaded, the trained length — so the probe trusts it only for a loaded model. A model the server does not have is answered anyway, with HTTP 200, by its default model: no 404 will ever tell, so the start-up warning is the only place it shows. And while it reads a long prompt it sends SSE comments (`: keepalive`); openai-go turns the blank line after one into an empty event and fails on it (`unexpected end of JSON input`). `mm` now removes comment-only blocks from every stream before openai-go sees them. | ||
| 26 | + | ||
| 25 | **Errors are rewritten in the server's own words.** A stack of wrapped messages is noise; "tool calls need llama-server started with --jinja" is the whole diagnosis. The provider recognises connection refusals, the missing `--jinja` flag, 401/403, 404 with a pull or alias hint, 429 and 5xx. Unknown errors come back unchanged: a raw message beats a wrong hint. | 27 | **Errors are rewritten in the server's own words.** A stack of wrapped messages is noise; "tool calls need llama-server started with --jinja" is the whole diagnosis. The provider recognises connection refusals, the missing `--jinja` flag, 401/403, 404 with a pull or alias hint, 429 and 5xx. Unknown errors come back unchanged: a raw message beats a wrong hint. |
| 26 | 28 | ||
| 27 | **A stream the server breaks is retried, and its words are kept.** llama.cpp reports a failure in the middle of a streamed answer as an SSE `error:` event (the 200 status is already sent). openai-go only reads `data:` lines, so the message used to vanish behind `unexpected end of JSON input`. The tap that reads the stream for reasoning also picks up those events, and the model call that broke is retried once — that call only: the tools that ran earlier in the turn are not replayed, and text the broken attempt already streamed is not taken back. If it breaks again, the error shows the server's own message (`the model server reported an error while generating: Failed to parse input at pos …`), or says the connection broke. Either way the history is kept: asking to continue picks the work up. | 29 | **A stream the server breaks is retried, and its words are kept.** llama.cpp reports a failure in the middle of a streamed answer as an SSE `error:` event (the 200 status is already sent). openai-go only reads `data:` lines, so the message used to vanish behind `unexpected end of JSON input`. The tap that reads the stream for reasoning also picks up those events, and the model call that broke is retried once — that call only: the tools that ran earlier in the turn are not replayed, and text the broken attempt already streamed is not taken back. If it breaks again, the error shows the server's own message (`the model server reported an error while generating: Failed to parse input at pos …`), or says the connection broke. Either way the history is kept: asking to continue picks the work up. |
| @@ -40,5 +42,5 @@ | |||
| 40 | 42 | ||
| 41 | - The two configuration files that parametrise each provider are listed in the [configuration reference](../reference/configuration.md). | 43 | - The two configuration files that parametrise each provider are listed in the [configuration reference](../reference/configuration.md). |
| 42 | - The window the probe learns is what [context compression](context-compression.md) measures against. | 44 | - The window the probe learns is what [context compression](context-compression.md) measures against. |
| 43 | -- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) and [how to run on Kronk](../how-to/run-with-kronk.md). | 45 | +- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) [how to run on Kronk](../how-to/run-with-kronk.md) and [how to run on MLX-Serve](../how-to/run-with-mlx-serve.md). |
| 44 | - Checking the tool order and measuring the cache gain on your own server: [how to check that the tools go out in a stable order](../how-to/verify-tool-order.md). | 46 | - Checking the tool order and measuring the cache gain on your own server: [how to check that the tools go out in a stable order](../how-to/verify-tool-order.md). |
modified
docs/en/how-to/run-in-a-container.md +1 -1 | @@ -68,7 +68,7 @@ The project is mounted at the same path as on your machine, so the paths the edi | ||
| 68 | 68 | |
| 69 | 69 | ## Reach the model |
| 70 | 70 | |
| 71 | -From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too. | |
| 71 | +From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too. | |
| 72 | 72 | |
| 73 | 73 | - **`llamacpp`**: on Linux, start llama-server with `--host 0.0.0.0`, as it listens on the loopback only by default (see the last point). Files written before v1.1.0 may say `fallback: ""`: remove that line. |
| 74 | 74 | - **An agent file with a `baseUrl` on `localhost` or `127.0.0.1`:** replace the host with `host.docker.internal`, or add a `fallback`. |
| @@ -68,7 +68,7 @@ The project is mounted at the same path as on your machine, so the paths the edi | |||
| 68 | 68 | ||
| 69 | ## Reach the model | 69 | ## Reach the model |
| 70 | 70 | ||
| 71 | -From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too. | 71 | +From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too. |
| 72 | 72 | ||
| 73 | - **`llamacpp`**: on Linux, start llama-server with `--host 0.0.0.0`, as it listens on the loopback only by default (see the last point). Files written before v1.1.0 may say `fallback: ""`: remove that line. | 73 | - **`llamacpp`**: on Linux, start llama-server with `--host 0.0.0.0`, as it listens on the loopback only by default (see the last point). Files written before v1.1.0 may say `fallback: ""`: remove that line. |
| 74 | - **An agent file with a `baseUrl` on `localhost` or `127.0.0.1`:** replace the host with `host.docker.internal`, or add a `fallback`. | 74 | - **An agent file with a `baseUrl` on `localhost` or `127.0.0.1`:** replace the host with `host.docker.internal`, or add a `fallback`. |
added
docs/en/how-to/run-with-mlx-serve.md +31 -0 | new file mode 100644 | ||
| @@ -0,0 +1,31 @@ | ||
| 1 | +# How to run mini-me on MLX-Serve | |
| 2 | + | |
| 3 | +This guide shows how to point `mm` at [MLX-Serve](https://github.com/ddalcu/mlx-serve), a local model server for Apple Silicon (MLX, no Python), through its OpenAI-compatible endpoint. It assumes MLX-Serve is installed (the app, or `brew install mlx-serve` for the server only) and that you know how to build `mm`. | |
| 4 | + | |
| 5 | +## Steps | |
| 6 | + | |
| 7 | +1. Download a model and start the server. `mlx-serve serve` serves every downloaded model on `0.0.0.0:11234` and loads a model on the first request that names it: | |
| 8 | + | |
| 9 | + ```bash | |
| 10 | + mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | |
| 11 | + mlx-serve serve # or open the MLX-Serve app | |
| 12 | + ``` | |
| 13 | + | |
| 14 | +2. Run the demo configuration from its directory: | |
| 15 | + | |
| 16 | + ```bash | |
| 17 | + cd demos/mlx-gemma-4-e4b | |
| 18 | + ../../mm # finds .mm/agent.yaml | |
| 19 | + ``` | |
| 20 | + | |
| 21 | +3. Check the banner. `provider: mlxserve` confirms the provider. When the model is loaded, `ctx: 101376 (/v1/models)` is the window MLX-Serve serves it with. When it is not loaded yet, the window is unknown at start-up and `mm` learns it before the next question, once the first answer has loaded the model. | |
| 22 | + | |
| 23 | +## Variants | |
| 24 | + | |
| 25 | +- **Another model.** Set `model:` to the id exactly as `GET /v1/models` lists it (`curl -s localhost:11234/v1/models`). **Check the start-up warnings:** a model MLX-Serve does not have is not an error on its side — it answers with its default model under the name you asked for. The only sign is the warning `model "…" is not downloaded — mlx-serve pull …`. | |
| 26 | +- **Write the file with the wizard.** `mm init --provider mlxserve` lists the server's models and reads the chosen one's family, window, chat template (`/api/show`) and its own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`). `--check` asks the model one question. See [How to create an agent](create-an-agent.md). | |
| 27 | +- **Let mm pull the model.** With `autoPull: true`, mm downloads a model the server does not list at start-up, through `POST /api/pull` (Ollama's wire, which MLX-Serve speaks), and shows the progress. See [`autoPull`](../reference/configuration.md). | |
| 28 | +- **Reasoning.** MLX-Serve reasons when **either** `chat_template_kwargs.enable_thinking` **or** `reasoning_effort` says so. To turn it off for every turn, say no to both in `sampling` — or leave both out: Gemma 4 does not reason by default. See [How to turn a model's reasoning off](turn-reasoning-off.md). | |
| 29 | +- **From a container or a Docker sandbox.** MLX-Serve listens on all interfaces by default, so with no `baseUrl` answering, `mm` falls back to `http://host.docker.internal:11234/v1` by itself. In a sandbox, allow `localhost:11234` in the network policy. | |
| 30 | +- **A protected MLX-Serve.** A server started with `--api-key KEY` checks the key for every caller but localhost — a container or a sandbox is not localhost. Export it in `MLX_SERVE_API_KEY` (mm's name for it; or name another variable under `apiKeyEnv`). A refused key is a start-up warning naming the variable. | |
| 31 | +- **Free the memory.** `/unload` and the `unload_model` tool unload the model through `POST /v1/unload-model`. See [How to free a model's memory](unload-a-model.md). | |
| new file mode 100644 | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | +# How to run mini-me on MLX-Serve | ||
| 2 | + | ||
| 3 | +This guide shows how to point `mm` at [MLX-Serve](https://github.com/ddalcu/mlx-serve), a local model server for Apple Silicon (MLX, no Python), through its OpenAI-compatible endpoint. It assumes MLX-Serve is installed (the app, or `brew install mlx-serve` for the server only) and that you know how to build `mm`. | ||
| 4 | + | ||
| 5 | +## Steps | ||
| 6 | + | ||
| 7 | +1. Download a model and start the server. `mlx-serve serve` serves every downloaded model on `0.0.0.0:11234` and loads a model on the first request that names it: | ||
| 8 | + | ||
| 9 | + ```bash | ||
| 10 | + mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | ||
| 11 | + mlx-serve serve # or open the MLX-Serve app | ||
| 12 | + ``` | ||
| 13 | + | ||
| 14 | +2. Run the demo configuration from its directory: | ||
| 15 | + | ||
| 16 | + ```bash | ||
| 17 | + cd demos/mlx-gemma-4-e4b | ||
| 18 | + ../../mm # finds .mm/agent.yaml | ||
| 19 | + ``` | ||
| 20 | + | ||
| 21 | +3. Check the banner. `provider: mlxserve` confirms the provider. When the model is loaded, `ctx: 101376 (/v1/models)` is the window MLX-Serve serves it with. When it is not loaded yet, the window is unknown at start-up and `mm` learns it before the next question, once the first answer has loaded the model. | ||
| 22 | + | ||
| 23 | +## Variants | ||
| 24 | + | ||
| 25 | +- **Another model.** Set `model:` to the id exactly as `GET /v1/models` lists it (`curl -s localhost:11234/v1/models`). **Check the start-up warnings:** a model MLX-Serve does not have is not an error on its side — it answers with its default model under the name you asked for. The only sign is the warning `model "…" is not downloaded — mlx-serve pull …`. | ||
| 26 | +- **Write the file with the wizard.** `mm init --provider mlxserve` lists the server's models and reads the chosen one's family, window, chat template (`/api/show`) and its own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`). `--check` asks the model one question. See [How to create an agent](create-an-agent.md). | ||
| 27 | +- **Let mm pull the model.** With `autoPull: true`, mm downloads a model the server does not list at start-up, through `POST /api/pull` (Ollama's wire, which MLX-Serve speaks), and shows the progress. See [`autoPull`](../reference/configuration.md). | ||
| 28 | +- **Reasoning.** MLX-Serve reasons when **either** `chat_template_kwargs.enable_thinking` **or** `reasoning_effort` says so. To turn it off for every turn, say no to both in `sampling` — or leave both out: Gemma 4 does not reason by default. See [How to turn a model's reasoning off](turn-reasoning-off.md). | ||
| 29 | +- **From a container or a Docker sandbox.** MLX-Serve listens on all interfaces by default, so with no `baseUrl` answering, `mm` falls back to `http://host.docker.internal:11234/v1` by itself. In a sandbox, allow `localhost:11234` in the network policy. | ||
| 30 | +- **A protected MLX-Serve.** A server started with `--api-key KEY` checks the key for every caller but localhost — a container or a sandbox is not localhost. Export it in `MLX_SERVE_API_KEY` (mm's name for it; or name another variable under `apiKeyEnv`). A refused key is a start-up warning naming the variable. | ||
| 31 | +- **Free the memory.** `/unload` and the `unload_model` tool unload the model through `POST /v1/unload-model`. See [How to free a model's memory](unload-a-model.md). | ||
modified
docs/en/how-to/turn-reasoning-off.md +12 -1 | @@ -27,6 +27,17 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a | ||
| 27 | 27 | reasoning_effort: none |
| 28 | 28 | ``` |
| 29 | 29 | |
| 30 | + For `mlxserve`, both — MLX-Serve reasons when either one says so (measured on mlx-serve 26.11.3): | |
| 31 | + | |
| 32 | + ```yaml | |
| 33 | + sampling: | |
| 34 | + temperature: 0.0 | |
| 35 | + max_tokens: 4096 | |
| 36 | + reasoning_effort: none | |
| 37 | + chat_template_kwargs: | |
| 38 | + enable_thinking: false | |
| 39 | + ``` | |
| 40 | + | |
| 30 | 41 | The keys you write are merged with the built-in ones (`temperature`, `top_p`, `max_tokens`): only the switch needs adding. |
| 31 | 42 | |
| 32 | 43 | 3. Ask a question and compare. With reasoning on, the line mode prints a dim `💭` block before the `🤖` answer; with it off, the answer comes straight away: |
| @@ -61,7 +72,7 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a | ||
| 61 | 72 | - On `ollama`, `reasoning_effort` goes at the top level of `sampling`, not under `chat_template_kwargs`; only `none` has been measured there. |
| 62 | 73 | - Compaction summaries do not follow it — see below. |
| 63 | 74 | - **Turn it off for one run.** Keep two configuration files, or start the server itself without reasoning (for llama-server, see its `--reasoning-budget` option). |
| 64 | -- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman` and `kronk` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. | |
| 75 | +- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman` and `kronk` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. On `mlxserve` it does both. | |
| 65 | 76 | |
| 66 | 77 | ## See also |
| 67 | 78 | |
| @@ -27,6 +27,17 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a | |||
| 27 | reasoning_effort: none | 27 | reasoning_effort: none |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | + For `mlxserve`, both — MLX-Serve reasons when either one says so (measured on mlx-serve 26.11.3): | ||
| 31 | + | ||
| 32 | + ```yaml | ||
| 33 | + sampling: | ||
| 34 | + temperature: 0.0 | ||
| 35 | + max_tokens: 4096 | ||
| 36 | + reasoning_effort: none | ||
| 37 | + chat_template_kwargs: | ||
| 38 | + enable_thinking: false | ||
| 39 | + ``` | ||
| 40 | + | ||
| 30 | The keys you write are merged with the built-in ones (`temperature`, `top_p`, `max_tokens`): only the switch needs adding. | 41 | The keys you write are merged with the built-in ones (`temperature`, `top_p`, `max_tokens`): only the switch needs adding. |
| 31 | 42 | ||
| 32 | 3. Ask a question and compare. With reasoning on, the line mode prints a dim `💭` block before the `🤖` answer; with it off, the answer comes straight away: | 43 | 3. Ask a question and compare. With reasoning on, the line mode prints a dim `💭` block before the `🤖` answer; with it off, the answer comes straight away: |
| @@ -61,7 +72,7 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a | |||
| 61 | - On `ollama`, `reasoning_effort` goes at the top level of `sampling`, not under `chat_template_kwargs`; only `none` has been measured there. | 72 | - On `ollama`, `reasoning_effort` goes at the top level of `sampling`, not under `chat_template_kwargs`; only `none` has been measured there. |
| 62 | - Compaction summaries do not follow it — see below. | 73 | - Compaction summaries do not follow it — see below. |
| 63 | - **Turn it off for one run.** Keep two configuration files, or start the server itself without reasoning (for llama-server, see its `--reasoning-budget` option). | 74 | - **Turn it off for one run.** Keep two configuration files, or start the server itself without reasoning (for llama-server, see its `--reasoning-budget` option). |
| 64 | -- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman` and `kronk` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. | 75 | +- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman` and `kronk` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. On `mlxserve` it does both. |
| 65 | 76 | ||
| 66 | ## See also | 77 | ## See also |
| 67 | 78 | ||
modified
docs/en/reference/cli.md +2 -2 | @@ -87,7 +87,7 @@ The rule depends on where the file is, not on how it was found: `-config`, `AGEN | ||
| 87 | 87 | | `MM_BIN` | Set by `mm` in its own environment, so every process it starts inherits it — the commands its `bash` tool runs, its hooks: the path of the running `mm` binary. | |
| 88 | 88 | | `MM_CONFIG` | Set by `mm` in its own environment, like `MM_BIN`, when a configuration file was read: the absolute path of its configuration file. Read by `--ask` / `--ask-with-context` when no `-config` and no positional path are given. | |
| 89 | 89 | | `MM_ASK_DEPTH` | How many `/ask` levels deep this agent runs (unset = 0). Set by `/ask`; at 2, `/ask` is refused. | |
| 90 | -| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`. | | |
| 90 | +| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`, `MLX_SERVE_API_KEY` for `mlxserve`. | | |
| 91 | 91 | |
| 92 | 92 | ## Start-up output |
| 93 | 93 | |
| @@ -247,7 +247,7 @@ An agent file outside the workspace only gives a warning: see [when the agent fi | ||
| 247 | 247 | | Flag | Question when absent | Default | |
| 248 | 248 | |------|----------------------|---------| |
| 249 | 249 | | `--project yes\|no` | Keep everything in a `.mm` folder? — asked first. `yes`: the file is `.mm/agent.yaml` (the folder is created), its paths are written from the project root (`skillsDir: .mm/skills`), and `mm` / `mm tui` started there find it with no argument | `no` | |
| 250 | -| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) | | |
| 250 | +| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) | | |
| 251 | 251 | | `--base-url` | `openai` and `openai-responses` only: Endpoint — the service's OpenAI-compatible address (OpenAI, Cerebras, Hugging Face…); for the other providers, not asked | `https://api.openai.com/v1` for `openai` and `openai-responses`; otherwise `AGENT_BASE_URL` when set, else the first of the provider's local addresses whose model list answers — its default, then the same with `127.0.0.1` when the default names `localhost`, then for `llamacpp` llama-server's former port, `http://127.0.0.1:8080/v1` — and its container fallback (`host.docker.internal`) only when none does. The model question names the address its list comes from (`Model? (listed from …)`). Written as `baseUrl` unless it is the default | |
| 252 | 252 | | `--api-key-env` | `openai` and `openai-responses` only: Environment variable that holds the API key | `OPENAI_API_KEY`. Written as `apiKeyEnv` unless it is the default | |
| 253 | 253 | | `--model` | Model: a list of the server's models (`/api/tags` for llmman and Ollama, `/models` for the others; 5 s for a local server, 20 s for `openai`), or a name to type when there is no list — the question says why (`<VARIABLE> is not set: no list`, or the server's error). For `openai` the list is asked with the key read from the variable named above, and not asked at all when that variable is empty | the first of the list | |
| @@ -87,7 +87,7 @@ The rule depends on where the file is, not on how it was found: `-config`, `AGEN | |||
| 87 | | `MM_BIN` | Set by `mm` in its own environment, so every process it starts inherits it — the commands its `bash` tool runs, its hooks: the path of the running `mm` binary. | | 87 | | `MM_BIN` | Set by `mm` in its own environment, so every process it starts inherits it — the commands its `bash` tool runs, its hooks: the path of the running `mm` binary. | |
| 88 | | `MM_CONFIG` | Set by `mm` in its own environment, like `MM_BIN`, when a configuration file was read: the absolute path of its configuration file. Read by `--ask` / `--ask-with-context` when no `-config` and no positional path are given. | | 88 | | `MM_CONFIG` | Set by `mm` in its own environment, like `MM_BIN`, when a configuration file was read: the absolute path of its configuration file. Read by `--ask` / `--ask-with-context` when no `-config` and no positional path are given. | |
| 89 | | `MM_ASK_DEPTH` | How many `/ask` levels deep this agent runs (unset = 0). Set by `/ask`; at 2, `/ask` is refused. | | 89 | | `MM_ASK_DEPTH` | How many `/ask` levels deep this agent runs (unset = 0). Set by `/ask`; at 2, `/ask` is refused. | |
| 90 | -| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`. | | 90 | +| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`, `MLX_SERVE_API_KEY` for `mlxserve`. | |
| 91 | 91 | ||
| 92 | ## Start-up output | 92 | ## Start-up output |
| 93 | 93 | ||
| @@ -247,7 +247,7 @@ An agent file outside the workspace only gives a warning: see [when the agent fi | |||
| 247 | | Flag | Question when absent | Default | | 247 | | Flag | Question when absent | Default | |
| 248 | |------|----------------------|---------| | 248 | |------|----------------------|---------| |
| 249 | | `--project yes\|no` | Keep everything in a `.mm` folder? — asked first. `yes`: the file is `.mm/agent.yaml` (the folder is created), its paths are written from the project root (`skillsDir: .mm/skills`), and `mm` / `mm tui` started there find it with no argument | `no` | | 249 | | `--project yes\|no` | Keep everything in a `.mm` folder? — asked first. `yes`: the file is `.mm/agent.yaml` (the folder is created), its paths are written from the project root (`skillsDir: .mm/skills`), and `mm` / `mm tui` started there find it with no argument | `no` | |
| 250 | -| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) | | 250 | +| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) | |
| 251 | | `--base-url` | `openai` and `openai-responses` only: Endpoint — the service's OpenAI-compatible address (OpenAI, Cerebras, Hugging Face…); for the other providers, not asked | `https://api.openai.com/v1` for `openai` and `openai-responses`; otherwise `AGENT_BASE_URL` when set, else the first of the provider's local addresses whose model list answers — its default, then the same with `127.0.0.1` when the default names `localhost`, then for `llamacpp` llama-server's former port, `http://127.0.0.1:8080/v1` — and its container fallback (`host.docker.internal`) only when none does. The model question names the address its list comes from (`Model? (listed from …)`). Written as `baseUrl` unless it is the default | | 251 | | `--base-url` | `openai` and `openai-responses` only: Endpoint — the service's OpenAI-compatible address (OpenAI, Cerebras, Hugging Face…); for the other providers, not asked | `https://api.openai.com/v1` for `openai` and `openai-responses`; otherwise `AGENT_BASE_URL` when set, else the first of the provider's local addresses whose model list answers — its default, then the same with `127.0.0.1` when the default names `localhost`, then for `llamacpp` llama-server's former port, `http://127.0.0.1:8080/v1` — and its container fallback (`host.docker.internal`) only when none does. The model question names the address its list comes from (`Model? (listed from …)`). Written as `baseUrl` unless it is the default | |
| 252 | | `--api-key-env` | `openai` and `openai-responses` only: Environment variable that holds the API key | `OPENAI_API_KEY`. Written as `apiKeyEnv` unless it is the default | | 252 | | `--api-key-env` | `openai` and `openai-responses` only: Environment variable that holds the API key | `OPENAI_API_KEY`. Written as `apiKeyEnv` unless it is the default | |
| 253 | | `--model` | Model: a list of the server's models (`/api/tags` for llmman and Ollama, `/models` for the others; 5 s for a local server, 20 s for `openai`), or a name to type when there is no list — the question says why (`<VARIABLE> is not set: no list`, or the server's error). For `openai` the list is asked with the key read from the variable named above, and not asked at all when that variable is empty | the first of the list | | 253 | | `--model` | Model: a list of the server's models (`/api/tags` for llmman and Ollama, `/models` for the others; 5 s for a local server, 20 s for `openai`), or a name to type when there is no list — the question says why (`<VARIABLE> is not set: no list`, or the server's error). For `openai` the list is asked with the key read from the variable named above, and not asked at all when that variable is empty | the first of the list | |
modified
docs/en/reference/configuration.md +3 -2 | @@ -8,7 +8,7 @@ Where `mm` looks for this file: [Configuration file resolution](cli.md#configura | ||
| 8 | 8 | |
| 9 | 9 | | Key | Type | Default | Description | |
| 10 | 10 | |-----|------|---------|-------------| |
| 11 | -| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. | | |
| 11 | +| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. | | |
| 12 | 12 | | `model` | string | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Model identifier in the provider's naming. Overridden by `AGENT_MODEL`. | |
| 13 | 13 | | `baseUrl` | string | `""` (provider default) | OpenAI-compatible endpoint tried first. Overridden by `AGENT_BASE_URL`. | |
| 14 | 14 | | `fallback` | string or absent | absent (provider default) | Endpoint used when `baseUrl` does not answer `/models` within 2 s. Absent = provider default; `""` = no fallback. | |
| @@ -232,6 +232,7 @@ workspace: | ||
| 232 | 232 | | `llmman` | `http://127.0.0.1:17434/v1` | `http://host.docker.internal:17434/v1` | `LLMMAN_API_KEY` | no | |
| 233 | 233 | | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | no | |
| 234 | 234 | | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | no — only Kronk's `authenticated` and `full-protected` modes check it | |
| 235 | +| `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | no — only a server started with `--api-key` checks it, and not for localhost | | |
| 235 | 236 | | `openai` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — a server that needs one answers 401, and the start-up warning names the variable | |
| 236 | 237 | | `openai-responses` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — as `openai` | |
| 237 | 238 | |
| @@ -506,7 +507,7 @@ Reported on stderr as `[config error: <path>: <message>]`, exit code 1 — in ev | ||
| 506 | 507 | | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | a name starting with `with-context` | |
| 507 | 508 | | `mmConfigs.<name>: the path must not be empty` | `<name>: ""`, or a long form without `path` | |
| 508 | 509 | | `hooks: unknown event "x" (…)`, `hooks.<event>[N]: …` | an invalid `hooks:` block — see [hooks](hooks.md#validation-errors) | |
| 509 | -| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, ollama, openai, openai-responses)` | Reported by the engine, as `[engine error: …]`. | | |
| 510 | +| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Reported by the engine, as `[engine error: …]`. | | |
| 510 | 511 | |
| 511 | 512 | A start-up warning, not an error, is printed when `context.enabled` is `true`, the window is unknown and `context.maxMessages` is `0`, and when a declared tool has the name of an MCP tool (`tools: <name> skipped — an MCP tool already has that name`; the tool is not declared), and when the file sets the deprecated `permissions` key (`permissions: ask is deprecated — use yolo: false instead …`). |
| 512 | 513 | |
| @@ -8,7 +8,7 @@ Where `mm` looks for this file: [Configuration file resolution](cli.md#configura | |||
| 8 | 8 | ||
| 9 | | Key | Type | Default | Description | | 9 | | Key | Type | Default | Description | |
| 10 | |-----|------|---------|-------------| | 10 | |-----|------|---------|-------------| |
| 11 | -| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. | | 11 | +| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. | |
| 12 | | `model` | string | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Model identifier in the provider's naming. Overridden by `AGENT_MODEL`. | | 12 | | `model` | string | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Model identifier in the provider's naming. Overridden by `AGENT_MODEL`. | |
| 13 | | `baseUrl` | string | `""` (provider default) | OpenAI-compatible endpoint tried first. Overridden by `AGENT_BASE_URL`. | | 13 | | `baseUrl` | string | `""` (provider default) | OpenAI-compatible endpoint tried first. Overridden by `AGENT_BASE_URL`. | |
| 14 | | `fallback` | string or absent | absent (provider default) | Endpoint used when `baseUrl` does not answer `/models` within 2 s. Absent = provider default; `""` = no fallback. | | 14 | | `fallback` | string or absent | absent (provider default) | Endpoint used when `baseUrl` does not answer `/models` within 2 s. Absent = provider default; `""` = no fallback. | |
| @@ -232,6 +232,7 @@ workspace: | |||
| 232 | | `llmman` | `http://127.0.0.1:17434/v1` | `http://host.docker.internal:17434/v1` | `LLMMAN_API_KEY` | no | | 232 | | `llmman` | `http://127.0.0.1:17434/v1` | `http://host.docker.internal:17434/v1` | `LLMMAN_API_KEY` | no | |
| 233 | | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | no | | 233 | | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | no | |
| 234 | | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | no — only Kronk's `authenticated` and `full-protected` modes check it | | 234 | | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | no — only Kronk's `authenticated` and `full-protected` modes check it | |
| 235 | +| `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | no — only a server started with `--api-key` checks it, and not for localhost | | ||
| 235 | | `openai` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — a server that needs one answers 401, and the start-up warning names the variable | | 236 | | `openai` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — a server that needs one answers 401, and the start-up warning names the variable | |
| 236 | | `openai-responses` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — as `openai` | | 237 | | `openai-responses` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — as `openai` | |
| 237 | 238 | ||
| @@ -506,7 +507,7 @@ Reported on stderr as `[config error: <path>: <message>]`, exit code 1 — in ev | |||
| 506 | | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | a name starting with `with-context` | | 507 | | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | a name starting with `with-context` | |
| 507 | | `mmConfigs.<name>: the path must not be empty` | `<name>: ""`, or a long form without `path` | | 508 | | `mmConfigs.<name>: the path must not be empty` | `<name>: ""`, or a long form without `path` | |
| 508 | | `hooks: unknown event "x" (…)`, `hooks.<event>[N]: …` | an invalid `hooks:` block — see [hooks](hooks.md#validation-errors) | | 509 | | `hooks: unknown event "x" (…)`, `hooks.<event>[N]: …` | an invalid `hooks:` block — see [hooks](hooks.md#validation-errors) | |
| 509 | -| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, ollama, openai, openai-responses)` | Reported by the engine, as `[engine error: …]`. | | 510 | +| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Reported by the engine, as `[engine error: …]`. | |
| 510 | 511 | ||
| 511 | A start-up warning, not an error, is printed when `context.enabled` is `true`, the window is unknown and `context.maxMessages` is `0`, and when a declared tool has the name of an MCP tool (`tools: <name> skipped — an MCP tool already has that name`; the tool is not declared), and when the file sets the deprecated `permissions` key (`permissions: ask is deprecated — use yolo: false instead …`). | 512 | A start-up warning, not an error, is printed when `context.enabled` is `true`, the window is unknown and `context.maxMessages` is `0`, and when a declared tool has the name of an MCP tool (`tools: <name> skipped — an MCP tool already has that name`; the tool is not declared), and when the file sets the deprecated `permissions` key (`permissions: ask is deprecated — use yolo: false instead …`). |
| 512 | 513 | ||
modified
docs/en/reference/tools.md +1 -0 | @@ -317,6 +317,7 @@ Declared when `unloadModels` is true (the default), except beside a `structuredO | ||
| 317 | 317 | |--------|-----------| |
| 318 | 318 | | llmman, `ollama` | Looks the model up in `GET /api/ps` first; when it is loaded, `POST /api/generate {"model": …, "keep_alive": 0}` and expects `done_reason: "unload"`. A model that is not loaded is never asked for: the request would load it first. | |
| 319 | 319 | | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, which expects `status: "unloaded"`. Kronk's 404 for a model that is not loaded gives `<model> was not loaded: nothing to unload`. | |
| 320 | +| `mlxserve` | Looks the model up in `GET /v1/models` first; when it is `loaded`, `POST /v1/unload-model {"model": …}` and expects `state: "unloaded"`. MLX-Serve answers "unloaded" for a model that was not loaded too, hence the look-up. | | |
| 320 | 321 | | `llamacpp` | `POST /models/unload {"model": …}`, which exists in router mode only (llama-server started without a model). A single-model server's 404 gives the reason and the alternatives: router mode, `--sleep-idle-seconds N`, stopping the server. | |
| 321 | 322 | | `dmr` | `cannot unload <model>: the dmr provider cannot unload a model`. | |
| 322 | 323 | | Result | One line: `unloaded <model>`, `<model> was not loaded: nothing to unload`, or `cannot unload <model>: <reason>` (unreachable server, the server's own error, no confirmation). | |
| @@ -317,6 +317,7 @@ Declared when `unloadModels` is true (the default), except beside a `structuredO | |||
| 317 | |--------|-----------| | 317 | |--------|-----------| |
| 318 | | llmman, `ollama` | Looks the model up in `GET /api/ps` first; when it is loaded, `POST /api/generate {"model": …, "keep_alive": 0}` and expects `done_reason: "unload"`. A model that is not loaded is never asked for: the request would load it first. | | 318 | | llmman, `ollama` | Looks the model up in `GET /api/ps` first; when it is loaded, `POST /api/generate {"model": …, "keep_alive": 0}` and expects `done_reason: "unload"`. A model that is not loaded is never asked for: the request would load it first. | |
| 319 | | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, which expects `status: "unloaded"`. Kronk's 404 for a model that is not loaded gives `<model> was not loaded: nothing to unload`. | | 319 | | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, which expects `status: "unloaded"`. Kronk's 404 for a model that is not loaded gives `<model> was not loaded: nothing to unload`. | |
| 320 | +| `mlxserve` | Looks the model up in `GET /v1/models` first; when it is `loaded`, `POST /v1/unload-model {"model": …}` and expects `state: "unloaded"`. MLX-Serve answers "unloaded" for a model that was not loaded too, hence the look-up. | | ||
| 320 | | `llamacpp` | `POST /models/unload {"model": …}`, which exists in router mode only (llama-server started without a model). A single-model server's 404 gives the reason and the alternatives: router mode, `--sleep-idle-seconds N`, stopping the server. | | 321 | | `llamacpp` | `POST /models/unload {"model": …}`, which exists in router mode only (llama-server started without a model). A single-model server's 404 gives the reason and the alternatives: router mode, `--sleep-idle-seconds N`, stopping the server. | |
| 321 | | `dmr` | `cannot unload <model>: the dmr provider cannot unload a model`. | | 322 | | `dmr` | `cannot unload <model>: the dmr provider cannot unload a model`. | |
| 322 | | Result | One line: `unloaded <model>`, `<model> was not loaded: nothing to unload`, or `cannot unload <model>: <reason>` (unreachable server, the server's own error, no confirmation). | | 323 | | Result | One line: `unloaded <model>`, `<model> was not loaded: nothing to unload`, or `cannot unload <model>: <reason>` (unreachable server, the server's own error, no confirmation). | |
modified
docs/fr/README.md +1 -0 | @@ -17,6 +17,7 @@ Cette documentation est organisée selon les quatre quadrants [Diátaxis](https: | ||
| 17 | 17 | - [Faire tourner mini-me sur llmman](how-to/run-with-llmman.md) — `provider: llmman`, la config de démo dans `demos/llmman/` |
| 18 | 18 | - [Faire tourner mini-me sur Ollama](how-to/run-with-ollama.md) — `provider: ollama`, la config de démo dans `demos/ollama/` |
| 19 | 19 | - [Faire tourner mini-me sur Kronk](how-to/run-with-kronk.md) — `provider: kronk`, la config de démo dans `demos/kronk/` |
| 20 | +- [Faire tourner mini-me sur MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, la config de démo dans `demos/mlx-gemma-4-e4b/` | |
| 20 | 21 | - [Utiliser n'importe quel serveur compatible OpenAI](how-to/run-with-an-openai-compatible-server.md) — `provider: openai` : l'API d'OpenAI, vLLM, LM Studio, une passerelle |
| 21 | 22 | - [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](how-to/use-the-openai-responses-api.md) — `provider: openai-responses` : les modèles de raisonnement d'OpenAI avec des outils |
| 22 | 23 | - [Interroger un autre agent mm depuis votre session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<nom>`, `/ask-with-context-<nom>` |
| @@ -17,6 +17,7 @@ Cette documentation est organisée selon les quatre quadrants [Diátaxis](https: | |||
| 17 | - [Faire tourner mini-me sur llmman](how-to/run-with-llmman.md) — `provider: llmman`, la config de démo dans `demos/llmman/` | 17 | - [Faire tourner mini-me sur llmman](how-to/run-with-llmman.md) — `provider: llmman`, la config de démo dans `demos/llmman/` |
| 18 | - [Faire tourner mini-me sur Ollama](how-to/run-with-ollama.md) — `provider: ollama`, la config de démo dans `demos/ollama/` | 18 | - [Faire tourner mini-me sur Ollama](how-to/run-with-ollama.md) — `provider: ollama`, la config de démo dans `demos/ollama/` |
| 19 | - [Faire tourner mini-me sur Kronk](how-to/run-with-kronk.md) — `provider: kronk`, la config de démo dans `demos/kronk/` | 19 | - [Faire tourner mini-me sur Kronk](how-to/run-with-kronk.md) — `provider: kronk`, la config de démo dans `demos/kronk/` |
| 20 | +- [Faire tourner mini-me sur MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, la config de démo dans `demos/mlx-gemma-4-e4b/` | ||
| 20 | - [Utiliser n'importe quel serveur compatible OpenAI](how-to/run-with-an-openai-compatible-server.md) — `provider: openai` : l'API d'OpenAI, vLLM, LM Studio, une passerelle | 21 | - [Utiliser n'importe quel serveur compatible OpenAI](how-to/run-with-an-openai-compatible-server.md) — `provider: openai` : l'API d'OpenAI, vLLM, LM Studio, une passerelle |
| 21 | - [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](how-to/use-the-openai-responses-api.md) — `provider: openai-responses` : les modèles de raisonnement d'OpenAI avec des outils | 22 | - [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](how-to/use-the-openai-responses-api.md) — `provider: openai-responses` : les modèles de raisonnement d'OpenAI avec des outils |
| 22 | - [Interroger un autre agent mm depuis votre session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<nom>`, `/ask-with-context-<nom>` | 23 | - [Interroger un autre agent mm depuis votre session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<nom>`, `/ask-with-context-<nom>` |
modified
docs/fr/explanation/mm-init.md +1 -0 | @@ -17,6 +17,7 @@ Le serveur connaît le modèle exact qui est chargé : c'est la source la plus p | ||
| 17 | 17 | | `llmman`, `ollama` | `/api/tags`, puis `/api/show` | la liste des modèles, la famille annoncée par le serveur (`details.family`), la fenêtre de contexte native, l'échantillonnage écrit dans le GGUF (`temperature`, `top_p`, `top_k`, `min_p`), le template de chat | |
| 18 | 18 | | `llamacpp` | `/props` | la fenêtre et le template de chat | |
| 19 | 19 | | `kronk` | `/models`, puis `/v1/kronk/models/<id>` | la liste des modèles, l'architecture, la fenêtre avec laquelle le modèle est configuré (celle d'entraînement à défaut), l'échantillonnage écrit dans le GGUF, le template de chat ; pour un profil, son propre échantillonnage, qui l'emporte sur toute autre source : `mm` envoie son échantillonnage à chaque requête et une valeur de la requête remplace celle du profil, donc sans cette copie les valeurs du profil ne s'appliqueraient jamais | |
| 20 | +| `mlxserve` | `/models`, puis `/api/show` | la liste des modèles, la famille, la fenêtre (celle servie quand le modèle est chargé), le template de chat, et l'échantillonnage propre au modèle (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`) | | |
| 20 | 21 | | `dmr` | `/models` | la liste des modèles seulement | |
| 21 | 22 | | `openai`, `openai-responses` | `/models` (avec la clé) | la liste des modèles seulement | |
| 22 | 23 | |
| @@ -17,6 +17,7 @@ Le serveur connaît le modèle exact qui est chargé : c'est la source la plus p | |||
| 17 | | `llmman`, `ollama` | `/api/tags`, puis `/api/show` | la liste des modèles, la famille annoncée par le serveur (`details.family`), la fenêtre de contexte native, l'échantillonnage écrit dans le GGUF (`temperature`, `top_p`, `top_k`, `min_p`), le template de chat | | 17 | | `llmman`, `ollama` | `/api/tags`, puis `/api/show` | la liste des modèles, la famille annoncée par le serveur (`details.family`), la fenêtre de contexte native, l'échantillonnage écrit dans le GGUF (`temperature`, `top_p`, `top_k`, `min_p`), le template de chat | |
| 18 | | `llamacpp` | `/props` | la fenêtre et le template de chat | | 18 | | `llamacpp` | `/props` | la fenêtre et le template de chat | |
| 19 | | `kronk` | `/models`, puis `/v1/kronk/models/<id>` | la liste des modèles, l'architecture, la fenêtre avec laquelle le modèle est configuré (celle d'entraînement à défaut), l'échantillonnage écrit dans le GGUF, le template de chat ; pour un profil, son propre échantillonnage, qui l'emporte sur toute autre source : `mm` envoie son échantillonnage à chaque requête et une valeur de la requête remplace celle du profil, donc sans cette copie les valeurs du profil ne s'appliqueraient jamais | | 19 | | `kronk` | `/models`, puis `/v1/kronk/models/<id>` | la liste des modèles, l'architecture, la fenêtre avec laquelle le modèle est configuré (celle d'entraînement à défaut), l'échantillonnage écrit dans le GGUF, le template de chat ; pour un profil, son propre échantillonnage, qui l'emporte sur toute autre source : `mm` envoie son échantillonnage à chaque requête et une valeur de la requête remplace celle du profil, donc sans cette copie les valeurs du profil ne s'appliqueraient jamais | |
| 20 | +| `mlxserve` | `/models`, puis `/api/show` | la liste des modèles, la famille, la fenêtre (celle servie quand le modèle est chargé), le template de chat, et l'échantillonnage propre au modèle (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`) | | ||
| 20 | | `dmr` | `/models` | la liste des modèles seulement | | 21 | | `dmr` | `/models` | la liste des modèles seulement | |
| 21 | | `openai`, `openai-responses` | `/models` (avec la clé) | la liste des modèles seulement | | 22 | | `openai`, `openai-responses` | `/models` (avec la clé) | la liste des modèles seulement | |
| 22 | 23 | ||
modified
docs/fr/explanation/providers.md +4 -2 | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | ## De quoi s'agit-il ? |
| 4 | 4 | |
| 5 | -`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Cinq serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama et Kronk, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama` et `kronk`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé. | |
| 5 | +`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Six serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama, Kronk et MLX-Serve, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` et `mlxserve`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé. | |
| 6 | 6 | |
| 7 | 7 | ## Pourquoi c'est conçu ainsi |
| 8 | 8 | |
| @@ -22,6 +22,8 @@ | ||
| 22 | 22 | |
| 23 | 23 | **Kronk est une cinquième entrée, avec ses propres routes à côté de celles d'OpenAI.** [Kronk](https://www.kronkai.com) (`kronk server start`, port 11435, ticket 75) est un serveur Go qui embarque llama.cpp directement, sans processus `llama-server`. Mesuré sur Kronk 1.33.2, il se comporte comme llama.cpp là où cela compte pour `mm` : le raisonnement arrive dans `reasoning_content`, et `chat_template_kwargs` le coupe, alors que `reasoning_effort: "none"` est ignoré. Comme Ollama, il n'envoie pas d'avancement de lecture du prompt. La fenêtre, le téléchargement et le déchargement ont leurs propres routes sous `/v1/kronk/…`. `GET /v1/kronk/models/<id>` donne la fenêtre avec laquelle le modèle est configuré, chargé ou non : elle est donc connue dès le démarrage. L'id contient un `/` (`provider/modelID`), il voyage donc échappé : un `/` brut coupe le chemin. Le téléchargement, `POST /v1/kronk/models/pull`, répond 200 même quand il échoue : seul le dernier enregistrement du flux (`"downloaded": true`, ou la raison) dit comment il s'est terminé. Un modèle installé se charge à la première requête ; un modèle absent donne un 404, d'où l'avertissement `kronk model pull` de la sonde. Kronk n'écoute que sur la boucle locale : le repli depuis une sandbox ne marche qu'une fois Kronk lancé sur l'hôte avec `--api-host 0.0.0.0:11435`. Kronk liste aussi des profils de configuration (`provider/modelID/PROFIL`, les mêmes poids avec leurs propres réglages dans `model_config.yaml`) ; `mm` les traite comme des modèles, et la sonde lit la fenêtre propre au profil. L'échantillonnage d'un profil ne fait que compléter ce que la requête ne donne pas : le `sampling` de `mm` l'emporte, mesuré avec `temperature` et `max_tokens`. |
| 24 | 24 | |
| 25 | +**MLX-Serve est une sixième entrée, et la première dont le silence est le piège.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) fait tourner des modèles MLX sur Apple Silicon et parle les API d'OpenAI, d'Anthropic et d'Ollama sur un seul port ; `mm` utilise le côté OpenAI, et le `/api/pull` d'Ollama pour `autoPull`. Mesuré sur mlx-serve 26.11.3 : le raisonnement arrive dans `reasoning_content` et s'active dès que `enable_thinking` **ou** `reasoning_effort` le demande ; un résumé est donc envoyé avec les deux coupés (une troisième façon de couper le raisonnement, à côté du template et de l'effort). Pas de progression du prompt. `GET /v1/models` liste tous les modèles téléchargés avec `loaded` et `context_length` : chargé, c'est la fenêtre servie (elle est passée de 101376 à 73728 entre deux chargements, avec moins de mémoire libre) ; non chargé, la longueur d'entraînement — le probe ne s'y fie donc que pour un modèle chargé. Un modèle que le serveur n'a pas reçoit quand même une réponse, HTTP 200, de son modèle par défaut : aucun 404 ne le dira, l'avertissement du démarrage est le seul endroit où cela se voit. Enfin, pendant qu'il lit un long prompt, il envoie des commentaires SSE (`: keepalive`) ; openai-go transforme la ligne vide qui suit en événement vide et échoue dessus (`unexpected end of JSON input`). `mm` retire désormais les blocs faits uniquement de commentaires de chaque flux avant qu'openai-go ne les voie. | |
| 26 | + | |
| 25 | 27 | **Les erreurs sont réécrites dans les mots du serveur.** Une pile de messages imbriqués est du bruit ; « tool calls need llama-server started with --jinja » est tout le diagnostic. Le fournisseur reconnaît les refus de connexion, l'option `--jinja` manquante, les 401/403, les 404 avec une indication de pull ou d'alias, les 429 et les 5xx. Les erreurs inconnues reviennent inchangées : un message brut vaut mieux qu'une mauvaise piste. |
| 26 | 28 | |
| 27 | 29 | **Un flux que le serveur interrompt est relancé, et ses mots sont gardés.** llama.cpp signale un échec au milieu d'une réponse diffusée par un événement SSE `error:` (le statut 200 est déjà parti). openai-go ne lit que les lignes `data:` : le message disparaissait derrière `unexpected end of JSON input`. Le tap qui lit déjà le flux pour le raisonnement récupère aussi ces événements, et l'appel au modèle qui a échoué est relancé une fois — cet appel seulement : les outils déjà exécutés dans le tour ne sont pas rejoués, et le texte déjà diffusé par la tentative interrompue n'est pas retiré. S'il échoue encore, l'erreur donne le message du serveur (`the model server reported an error while generating: Failed to parse input at pos …`), ou indique que la connexion a été coupée. Dans les deux cas l'historique est conservé : demander de continuer reprend le travail. |
| @@ -40,5 +42,5 @@ | ||
| 40 | 42 | |
| 41 | 43 | - Les deux fichiers de configuration qui paramètrent chaque fournisseur sont listés dans la [référence de la configuration](../reference/configuration.md). |
| 42 | 44 | - La fenêtre apprise par la sonde est ce contre quoi la [compression du contexte](context-compression.md) mesure. |
| 43 | -- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) et [comment faire tourner sur Kronk](../how-to/run-with-kronk.md). | |
| 45 | +- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) [comment faire tourner sur Kronk](../how-to/run-with-kronk.md) et [comment faire tourner sur MLX-Serve](../how-to/run-with-mlx-serve.md). | |
| 44 | 46 | - Vérifier l'ordre des outils et mesurer le gain de cache sur votre propre serveur : [vérifier que les outils partent dans un ordre stable](../how-to/verify-tool-order.md). |
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | ## De quoi s'agit-il ? | 3 | ## De quoi s'agit-il ? |
| 4 | 4 | ||
| 5 | -`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Cinq serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama et Kronk, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama` et `kronk`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé. | 5 | +`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Six serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama, Kronk et MLX-Serve, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` et `mlxserve`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé. |
| 6 | 6 | ||
| 7 | ## Pourquoi c'est conçu ainsi | 7 | ## Pourquoi c'est conçu ainsi |
| 8 | 8 | ||
| @@ -22,6 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | **Kronk est une cinquième entrée, avec ses propres routes à côté de celles d'OpenAI.** [Kronk](https://www.kronkai.com) (`kronk server start`, port 11435, ticket 75) est un serveur Go qui embarque llama.cpp directement, sans processus `llama-server`. Mesuré sur Kronk 1.33.2, il se comporte comme llama.cpp là où cela compte pour `mm` : le raisonnement arrive dans `reasoning_content`, et `chat_template_kwargs` le coupe, alors que `reasoning_effort: "none"` est ignoré. Comme Ollama, il n'envoie pas d'avancement de lecture du prompt. La fenêtre, le téléchargement et le déchargement ont leurs propres routes sous `/v1/kronk/…`. `GET /v1/kronk/models/<id>` donne la fenêtre avec laquelle le modèle est configuré, chargé ou non : elle est donc connue dès le démarrage. L'id contient un `/` (`provider/modelID`), il voyage donc échappé : un `/` brut coupe le chemin. Le téléchargement, `POST /v1/kronk/models/pull`, répond 200 même quand il échoue : seul le dernier enregistrement du flux (`"downloaded": true`, ou la raison) dit comment il s'est terminé. Un modèle installé se charge à la première requête ; un modèle absent donne un 404, d'où l'avertissement `kronk model pull` de la sonde. Kronk n'écoute que sur la boucle locale : le repli depuis une sandbox ne marche qu'une fois Kronk lancé sur l'hôte avec `--api-host 0.0.0.0:11435`. Kronk liste aussi des profils de configuration (`provider/modelID/PROFIL`, les mêmes poids avec leurs propres réglages dans `model_config.yaml`) ; `mm` les traite comme des modèles, et la sonde lit la fenêtre propre au profil. L'échantillonnage d'un profil ne fait que compléter ce que la requête ne donne pas : le `sampling` de `mm` l'emporte, mesuré avec `temperature` et `max_tokens`. | 23 | **Kronk est une cinquième entrée, avec ses propres routes à côté de celles d'OpenAI.** [Kronk](https://www.kronkai.com) (`kronk server start`, port 11435, ticket 75) est un serveur Go qui embarque llama.cpp directement, sans processus `llama-server`. Mesuré sur Kronk 1.33.2, il se comporte comme llama.cpp là où cela compte pour `mm` : le raisonnement arrive dans `reasoning_content`, et `chat_template_kwargs` le coupe, alors que `reasoning_effort: "none"` est ignoré. Comme Ollama, il n'envoie pas d'avancement de lecture du prompt. La fenêtre, le téléchargement et le déchargement ont leurs propres routes sous `/v1/kronk/…`. `GET /v1/kronk/models/<id>` donne la fenêtre avec laquelle le modèle est configuré, chargé ou non : elle est donc connue dès le démarrage. L'id contient un `/` (`provider/modelID`), il voyage donc échappé : un `/` brut coupe le chemin. Le téléchargement, `POST /v1/kronk/models/pull`, répond 200 même quand il échoue : seul le dernier enregistrement du flux (`"downloaded": true`, ou la raison) dit comment il s'est terminé. Un modèle installé se charge à la première requête ; un modèle absent donne un 404, d'où l'avertissement `kronk model pull` de la sonde. Kronk n'écoute que sur la boucle locale : le repli depuis une sandbox ne marche qu'une fois Kronk lancé sur l'hôte avec `--api-host 0.0.0.0:11435`. Kronk liste aussi des profils de configuration (`provider/modelID/PROFIL`, les mêmes poids avec leurs propres réglages dans `model_config.yaml`) ; `mm` les traite comme des modèles, et la sonde lit la fenêtre propre au profil. L'échantillonnage d'un profil ne fait que compléter ce que la requête ne donne pas : le `sampling` de `mm` l'emporte, mesuré avec `temperature` et `max_tokens`. |
| 24 | 24 | ||
| 25 | +**MLX-Serve est une sixième entrée, et la première dont le silence est le piège.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) fait tourner des modèles MLX sur Apple Silicon et parle les API d'OpenAI, d'Anthropic et d'Ollama sur un seul port ; `mm` utilise le côté OpenAI, et le `/api/pull` d'Ollama pour `autoPull`. Mesuré sur mlx-serve 26.11.3 : le raisonnement arrive dans `reasoning_content` et s'active dès que `enable_thinking` **ou** `reasoning_effort` le demande ; un résumé est donc envoyé avec les deux coupés (une troisième façon de couper le raisonnement, à côté du template et de l'effort). Pas de progression du prompt. `GET /v1/models` liste tous les modèles téléchargés avec `loaded` et `context_length` : chargé, c'est la fenêtre servie (elle est passée de 101376 à 73728 entre deux chargements, avec moins de mémoire libre) ; non chargé, la longueur d'entraînement — le probe ne s'y fie donc que pour un modèle chargé. Un modèle que le serveur n'a pas reçoit quand même une réponse, HTTP 200, de son modèle par défaut : aucun 404 ne le dira, l'avertissement du démarrage est le seul endroit où cela se voit. Enfin, pendant qu'il lit un long prompt, il envoie des commentaires SSE (`: keepalive`) ; openai-go transforme la ligne vide qui suit en événement vide et échoue dessus (`unexpected end of JSON input`). `mm` retire désormais les blocs faits uniquement de commentaires de chaque flux avant qu'openai-go ne les voie. | ||
| 26 | + | ||
| 25 | **Les erreurs sont réécrites dans les mots du serveur.** Une pile de messages imbriqués est du bruit ; « tool calls need llama-server started with --jinja » est tout le diagnostic. Le fournisseur reconnaît les refus de connexion, l'option `--jinja` manquante, les 401/403, les 404 avec une indication de pull ou d'alias, les 429 et les 5xx. Les erreurs inconnues reviennent inchangées : un message brut vaut mieux qu'une mauvaise piste. | 27 | **Les erreurs sont réécrites dans les mots du serveur.** Une pile de messages imbriqués est du bruit ; « tool calls need llama-server started with --jinja » est tout le diagnostic. Le fournisseur reconnaît les refus de connexion, l'option `--jinja` manquante, les 401/403, les 404 avec une indication de pull ou d'alias, les 429 et les 5xx. Les erreurs inconnues reviennent inchangées : un message brut vaut mieux qu'une mauvaise piste. |
| 26 | 28 | ||
| 27 | **Un flux que le serveur interrompt est relancé, et ses mots sont gardés.** llama.cpp signale un échec au milieu d'une réponse diffusée par un événement SSE `error:` (le statut 200 est déjà parti). openai-go ne lit que les lignes `data:` : le message disparaissait derrière `unexpected end of JSON input`. Le tap qui lit déjà le flux pour le raisonnement récupère aussi ces événements, et l'appel au modèle qui a échoué est relancé une fois — cet appel seulement : les outils déjà exécutés dans le tour ne sont pas rejoués, et le texte déjà diffusé par la tentative interrompue n'est pas retiré. S'il échoue encore, l'erreur donne le message du serveur (`the model server reported an error while generating: Failed to parse input at pos …`), ou indique que la connexion a été coupée. Dans les deux cas l'historique est conservé : demander de continuer reprend le travail. | 29 | **Un flux que le serveur interrompt est relancé, et ses mots sont gardés.** llama.cpp signale un échec au milieu d'une réponse diffusée par un événement SSE `error:` (le statut 200 est déjà parti). openai-go ne lit que les lignes `data:` : le message disparaissait derrière `unexpected end of JSON input`. Le tap qui lit déjà le flux pour le raisonnement récupère aussi ces événements, et l'appel au modèle qui a échoué est relancé une fois — cet appel seulement : les outils déjà exécutés dans le tour ne sont pas rejoués, et le texte déjà diffusé par la tentative interrompue n'est pas retiré. S'il échoue encore, l'erreur donne le message du serveur (`the model server reported an error while generating: Failed to parse input at pos …`), ou indique que la connexion a été coupée. Dans les deux cas l'historique est conservé : demander de continuer reprend le travail. |
| @@ -40,5 +42,5 @@ | |||
| 40 | 42 | ||
| 41 | - Les deux fichiers de configuration qui paramètrent chaque fournisseur sont listés dans la [référence de la configuration](../reference/configuration.md). | 43 | - Les deux fichiers de configuration qui paramètrent chaque fournisseur sont listés dans la [référence de la configuration](../reference/configuration.md). |
| 42 | - La fenêtre apprise par la sonde est ce contre quoi la [compression du contexte](context-compression.md) mesure. | 44 | - La fenêtre apprise par la sonde est ce contre quoi la [compression du contexte](context-compression.md) mesure. |
| 43 | -- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) et [comment faire tourner sur Kronk](../how-to/run-with-kronk.md). | 45 | +- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) [comment faire tourner sur Kronk](../how-to/run-with-kronk.md) et [comment faire tourner sur MLX-Serve](../how-to/run-with-mlx-serve.md). |
| 44 | - Vérifier l'ordre des outils et mesurer le gain de cache sur votre propre serveur : [vérifier que les outils partent dans un ordre stable](../how-to/verify-tool-order.md). | 46 | - Vérifier l'ordre des outils et mesurer le gain de cache sur votre propre serveur : [vérifier que les outils partent dans un ordre stable](../how-to/verify-tool-order.md). |
modified
docs/fr/how-to/run-in-a-container.md +1 -1 | @@ -68,7 +68,7 @@ Le projet est monté au même chemin que sur votre machine : les chemins envoyé | ||
| 68 | 68 | |
| 69 | 69 | ## Joindre le modèle |
| 70 | 70 | |
| 71 | -Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux. | |
| 71 | +Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux. | |
| 72 | 72 | |
| 73 | 73 | - **`llamacpp`** : sous Linux, lancez llama-server avec `--host 0.0.0.0`, car par défaut il n'écoute que sur la boucle locale (voir le dernier point). Les fichiers écrits avant la v1.1.0 peuvent contenir `fallback: ""` : retirez cette ligne. |
| 74 | 74 | - **Un fichier d'agent avec un `baseUrl` sur `localhost` ou `127.0.0.1` :** remplacez l'hôte par `host.docker.internal`, ou ajoutez un `fallback`. |
| @@ -68,7 +68,7 @@ Le projet est monté au même chemin que sur votre machine : les chemins envoyé | |||
| 68 | 68 | ||
| 69 | ## Joindre le modèle | 69 | ## Joindre le modèle |
| 70 | 70 | ||
| 71 | -Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux. | 71 | +Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux. |
| 72 | 72 | ||
| 73 | - **`llamacpp`** : sous Linux, lancez llama-server avec `--host 0.0.0.0`, car par défaut il n'écoute que sur la boucle locale (voir le dernier point). Les fichiers écrits avant la v1.1.0 peuvent contenir `fallback: ""` : retirez cette ligne. | 73 | - **`llamacpp`** : sous Linux, lancez llama-server avec `--host 0.0.0.0`, car par défaut il n'écoute que sur la boucle locale (voir le dernier point). Les fichiers écrits avant la v1.1.0 peuvent contenir `fallback: ""` : retirez cette ligne. |
| 74 | - **Un fichier d'agent avec un `baseUrl` sur `localhost` ou `127.0.0.1` :** remplacez l'hôte par `host.docker.internal`, ou ajoutez un `fallback`. | 74 | - **Un fichier d'agent avec un `baseUrl` sur `localhost` ou `127.0.0.1` :** remplacez l'hôte par `host.docker.internal`, ou ajoutez un `fallback`. |
added
docs/fr/how-to/run-with-mlx-serve.md +31 -0 | new file mode 100644 | ||
| @@ -0,0 +1,31 @@ | ||
| 1 | +# Comment faire tourner mini-me sur MLX-Serve | |
| 2 | + | |
| 3 | +Ce guide montre comment brancher `mm` sur [MLX-Serve](https://github.com/ddalcu/mlx-serve), un serveur de modèles local pour Apple Silicon (MLX, sans Python), par son point d'accès compatible OpenAI. Il suppose MLX-Serve installé (l'application, ou `brew install mlx-serve` pour le serveur seul) et que vous savez compiler `mm`. | |
| 4 | + | |
| 5 | +## Étapes | |
| 6 | + | |
| 7 | +1. Téléchargez un modèle et démarrez le serveur. `mlx-serve serve` sert tous les modèles téléchargés sur `0.0.0.0:11234` et charge un modèle à la première requête qui le nomme : | |
| 8 | + | |
| 9 | + ```bash | |
| 10 | + mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | |
| 11 | + mlx-serve serve # ou ouvrez l'application MLX-Serve | |
| 12 | + ``` | |
| 13 | + | |
| 14 | +2. Lancez la configuration de démonstration depuis son répertoire : | |
| 15 | + | |
| 16 | + ```bash | |
| 17 | + cd demos/mlx-gemma-4-e4b | |
| 18 | + ../../mm # finds .mm/agent.yaml | |
| 19 | + ``` | |
| 20 | + | |
| 21 | +3. Vérifiez la bannière. `provider: mlxserve` confirme le fournisseur. Quand le modèle est chargé, `ctx: 101376 (/v1/models)` est la fenêtre avec laquelle MLX-Serve le sert. S'il n'est pas encore chargé, la fenêtre est inconnue au démarrage et `mm` l'apprend avant la question suivante, une fois que la première réponse a chargé le modèle. | |
| 22 | + | |
| 23 | +## Variantes | |
| 24 | + | |
| 25 | +- **Un autre modèle.** Mettez dans `model:` l'identifiant exactement comme `GET /v1/models` le liste (`curl -s localhost:11234/v1/models`). **Regardez les avertissements du démarrage :** un modèle que MLX-Serve n'a pas n'est pas une erreur de son côté — il répond avec son modèle par défaut sous le nom demandé. Le seul signe est l'avertissement `model "…" is not downloaded — mlx-serve pull …`. | |
| 26 | +- **Écrire le fichier avec l'assistant.** `mm init --provider mlxserve` liste les modèles du serveur et lit, pour celui choisi, la famille, la fenêtre, le modèle de chat (`/api/show`) et son propre échantillonnage (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`). `--check` pose une question au modèle. Voir [Comment créer un agent](create-an-agent.md). | |
| 27 | +- **Laisser mm télécharger le modèle.** Avec `autoPull: true`, mm télécharge au démarrage un modèle que le serveur ne liste pas, par `POST /api/pull` (le protocole d'Ollama, que MLX-Serve parle), et affiche la progression. Voir [`autoPull`](../reference/configuration.md). | |
| 28 | +- **Le raisonnement.** MLX-Serve raisonne dès que `chat_template_kwargs.enable_thinking` **ou** `reasoning_effort` le demande. Pour le couper à chaque tour, dites non aux deux dans `sampling` — ou n'écrivez ni l'un ni l'autre : Gemma 4 ne raisonne pas par défaut. Voir [Comment couper le raisonnement d'un modèle](turn-reasoning-off.md). | |
| 29 | +- **Depuis un conteneur ou un Docker Sandbox.** MLX-Serve écoute sur toutes les interfaces par défaut : sans `baseUrl` qui réponde, `mm` se rabat tout seul sur `http://host.docker.internal:11234/v1`. Dans un sandbox, autorisez `localhost:11234` dans la politique réseau. | |
| 30 | +- **Un MLX-Serve protégé.** Un serveur démarré avec `--api-key CLÉ` vérifie la clé pour tout appelant sauf localhost — un conteneur ou un sandbox n'est pas localhost. Exportez-la dans `MLX_SERVE_API_KEY` (le nom que lui donne mm ; ou nommez une autre variable sous `apiKeyEnv`). Une clé refusée donne un avertissement au démarrage qui nomme la variable. | |
| 31 | +- **Libérer la mémoire.** `/unload` et l'outil `unload_model` déchargent le modèle par `POST /v1/unload-model`. Voir [Comment libérer la mémoire d'un modèle](unload-a-model.md). | |
| new file mode 100644 | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | +# Comment faire tourner mini-me sur MLX-Serve | ||
| 2 | + | ||
| 3 | +Ce guide montre comment brancher `mm` sur [MLX-Serve](https://github.com/ddalcu/mlx-serve), un serveur de modèles local pour Apple Silicon (MLX, sans Python), par son point d'accès compatible OpenAI. Il suppose MLX-Serve installé (l'application, ou `brew install mlx-serve` pour le serveur seul) et que vous savez compiler `mm`. | ||
| 4 | + | ||
| 5 | +## Étapes | ||
| 6 | + | ||
| 7 | +1. Téléchargez un modèle et démarrez le serveur. `mlx-serve serve` sert tous les modèles téléchargés sur `0.0.0.0:11234` et charge un modèle à la première requête qui le nomme : | ||
| 8 | + | ||
| 9 | + ```bash | ||
| 10 | + mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit | ||
| 11 | + mlx-serve serve # ou ouvrez l'application MLX-Serve | ||
| 12 | + ``` | ||
| 13 | + | ||
| 14 | +2. Lancez la configuration de démonstration depuis son répertoire : | ||
| 15 | + | ||
| 16 | + ```bash | ||
| 17 | + cd demos/mlx-gemma-4-e4b | ||
| 18 | + ../../mm # finds .mm/agent.yaml | ||
| 19 | + ``` | ||
| 20 | + | ||
| 21 | +3. Vérifiez la bannière. `provider: mlxserve` confirme le fournisseur. Quand le modèle est chargé, `ctx: 101376 (/v1/models)` est la fenêtre avec laquelle MLX-Serve le sert. S'il n'est pas encore chargé, la fenêtre est inconnue au démarrage et `mm` l'apprend avant la question suivante, une fois que la première réponse a chargé le modèle. | ||
| 22 | + | ||
| 23 | +## Variantes | ||
| 24 | + | ||
| 25 | +- **Un autre modèle.** Mettez dans `model:` l'identifiant exactement comme `GET /v1/models` le liste (`curl -s localhost:11234/v1/models`). **Regardez les avertissements du démarrage :** un modèle que MLX-Serve n'a pas n'est pas une erreur de son côté — il répond avec son modèle par défaut sous le nom demandé. Le seul signe est l'avertissement `model "…" is not downloaded — mlx-serve pull …`. | ||
| 26 | +- **Écrire le fichier avec l'assistant.** `mm init --provider mlxserve` liste les modèles du serveur et lit, pour celui choisi, la famille, la fenêtre, le modèle de chat (`/api/show`) et son propre échantillonnage (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`). `--check` pose une question au modèle. Voir [Comment créer un agent](create-an-agent.md). | ||
| 27 | +- **Laisser mm télécharger le modèle.** Avec `autoPull: true`, mm télécharge au démarrage un modèle que le serveur ne liste pas, par `POST /api/pull` (le protocole d'Ollama, que MLX-Serve parle), et affiche la progression. Voir [`autoPull`](../reference/configuration.md). | ||
| 28 | +- **Le raisonnement.** MLX-Serve raisonne dès que `chat_template_kwargs.enable_thinking` **ou** `reasoning_effort` le demande. Pour le couper à chaque tour, dites non aux deux dans `sampling` — ou n'écrivez ni l'un ni l'autre : Gemma 4 ne raisonne pas par défaut. Voir [Comment couper le raisonnement d'un modèle](turn-reasoning-off.md). | ||
| 29 | +- **Depuis un conteneur ou un Docker Sandbox.** MLX-Serve écoute sur toutes les interfaces par défaut : sans `baseUrl` qui réponde, `mm` se rabat tout seul sur `http://host.docker.internal:11234/v1`. Dans un sandbox, autorisez `localhost:11234` dans la politique réseau. | ||
| 30 | +- **Un MLX-Serve protégé.** Un serveur démarré avec `--api-key CLÉ` vérifie la clé pour tout appelant sauf localhost — un conteneur ou un sandbox n'est pas localhost. Exportez-la dans `MLX_SERVE_API_KEY` (le nom que lui donne mm ; ou nommez une autre variable sous `apiKeyEnv`). Une clé refusée donne un avertissement au démarrage qui nomme la variable. | ||
| 31 | +- **Libérer la mémoire.** `/unload` et l'outil `unload_model` déchargent le modèle par `POST /v1/unload-model`. Voir [Comment libérer la mémoire d'un modèle](unload-a-model.md). | ||
modified
docs/fr/how-to/turn-reasoning-off.md +12 -1 | @@ -27,6 +27,17 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r | ||
| 27 | 27 | reasoning_effort: none |
| 28 | 28 | ``` |
| 29 | 29 | |
| 30 | + Pour `mlxserve`, les deux — MLX-Serve raisonne dès que l'un des deux le demande (mesuré sur mlx-serve 26.11.3) : | |
| 31 | + | |
| 32 | + ```yaml | |
| 33 | + sampling: | |
| 34 | + temperature: 0.0 | |
| 35 | + max_tokens: 4096 | |
| 36 | + reasoning_effort: none | |
| 37 | + chat_template_kwargs: | |
| 38 | + enable_thinking: false | |
| 39 | + ``` | |
| 40 | + | |
| 30 | 41 | Les clés que vous écrivez s'ajoutent à celles par défaut (`temperature`, `top_p`, `max_tokens`) : seul l'interrupteur est à ajouter. |
| 31 | 42 | |
| 32 | 43 | 3. Posez une question et comparez. Raisonnement actif, le mode ligne affiche un bloc `💭` grisé avant la réponse `🤖` ; coupé, la réponse arrive directement : |
| @@ -61,7 +72,7 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r | ||
| 61 | 72 | - Avec `ollama`, `reasoning_effort` se place au premier niveau de `sampling`, pas sous `chat_template_kwargs` ; seule la valeur `none` y a été mesurée. |
| 62 | 73 | - Les résumés de compaction ne le suivent pas — voir ci-dessous. |
| 63 | 74 | - **Le couper pour une seule exécution.** Gardez deux fichiers de configuration, ou démarrez le serveur lui-même sans raisonnement (pour llama-server, voir son option `--reasoning-budget`). |
| 64 | -- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman` et `kronk`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. | |
| 75 | +- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman` et `kronk`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. Avec `mlxserve`, il fait les deux. | |
| 65 | 76 | |
| 66 | 77 | ## Voir aussi |
| 67 | 78 | |
| @@ -27,6 +27,17 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r | |||
| 27 | reasoning_effort: none | 27 | reasoning_effort: none |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | + Pour `mlxserve`, les deux — MLX-Serve raisonne dès que l'un des deux le demande (mesuré sur mlx-serve 26.11.3) : | ||
| 31 | + | ||
| 32 | + ```yaml | ||
| 33 | + sampling: | ||
| 34 | + temperature: 0.0 | ||
| 35 | + max_tokens: 4096 | ||
| 36 | + reasoning_effort: none | ||
| 37 | + chat_template_kwargs: | ||
| 38 | + enable_thinking: false | ||
| 39 | + ``` | ||
| 40 | + | ||
| 30 | Les clés que vous écrivez s'ajoutent à celles par défaut (`temperature`, `top_p`, `max_tokens`) : seul l'interrupteur est à ajouter. | 41 | Les clés que vous écrivez s'ajoutent à celles par défaut (`temperature`, `top_p`, `max_tokens`) : seul l'interrupteur est à ajouter. |
| 31 | 42 | ||
| 32 | 3. Posez une question et comparez. Raisonnement actif, le mode ligne affiche un bloc `💭` grisé avant la réponse `🤖` ; coupé, la réponse arrive directement : | 43 | 3. Posez une question et comparez. Raisonnement actif, le mode ligne affiche un bloc `💭` grisé avant la réponse `🤖` ; coupé, la réponse arrive directement : |
| @@ -61,7 +72,7 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r | |||
| 61 | - Avec `ollama`, `reasoning_effort` se place au premier niveau de `sampling`, pas sous `chat_template_kwargs` ; seule la valeur `none` y a été mesurée. | 72 | - Avec `ollama`, `reasoning_effort` se place au premier niveau de `sampling`, pas sous `chat_template_kwargs` ; seule la valeur `none` y a été mesurée. |
| 62 | - Les résumés de compaction ne le suivent pas — voir ci-dessous. | 73 | - Les résumés de compaction ne le suivent pas — voir ci-dessous. |
| 63 | - **Le couper pour une seule exécution.** Gardez deux fichiers de configuration, ou démarrez le serveur lui-même sans raisonnement (pour llama-server, voir son option `--reasoning-budget`). | 74 | - **Le couper pour une seule exécution.** Gardez deux fichiers de configuration, ou démarrez le serveur lui-même sans raisonnement (pour llama-server, voir son option `--reasoning-budget`). |
| 64 | -- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman` et `kronk`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. | 75 | +- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman` et `kronk`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. Avec `mlxserve`, il fait les deux. |
| 65 | 76 | ||
| 66 | ## Voir aussi | 77 | ## Voir aussi |
| 67 | 78 | ||
modified
docs/fr/reference/cli.md +2 -2 | @@ -87,7 +87,7 @@ La règle dépend de l'emplacement du fichier, pas de la façon dont il a été | ||
| 87 | 87 | | `MM_BIN` | Posée par `mm` dans son propre environnement, dont héritent tous les processus qu'il lance — les commandes de son outil `bash`, ses hooks : le chemin du binaire `mm` en cours. | |
| 88 | 88 | | `MM_CONFIG` | Posée par `mm` dans son propre environnement, comme `MM_BIN`, quand un fichier de configuration a été lu : le chemin absolu de son fichier de configuration. Lue par `--ask` / `--ask-with-context` quand ni `-config` ni chemin positionnel ne sont donnés. | |
| 89 | 89 | | `MM_ASK_DEPTH` | Nombre de niveaux de `/ask` au-dessus de cet agent (absente = 0). Posée par `/ask` ; à 2, `/ask` est refusée. | |
| 90 | -| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`. | | |
| 90 | +| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`, `MLX_SERVE_API_KEY` pour `mlxserve`. | | |
| 91 | 91 | |
| 92 | 92 | ## Sortie de démarrage |
| 93 | 93 | |
| @@ -247,7 +247,7 @@ Un fichier d'agent hors du workspace ne donne qu'un avertissement : voir [quand | ||
| 247 | 247 | | Option | Question quand elle est absente | Défaut | |
| 248 | 248 | |--------|---------------------------------|--------| |
| 249 | 249 | | `--project yes\|no` | Tout ranger dans un dossier `.mm` ? — posée en premier. `yes` : le fichier est `.mm/agent.yaml` (le dossier est créé), ses chemins sont écrits depuis la racine du projet (`skillsDir: .mm/skills`), et `mm` / `mm tui` lancés là le trouvent sans argument | `no` | |
| 250 | -| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) | | |
| 250 | +| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) | | |
| 251 | 251 | | `--base-url` | `openai` et `openai-responses` seulement : Endpoint — l'adresse compatible OpenAI du service (OpenAI, Cerebras, Hugging Face…) ; pour les autres fournisseurs, pas posée | `https://api.openai.com/v1` pour `openai` et `openai-responses` ; sinon `AGENT_BASE_URL` s'il est défini, sinon la première des adresses locales du fournisseur dont la liste de modèles répond — son adresse par défaut, puis la même avec `127.0.0.1` quand elle nomme `localhost`, puis pour `llamacpp` l'ancien port de llama-server, `http://127.0.0.1:8080/v1` — et son adresse de secours pour conteneur (`host.docker.internal`) seulement quand aucune ne répond. La question du modèle nomme l'adresse d'où vient sa liste (`Model? (listed from …)`). Écrite comme `baseUrl` sauf si c'est la valeur par défaut | |
| 252 | 252 | | `--api-key-env` | `openai` et `openai-responses` seulement : variable d'environnement qui contient la clé d'API | `OPENAI_API_KEY`. Écrite comme `apiKeyEnv` sauf si c'est la valeur par défaut | |
| 253 | 253 | | `--model` | Modèle : la liste des modèles du serveur (`/api/tags` pour llmman et Ollama, `/models` pour les autres ; 5 s pour un serveur local, 20 s pour `openai`), ou un nom à taper quand il n'y a pas de liste — la question dit pourquoi (`<VARIABLE> is not set: no list`, ou l'erreur du serveur). Pour `openai`, la liste est demandée avec la clé lue dans la variable nommée plus haut, et pas demandée du tout quand cette variable est vide | le premier de la liste | |
| @@ -87,7 +87,7 @@ La règle dépend de l'emplacement du fichier, pas de la façon dont il a été | |||
| 87 | | `MM_BIN` | Posée par `mm` dans son propre environnement, dont héritent tous les processus qu'il lance — les commandes de son outil `bash`, ses hooks : le chemin du binaire `mm` en cours. | | 87 | | `MM_BIN` | Posée par `mm` dans son propre environnement, dont héritent tous les processus qu'il lance — les commandes de son outil `bash`, ses hooks : le chemin du binaire `mm` en cours. | |
| 88 | | `MM_CONFIG` | Posée par `mm` dans son propre environnement, comme `MM_BIN`, quand un fichier de configuration a été lu : le chemin absolu de son fichier de configuration. Lue par `--ask` / `--ask-with-context` quand ni `-config` ni chemin positionnel ne sont donnés. | | 88 | | `MM_CONFIG` | Posée par `mm` dans son propre environnement, comme `MM_BIN`, quand un fichier de configuration a été lu : le chemin absolu de son fichier de configuration. Lue par `--ask` / `--ask-with-context` quand ni `-config` ni chemin positionnel ne sont donnés. | |
| 89 | | `MM_ASK_DEPTH` | Nombre de niveaux de `/ask` au-dessus de cet agent (absente = 0). Posée par `/ask` ; à 2, `/ask` est refusée. | | 89 | | `MM_ASK_DEPTH` | Nombre de niveaux de `/ask` au-dessus de cet agent (absente = 0). Posée par `/ask` ; à 2, `/ask` est refusée. | |
| 90 | -| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`. | | 90 | +| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`, `MLX_SERVE_API_KEY` pour `mlxserve`. | |
| 91 | 91 | ||
| 92 | ## Sortie de démarrage | 92 | ## Sortie de démarrage |
| 93 | 93 | ||
| @@ -247,7 +247,7 @@ Un fichier d'agent hors du workspace ne donne qu'un avertissement : voir [quand | |||
| 247 | | Option | Question quand elle est absente | Défaut | | 247 | | Option | Question quand elle est absente | Défaut | |
| 248 | |--------|---------------------------------|--------| | 248 | |--------|---------------------------------|--------| |
| 249 | | `--project yes\|no` | Tout ranger dans un dossier `.mm` ? — posée en premier. `yes` : le fichier est `.mm/agent.yaml` (le dossier est créé), ses chemins sont écrits depuis la racine du projet (`skillsDir: .mm/skills`), et `mm` / `mm tui` lancés là le trouvent sans argument | `no` | | 249 | | `--project yes\|no` | Tout ranger dans un dossier `.mm` ? — posée en premier. `yes` : le fichier est `.mm/agent.yaml` (le dossier est créé), ses chemins sont écrits depuis la racine du projet (`skillsDir: .mm/skills`), et `mm` / `mm tui` lancés là le trouvent sans argument | `no` | |
| 250 | -| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) | | 250 | +| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) | |
| 251 | | `--base-url` | `openai` et `openai-responses` seulement : Endpoint — l'adresse compatible OpenAI du service (OpenAI, Cerebras, Hugging Face…) ; pour les autres fournisseurs, pas posée | `https://api.openai.com/v1` pour `openai` et `openai-responses` ; sinon `AGENT_BASE_URL` s'il est défini, sinon la première des adresses locales du fournisseur dont la liste de modèles répond — son adresse par défaut, puis la même avec `127.0.0.1` quand elle nomme `localhost`, puis pour `llamacpp` l'ancien port de llama-server, `http://127.0.0.1:8080/v1` — et son adresse de secours pour conteneur (`host.docker.internal`) seulement quand aucune ne répond. La question du modèle nomme l'adresse d'où vient sa liste (`Model? (listed from …)`). Écrite comme `baseUrl` sauf si c'est la valeur par défaut | | 251 | | `--base-url` | `openai` et `openai-responses` seulement : Endpoint — l'adresse compatible OpenAI du service (OpenAI, Cerebras, Hugging Face…) ; pour les autres fournisseurs, pas posée | `https://api.openai.com/v1` pour `openai` et `openai-responses` ; sinon `AGENT_BASE_URL` s'il est défini, sinon la première des adresses locales du fournisseur dont la liste de modèles répond — son adresse par défaut, puis la même avec `127.0.0.1` quand elle nomme `localhost`, puis pour `llamacpp` l'ancien port de llama-server, `http://127.0.0.1:8080/v1` — et son adresse de secours pour conteneur (`host.docker.internal`) seulement quand aucune ne répond. La question du modèle nomme l'adresse d'où vient sa liste (`Model? (listed from …)`). Écrite comme `baseUrl` sauf si c'est la valeur par défaut | |
| 252 | | `--api-key-env` | `openai` et `openai-responses` seulement : variable d'environnement qui contient la clé d'API | `OPENAI_API_KEY`. Écrite comme `apiKeyEnv` sauf si c'est la valeur par défaut | | 252 | | `--api-key-env` | `openai` et `openai-responses` seulement : variable d'environnement qui contient la clé d'API | `OPENAI_API_KEY`. Écrite comme `apiKeyEnv` sauf si c'est la valeur par défaut | |
| 253 | | `--model` | Modèle : la liste des modèles du serveur (`/api/tags` pour llmman et Ollama, `/models` pour les autres ; 5 s pour un serveur local, 20 s pour `openai`), ou un nom à taper quand il n'y a pas de liste — la question dit pourquoi (`<VARIABLE> is not set: no list`, ou l'erreur du serveur). Pour `openai`, la liste est demandée avec la clé lue dans la variable nommée plus haut, et pas demandée du tout quand cette variable est vide | le premier de la liste | | 253 | | `--model` | Modèle : la liste des modèles du serveur (`/api/tags` pour llmman et Ollama, `/models` pour les autres ; 5 s pour un serveur local, 20 s pour `openai`), ou un nom à taper quand il n'y a pas de liste — la question dit pourquoi (`<VARIABLE> is not set: no list`, ou l'erreur du serveur). Pour `openai`, la liste est demandée avec la clé lue dans la variable nommée plus haut, et pas demandée du tout quand cette variable est vide | le premier de la liste | |
modified
docs/fr/reference/configuration.md +3 -2 | @@ -8,7 +8,7 @@ Où `mm` cherche ce fichier : [Résolution du fichier de configuration](cli.md#r | ||
| 8 | 8 | |
| 9 | 9 | | Clé | Type | Défaut | Description | |
| 10 | 10 | |-----|------|--------|-------------| |
| 11 | -| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. | | |
| 11 | +| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. | | |
| 12 | 12 | | `model` | chaîne | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Identifiant du modèle dans la nomenclature du fournisseur. Surchargé par `AGENT_MODEL`. | |
| 13 | 13 | | `baseUrl` | chaîne | `""` (défaut du fournisseur) | Point d'accès compatible OpenAI essayé en premier. Surchargé par `AGENT_BASE_URL`. | |
| 14 | 14 | | `fallback` | chaîne ou absente | absente (défaut du fournisseur) | Point d'accès utilisé quand `baseUrl` ne répond pas sur `/models` en 2 s. Absente = défaut du fournisseur ; `""` = pas de repli. | |
| @@ -232,6 +232,7 @@ workspace: | ||
| 232 | 232 | | `llmman` | `http://127.0.0.1:17434/v1` | `http://host.docker.internal:17434/v1` | `LLMMAN_API_KEY` | non | |
| 233 | 233 | | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | non | |
| 234 | 234 | | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | non — seuls les modes `authenticated` et `full-protected` de Kronk la vérifient | |
| 235 | +| `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | non — seul un serveur démarré avec `--api-key` la vérifie, et pas pour localhost | | |
| 235 | 236 | | `openai` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — un serveur qui en exige une répond 401, et l'avertissement de démarrage nomme la variable | |
| 236 | 237 | | `openai-responses` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — comme `openai` | |
| 237 | 238 | |
| @@ -506,7 +507,7 @@ Signalées sur stderr sous la forme `[config error: <chemin>: <message>]`, code | ||
| 506 | 507 | | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | un nom commençant par `with-context` | |
| 507 | 508 | | `mmConfigs.<nom>: the path must not be empty` | `<nom>: ""`, ou une forme longue sans `path` | |
| 508 | 509 | | `hooks: unknown event "x" (…)`, `hooks.<événement>[N]: …` | un bloc `hooks:` invalide — voir [les hooks](hooks.md#erreurs-de-validation) | |
| 509 | -| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, ollama, openai, openai-responses)` | Signalée par le moteur, sous la forme `[engine error: …]`. | | |
| 510 | +| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Signalée par le moteur, sous la forme `[engine error: …]`. | | |
| 510 | 511 | |
| 511 | 512 | Un avertissement au démarrage, et non une erreur, est affiché quand `context.enabled` vaut `true`, que la fenêtre est inconnue et que `context.maxMessages` vaut `0`, quand un outil déclaré porte le nom d'un outil MCP (`tools: <nom> skipped — an MCP tool already has that name` ; l'outil n'est pas déclaré), et quand le fichier pose la clé obsolète `permissions` (`permissions: ask is deprecated — use yolo: false instead …`). |
| 512 | 513 | |
| @@ -8,7 +8,7 @@ Où `mm` cherche ce fichier : [Résolution du fichier de configuration](cli.md#r | |||
| 8 | 8 | ||
| 9 | | Clé | Type | Défaut | Description | | 9 | | Clé | Type | Défaut | Description | |
| 10 | |-----|------|--------|-------------| | 10 | |-----|------|--------|-------------| |
| 11 | -| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. | | 11 | +| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. | |
| 12 | | `model` | chaîne | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Identifiant du modèle dans la nomenclature du fournisseur. Surchargé par `AGENT_MODEL`. | | 12 | | `model` | chaîne | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Identifiant du modèle dans la nomenclature du fournisseur. Surchargé par `AGENT_MODEL`. | |
| 13 | | `baseUrl` | chaîne | `""` (défaut du fournisseur) | Point d'accès compatible OpenAI essayé en premier. Surchargé par `AGENT_BASE_URL`. | | 13 | | `baseUrl` | chaîne | `""` (défaut du fournisseur) | Point d'accès compatible OpenAI essayé en premier. Surchargé par `AGENT_BASE_URL`. | |
| 14 | | `fallback` | chaîne ou absente | absente (défaut du fournisseur) | Point d'accès utilisé quand `baseUrl` ne répond pas sur `/models` en 2 s. Absente = défaut du fournisseur ; `""` = pas de repli. | | 14 | | `fallback` | chaîne ou absente | absente (défaut du fournisseur) | Point d'accès utilisé quand `baseUrl` ne répond pas sur `/models` en 2 s. Absente = défaut du fournisseur ; `""` = pas de repli. | |
| @@ -232,6 +232,7 @@ workspace: | |||
| 232 | | `llmman` | `http://127.0.0.1:17434/v1` | `http://host.docker.internal:17434/v1` | `LLMMAN_API_KEY` | non | | 232 | | `llmman` | `http://127.0.0.1:17434/v1` | `http://host.docker.internal:17434/v1` | `LLMMAN_API_KEY` | non | |
| 233 | | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | non | | 233 | | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | non | |
| 234 | | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | non — seuls les modes `authenticated` et `full-protected` de Kronk la vérifient | | 234 | | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | non — seuls les modes `authenticated` et `full-protected` de Kronk la vérifient | |
| 235 | +| `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | non — seul un serveur démarré avec `--api-key` la vérifie, et pas pour localhost | | ||
| 235 | | `openai` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — un serveur qui en exige une répond 401, et l'avertissement de démarrage nomme la variable | | 236 | | `openai` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — un serveur qui en exige une répond 401, et l'avertissement de démarrage nomme la variable | |
| 236 | | `openai-responses` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — comme `openai` | | 237 | | `openai-responses` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — comme `openai` | |
| 237 | 238 | ||
| @@ -506,7 +507,7 @@ Signalées sur stderr sous la forme `[config error: <chemin>: <message>]`, code | |||
| 506 | | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | un nom commençant par `with-context` | | 507 | | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | un nom commençant par `with-context` | |
| 507 | | `mmConfigs.<nom>: the path must not be empty` | `<nom>: ""`, ou une forme longue sans `path` | | 508 | | `mmConfigs.<nom>: the path must not be empty` | `<nom>: ""`, ou une forme longue sans `path` | |
| 508 | | `hooks: unknown event "x" (…)`, `hooks.<événement>[N]: …` | un bloc `hooks:` invalide — voir [les hooks](hooks.md#erreurs-de-validation) | | 509 | | `hooks: unknown event "x" (…)`, `hooks.<événement>[N]: …` | un bloc `hooks:` invalide — voir [les hooks](hooks.md#erreurs-de-validation) | |
| 509 | -| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, ollama, openai, openai-responses)` | Signalée par le moteur, sous la forme `[engine error: …]`. | | 510 | +| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Signalée par le moteur, sous la forme `[engine error: …]`. | |
| 510 | 511 | ||
| 511 | Un avertissement au démarrage, et non une erreur, est affiché quand `context.enabled` vaut `true`, que la fenêtre est inconnue et que `context.maxMessages` vaut `0`, quand un outil déclaré porte le nom d'un outil MCP (`tools: <nom> skipped — an MCP tool already has that name` ; l'outil n'est pas déclaré), et quand le fichier pose la clé obsolète `permissions` (`permissions: ask is deprecated — use yolo: false instead …`). | 512 | Un avertissement au démarrage, et non une erreur, est affiché quand `context.enabled` vaut `true`, que la fenêtre est inconnue et que `context.maxMessages` vaut `0`, quand un outil déclaré porte le nom d'un outil MCP (`tools: <nom> skipped — an MCP tool already has that name` ; l'outil n'est pas déclaré), et quand le fichier pose la clé obsolète `permissions` (`permissions: ask is deprecated — use yolo: false instead …`). |
| 512 | 513 | ||
modified
docs/fr/reference/tools.md +1 -0 | @@ -317,6 +317,7 @@ Déclaré quand `unloadModels` vaut true (le défaut), sauf à côté d'une `str | ||
| 317 | 317 | |--------|--------------| |
| 318 | 318 | | llmman, `ollama` | Cherche d'abord le modèle dans `GET /api/ps` ; quand il est chargé, `POST /api/generate {"model": …, "keep_alive": 0}` et attend `done_reason: "unload"`. Un modèle non chargé n'est jamais demandé : la requête le chargerait d'abord. | |
| 319 | 319 | | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, qui attend `status: "unloaded"`. Le 404 de Kronk pour un modèle non chargé donne `<modèle> was not loaded: nothing to unload`. | |
| 320 | +| `mlxserve` | Cherche d'abord le modèle dans `GET /v1/models` ; s'il est `loaded`, `POST /v1/unload-model {"model": …}` et attend `state: "unloaded"`. MLX-Serve répond « unloaded » aussi pour un modèle non chargé, d'où la recherche préalable. | | |
| 320 | 321 | | `llamacpp` | `POST /models/unload {"model": …}`, qui n'existe qu'en mode router (llama-server lancé sans modèle). Le 404 d'un serveur à modèle unique donne la raison et les alternatives : mode router, `--sleep-idle-seconds N`, arrêt du serveur. | |
| 321 | 322 | | `dmr` | `cannot unload <modèle>: the dmr provider cannot unload a model`. | |
| 322 | 323 | | Résultat | Une ligne : `unloaded <modèle>`, `<modèle> was not loaded: nothing to unload`, ou `cannot unload <modèle>: <raison>` (serveur injoignable, erreur du serveur lui-même, absence de confirmation). | |
| @@ -317,6 +317,7 @@ Déclaré quand `unloadModels` vaut true (le défaut), sauf à côté d'une `str | |||
| 317 | |--------|--------------| | 317 | |--------|--------------| |
| 318 | | llmman, `ollama` | Cherche d'abord le modèle dans `GET /api/ps` ; quand il est chargé, `POST /api/generate {"model": …, "keep_alive": 0}` et attend `done_reason: "unload"`. Un modèle non chargé n'est jamais demandé : la requête le chargerait d'abord. | | 318 | | llmman, `ollama` | Cherche d'abord le modèle dans `GET /api/ps` ; quand il est chargé, `POST /api/generate {"model": …, "keep_alive": 0}` et attend `done_reason: "unload"`. Un modèle non chargé n'est jamais demandé : la requête le chargerait d'abord. | |
| 319 | | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, qui attend `status: "unloaded"`. Le 404 de Kronk pour un modèle non chargé donne `<modèle> was not loaded: nothing to unload`. | | 319 | | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, qui attend `status: "unloaded"`. Le 404 de Kronk pour un modèle non chargé donne `<modèle> was not loaded: nothing to unload`. | |
| 320 | +| `mlxserve` | Cherche d'abord le modèle dans `GET /v1/models` ; s'il est `loaded`, `POST /v1/unload-model {"model": …}` et attend `state: "unloaded"`. MLX-Serve répond « unloaded » aussi pour un modèle non chargé, d'où la recherche préalable. | | ||
| 320 | | `llamacpp` | `POST /models/unload {"model": …}`, qui n'existe qu'en mode router (llama-server lancé sans modèle). Le 404 d'un serveur à modèle unique donne la raison et les alternatives : mode router, `--sleep-idle-seconds N`, arrêt du serveur. | | 321 | | `llamacpp` | `POST /models/unload {"model": …}`, qui n'existe qu'en mode router (llama-server lancé sans modèle). Le 404 d'un serveur à modèle unique donne la raison et les alternatives : mode router, `--sleep-idle-seconds N`, arrêt du serveur. | |
| 321 | | `dmr` | `cannot unload <modèle>: the dmr provider cannot unload a model`. | | 322 | | `dmr` | `cannot unload <modèle>: the dmr provider cannot unload a model`. | |
| 322 | | Résultat | Une ligne : `unloaded <modèle>`, `<modèle> was not loaded: nothing to unload`, ou `cannot unload <modèle>: <raison>` (serveur injoignable, erreur du serveur lui-même, absence de confirmation). | | 323 | | Résultat | Une ligne : `unloaded <modèle>`, `<modèle> was not loaded: nothing to unload`, ou `cannot unload <modèle>: <raison>` (serveur injoignable, erreur du serveur lui-même, absence de confirmation). | |
modified
go.mod +1 -1 | @@ -8,7 +8,7 @@ require ( | ||
| 8 | 8 | github.com/coder/acp-go-sdk v0.13.5 |
| 9 | 9 | github.com/firebase/genkit/go v1.13.1 |
| 10 | 10 | github.com/gdamore/tcell/v2 v2.13.10 |
| 11 | - github.com/openai/openai-go v1.8.2 | |
| 11 | + github.com/openai/openai-go v1.12.0 | |
| 12 | 12 | github.com/sashabaranov/go-openai v1.42.1 |
| 13 | 13 | github.com/tetratelabs/wazero v1.12.0 |
| 14 | 14 | go.lsp.dev/jsonrpc2 v1.0.1 |
| @@ -8,7 +8,7 @@ require ( | |||
| 8 | github.com/coder/acp-go-sdk v0.13.5 | 8 | github.com/coder/acp-go-sdk v0.13.5 |
| 9 | github.com/firebase/genkit/go v1.13.1 | 9 | github.com/firebase/genkit/go v1.13.1 |
| 10 | github.com/gdamore/tcell/v2 v2.13.10 | 10 | github.com/gdamore/tcell/v2 v2.13.10 |
| 11 | - github.com/openai/openai-go v1.8.2 | 11 | + github.com/openai/openai-go v1.12.0 |
| 12 | github.com/sashabaranov/go-openai v1.42.1 | 12 | github.com/sashabaranov/go-openai v1.42.1 |
| 13 | github.com/tetratelabs/wazero v1.12.0 | 13 | github.com/tetratelabs/wazero v1.12.0 |
| 14 | go.lsp.dev/jsonrpc2 v1.0.1 | 14 | go.lsp.dev/jsonrpc2 v1.0.1 |
modified
go.sum +2 -0 | @@ -43,6 +43,8 @@ github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a h1:v2cBA3xWKv2cIOV | ||
| 43 | 43 | github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a/go.mod h1:Y6ghKH+ZijXn5d9E7qGGZBmjitx7iitZdQiIW97EpTU= |
| 44 | 44 | github.com/openai/openai-go v1.8.2 h1:UqSkJ1vCOPUpz9Ka5tS0324EJFEuOvMc+lA/EarJWP8= |
| 45 | 45 | github.com/openai/openai-go v1.8.2/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y= |
| 46 | +github.com/openai/openai-go v1.12.0 h1:NBQCnXzqOTv5wsgNC36PrFEiskGfO5wccfCWDo9S1U0= | |
| 47 | +github.com/openai/openai-go v1.12.0/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y= | |
| 46 | 48 | github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY= |
| 47 | 49 | github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ= |
| 48 | 50 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
| @@ -43,6 +43,8 @@ github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a h1:v2cBA3xWKv2cIOV | |||
| 43 | github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a/go.mod h1:Y6ghKH+ZijXn5d9E7qGGZBmjitx7iitZdQiIW97EpTU= | 43 | github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a/go.mod h1:Y6ghKH+ZijXn5d9E7qGGZBmjitx7iitZdQiIW97EpTU= |
| 44 | github.com/openai/openai-go v1.8.2 h1:UqSkJ1vCOPUpz9Ka5tS0324EJFEuOvMc+lA/EarJWP8= | 44 | github.com/openai/openai-go v1.8.2 h1:UqSkJ1vCOPUpz9Ka5tS0324EJFEuOvMc+lA/EarJWP8= |
| 45 | github.com/openai/openai-go v1.8.2/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y= | 45 | github.com/openai/openai-go v1.8.2/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y= |
| 46 | +github.com/openai/openai-go v1.12.0 h1:NBQCnXzqOTv5wsgNC36PrFEiskGfO5wccfCWDo9S1U0= | ||
| 47 | +github.com/openai/openai-go v1.12.0/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y= | ||
| 46 | github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY= | 48 | github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY= |
| 47 | github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ= | 49 | github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ= |
| 48 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | 50 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
modified
internal/agentinit/decide.go +1 -1 | @@ -7,7 +7,7 @@ import ( | ||
| 7 | 7 | |
| 8 | 8 | // Choices are the wizard's answers. |
| 9 | 9 | type Choices struct { |
| 10 | - Provider string // llamacpp, llmman, ollama, dmr, kronk, openai, openai-responses | |
| 10 | + Provider string // llamacpp, llmman, ollama, dmr, kronk, mlxserve, openai, openai-responses | |
| 11 | 11 | BaseURL string // "" = the provider's default |
| 12 | 12 | // APIKeyEnv names the variable holding the API key of an |
| 13 | 13 | // OpenAI-compatible service (provider openai); "" = OPENAI_API_KEY. |
| @@ -7,7 +7,7 @@ import ( | |||
| 7 | 7 | ||
| 8 | // Choices are the wizard's answers. | 8 | // Choices are the wizard's answers. |
| 9 | type Choices struct { | 9 | type Choices struct { |
| 10 | - Provider string // llamacpp, llmman, ollama, dmr, kronk, openai, openai-responses | 10 | + Provider string // llamacpp, llmman, ollama, dmr, kronk, mlxserve, openai, openai-responses |
| 11 | BaseURL string // "" = the provider's default | 11 | BaseURL string // "" = the provider's default |
| 12 | // APIKeyEnv names the variable holding the API key of an | 12 | // APIKeyEnv names the variable holding the API key of an |
| 13 | // OpenAI-compatible service (provider openai); "" = OPENAI_API_KEY. | 13 | // OpenAI-compatible service (provider openai); "" = OPENAI_API_KEY. |
modified
internal/agentinit/facts.go +41 -1 | @@ -166,7 +166,9 @@ func ListModels(ctx context.Context, provider, base, key string) ([]string, erro | ||
| 166 | 166 | // ModelFacts asks the server about one model. llmman and Ollama answer |
| 167 | 167 | // /api/show (GGUF metadata, chat template); llama-server answers /props |
| 168 | 168 | // (window, chat template); Kronk answers /v1/kronk/models/<id> (GGUF |
| 169 | -// metadata, chat template, served window); Docker Model Runner says nothing | |
| 169 | +// metadata, chat template, served window); MLX-Serve answers Ollama's | |
| 170 | +// /api/show and lists the model's own sampling in /v1/models (mlxFacts); | |
| 171 | +// Docker Model Runner says nothing | |
| 170 | 172 | // more than the model list — Facts.Known is then false and the family table |
| 171 | 173 | // decides. |
| 172 | 174 | func ModelFacts(ctx context.Context, provider, base, model string) Facts { |
| @@ -177,10 +179,48 @@ func ModelFacts(ctx context.Context, provider, base, model string) Facts { | ||
| 177 | 179 | return propsFacts(ctx, base, model) |
| 178 | 180 | case "kronk": |
| 179 | 181 | return kronkFacts(ctx, base, model) |
| 182 | + case "mlxserve": | |
| 183 | + return mlxFacts(ctx, base, model) | |
| 180 | 184 | } |
| 181 | 185 | return Facts{} |
| 182 | 186 | } |
| 183 | 187 | |
| 188 | +// mlxFacts reads MLX-Serve (measured on mlx-serve 26.11.3): /api/show, in | |
| 189 | +// Ollama's shape, gives the family, the chat template and — loaded — the | |
| 190 | +// served window, but no sampling (`parameters` is empty); the model's | |
| 191 | +// generation_config is in /v1/models, `meta.gen_temperature`, `gen_top_p`, | |
| 192 | +// `gen_top_k`. | |
| 193 | +func mlxFacts(ctx context.Context, base, model string) Facts { | |
| 194 | + f := showFacts(ctx, base, model) | |
| 195 | + if !f.Known { | |
| 196 | + return f | |
| 197 | + } | |
| 198 | + var list struct { | |
| 199 | + Data []struct { | |
| 200 | + ID string `json:"id"` | |
| 201 | + Meta struct { | |
| 202 | + Temperature *float64 `json:"gen_temperature"` | |
| 203 | + TopP *float64 `json:"gen_top_p"` | |
| 204 | + TopK *float64 `json:"gen_top_k"` | |
| 205 | + } `json:"meta"` | |
| 206 | + } `json:"data"` | |
| 207 | + } | |
| 208 | + if call(ctx, http.MethodGet, strings.TrimRight(base, "/")+"/models", nil, 10*time.Second, &list) != nil { | |
| 209 | + return f | |
| 210 | + } | |
| 211 | + for _, m := range list.Data { | |
| 212 | + if m.ID != model { | |
| 213 | + continue | |
| 214 | + } | |
| 215 | + for key, v := range map[string]*float64{"temperature": m.Meta.Temperature, "top_p": m.Meta.TopP, "top_k": m.Meta.TopK} { | |
| 216 | + if v != nil { | |
| 217 | + f.Sampling[key] = *v | |
| 218 | + } | |
| 219 | + } | |
| 220 | + } | |
| 221 | + return f | |
| 222 | +} | |
| 223 | + | |
| 184 | 224 | // modelDetail is the line shown beside a model in the wizard's list, "" for |
| 185 | 225 | // most. Kronk lists configuration profiles beside the models |
| 186 | 226 | // (`provider/modelID/PROFILE`, e.g. `…/Qwopus3.5-4B-Coder.Q8_0/AGENT`): the |
| @@ -166,7 +166,9 @@ func ListModels(ctx context.Context, provider, base, key string) ([]string, erro | |||
| 166 | // ModelFacts asks the server about one model. llmman and Ollama answer | 166 | // ModelFacts asks the server about one model. llmman and Ollama answer |
| 167 | // /api/show (GGUF metadata, chat template); llama-server answers /props | 167 | // /api/show (GGUF metadata, chat template); llama-server answers /props |
| 168 | // (window, chat template); Kronk answers /v1/kronk/models/<id> (GGUF | 168 | // (window, chat template); Kronk answers /v1/kronk/models/<id> (GGUF |
| 169 | -// metadata, chat template, served window); Docker Model Runner says nothing | 169 | +// metadata, chat template, served window); MLX-Serve answers Ollama's |
| 170 | +// /api/show and lists the model's own sampling in /v1/models (mlxFacts); | ||
| 171 | +// Docker Model Runner says nothing | ||
| 170 | // more than the model list — Facts.Known is then false and the family table | 172 | // more than the model list — Facts.Known is then false and the family table |
| 171 | // decides. | 173 | // decides. |
| 172 | func ModelFacts(ctx context.Context, provider, base, model string) Facts { | 174 | func ModelFacts(ctx context.Context, provider, base, model string) Facts { |
| @@ -177,10 +179,48 @@ func ModelFacts(ctx context.Context, provider, base, model string) Facts { | |||
| 177 | return propsFacts(ctx, base, model) | 179 | return propsFacts(ctx, base, model) |
| 178 | case "kronk": | 180 | case "kronk": |
| 179 | return kronkFacts(ctx, base, model) | 181 | return kronkFacts(ctx, base, model) |
| 182 | + case "mlxserve": | ||
| 183 | + return mlxFacts(ctx, base, model) | ||
| 180 | } | 184 | } |
| 181 | return Facts{} | 185 | return Facts{} |
| 182 | } | 186 | } |
| 183 | 187 | ||
| 188 | +// mlxFacts reads MLX-Serve (measured on mlx-serve 26.11.3): /api/show, in | ||
| 189 | +// Ollama's shape, gives the family, the chat template and — loaded — the | ||
| 190 | +// served window, but no sampling (`parameters` is empty); the model's | ||
| 191 | +// generation_config is in /v1/models, `meta.gen_temperature`, `gen_top_p`, | ||
| 192 | +// `gen_top_k`. | ||
| 193 | +func mlxFacts(ctx context.Context, base, model string) Facts { | ||
| 194 | + f := showFacts(ctx, base, model) | ||
| 195 | + if !f.Known { | ||
| 196 | + return f | ||
| 197 | + } | ||
| 198 | + var list struct { | ||
| 199 | + Data []struct { | ||
| 200 | + ID string `json:"id"` | ||
| 201 | + Meta struct { | ||
| 202 | + Temperature *float64 `json:"gen_temperature"` | ||
| 203 | + TopP *float64 `json:"gen_top_p"` | ||
| 204 | + TopK *float64 `json:"gen_top_k"` | ||
| 205 | + } `json:"meta"` | ||
| 206 | + } `json:"data"` | ||
| 207 | + } | ||
| 208 | + if call(ctx, http.MethodGet, strings.TrimRight(base, "/")+"/models", nil, 10*time.Second, &list) != nil { | ||
| 209 | + return f | ||
| 210 | + } | ||
| 211 | + for _, m := range list.Data { | ||
| 212 | + if m.ID != model { | ||
| 213 | + continue | ||
| 214 | + } | ||
| 215 | + for key, v := range map[string]*float64{"temperature": m.Meta.Temperature, "top_p": m.Meta.TopP, "top_k": m.Meta.TopK} { | ||
| 216 | + if v != nil { | ||
| 217 | + f.Sampling[key] = *v | ||
| 218 | + } | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + return f | ||
| 222 | +} | ||
| 223 | + | ||
| 184 | // modelDetail is the line shown beside a model in the wizard's list, "" for | 224 | // modelDetail is the line shown beside a model in the wizard's list, "" for |
| 185 | // most. Kronk lists configuration profiles beside the models | 225 | // most. Kronk lists configuration profiles beside the models |
| 186 | // (`provider/modelID/PROFILE`, e.g. `…/Qwopus3.5-4B-Coder.Q8_0/AGENT`): the | 226 | // (`provider/modelID/PROFILE`, e.g. `…/Qwopus3.5-4B-Coder.Q8_0/AGENT`): the |
modified
internal/agentinit/facts_test.go +29 -0 | @@ -212,3 +212,32 @@ func TestPropsFactsRouterMode(t *testing.T) { | ||
| 212 | 212 | t.Errorf("router-only answer gave facts: %+v", f) |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | + | |
| 216 | +// MLX-Serve: /api/show in Ollama's shape (no sampling in `parameters`), the | |
| 217 | +// model's own sampling in /v1/models' `meta.gen_*` (measured on mlx-serve | |
| 218 | +// 26.11.3); the model list is /v1/models, whose ids have no ":latest". | |
| 219 | +func TestMlxServeFacts(t *testing.T) { | |
| 220 | + const id = "lmstudio-community/gemma-4-E4B-it-MLX-8bit" | |
| 221 | + s := fakeServer(t, map[string]any{ | |
| 222 | + "POST /api/show": map[string]any{ | |
| 223 | + "parameters": "", | |
| 224 | + "template": "{%- if enable_thinking is defined and enable_thinking -%}…", | |
| 225 | + "details": map[string]any{"family": "gemma4"}, | |
| 226 | + "model_info": map[string]any{"general.architecture": "gemma4", "gemma4.context_length": 101376}, | |
| 227 | + }, | |
| 228 | + "GET /v1/models": map[string]any{"data": []any{ | |
| 229 | + map[string]any{"id": "other/model", "meta": map[string]any{"gen_temperature": 0.2}}, | |
| 230 | + map[string]any{"id": id, "meta": map[string]any{"gen_temperature": 1, "gen_top_p": 0.95, "gen_top_k": 64}}, | |
| 231 | + }}, | |
| 232 | + }) | |
| 233 | + f := ModelFacts(context.Background(), "mlxserve", s.URL+"/v1", id) | |
| 234 | + if !f.Known || f.ServerFamily != "gemma4" || f.ContextLength != 101376 || f.Thinking.Switch != "enable_thinking" { | |
| 235 | + t.Errorf("facts = %+v", f) | |
| 236 | + } | |
| 237 | + if want := map[string]float64{"temperature": 1, "top_p": 0.95, "top_k": 64}; !reflect.DeepEqual(f.Sampling, want) { | |
| 238 | + t.Errorf("sampling = %v, want %v", f.Sampling, want) | |
| 239 | + } | |
| 240 | + if got, err := Models(context.Background(), "mlxserve", s.URL+"/v1"); err != nil || !reflect.DeepEqual(got, []string{id, "other/model"}) { | |
| 241 | + t.Errorf("models: %v %v", got, err) | |
| 242 | + } | |
| 243 | +} | |
| @@ -212,3 +212,32 @@ func TestPropsFactsRouterMode(t *testing.T) { | |||
| 212 | t.Errorf("router-only answer gave facts: %+v", f) | 212 | t.Errorf("router-only answer gave facts: %+v", f) |
| 213 | } | 213 | } |
| 214 | } | 214 | } |
| 215 | + | ||
| 216 | +// MLX-Serve: /api/show in Ollama's shape (no sampling in `parameters`), the | ||
| 217 | +// model's own sampling in /v1/models' `meta.gen_*` (measured on mlx-serve | ||
| 218 | +// 26.11.3); the model list is /v1/models, whose ids have no ":latest". | ||
| 219 | +func TestMlxServeFacts(t *testing.T) { | ||
| 220 | + const id = "lmstudio-community/gemma-4-E4B-it-MLX-8bit" | ||
| 221 | + s := fakeServer(t, map[string]any{ | ||
| 222 | + "POST /api/show": map[string]any{ | ||
| 223 | + "parameters": "", | ||
| 224 | + "template": "{%- if enable_thinking is defined and enable_thinking -%}…", | ||
| 225 | + "details": map[string]any{"family": "gemma4"}, | ||
| 226 | + "model_info": map[string]any{"general.architecture": "gemma4", "gemma4.context_length": 101376}, | ||
| 227 | + }, | ||
| 228 | + "GET /v1/models": map[string]any{"data": []any{ | ||
| 229 | + map[string]any{"id": "other/model", "meta": map[string]any{"gen_temperature": 0.2}}, | ||
| 230 | + map[string]any{"id": id, "meta": map[string]any{"gen_temperature": 1, "gen_top_p": 0.95, "gen_top_k": 64}}, | ||
| 231 | + }}, | ||
| 232 | + }) | ||
| 233 | + f := ModelFacts(context.Background(), "mlxserve", s.URL+"/v1", id) | ||
| 234 | + if !f.Known || f.ServerFamily != "gemma4" || f.ContextLength != 101376 || f.Thinking.Switch != "enable_thinking" { | ||
| 235 | + t.Errorf("facts = %+v", f) | ||
| 236 | + } | ||
| 237 | + if want := map[string]float64{"temperature": 1, "top_p": 0.95, "top_k": 64}; !reflect.DeepEqual(f.Sampling, want) { | ||
| 238 | + t.Errorf("sampling = %v, want %v", f.Sampling, want) | ||
| 239 | + } | ||
| 240 | + if got, err := Models(context.Background(), "mlxserve", s.URL+"/v1"); err != nil || !reflect.DeepEqual(got, []string{id, "other/model"}) { | ||
| 241 | + t.Errorf("models: %v %v", got, err) | ||
| 242 | + } | ||
| 243 | +} | ||
modified
internal/agentinit/wizard.go +2 -2 | @@ -21,14 +21,14 @@ import ( | ||
| 21 | 21 | // providers are the servers mm speaks to, in the order they are offered. |
| 22 | 22 | // llamacpp first (ticket 221, user's choice): the default when nothing |
| 23 | 23 | // answers (firstAnswering). |
| 24 | -var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "openai", "openai-responses"} | |
| 24 | +var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "openai", "openai-responses"} | |
| 25 | 25 | |
| 26 | 26 | // local are the providers probed for the first question's default, in this |
| 27 | 27 | // order: the first that answers is proposed — llamacpp when llama-server |
| 28 | 28 | // runs (9931, then 8080), else a running llmman, Ollama… Never `openai`, |
| 29 | 29 | // whose default address is the OpenAI API — mm init must not call a remote |
| 30 | 30 | // service nobody asked for. |
| 31 | -var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk"} | |
| 31 | +var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve"} | |
| 32 | 32 | |
| 33 | 33 | // Window asks the flow's questions in a full-screen window (internal/tui's |
| 34 | 34 | // RunInit): it returns false when the user quit without writing. main hands |
| @@ -21,14 +21,14 @@ import ( | |||
| 21 | // providers are the servers mm speaks to, in the order they are offered. | 21 | // providers are the servers mm speaks to, in the order they are offered. |
| 22 | // llamacpp first (ticket 221, user's choice): the default when nothing | 22 | // llamacpp first (ticket 221, user's choice): the default when nothing |
| 23 | // answers (firstAnswering). | 23 | // answers (firstAnswering). |
| 24 | -var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "openai", "openai-responses"} | 24 | +var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "openai", "openai-responses"} |
| 25 | 25 | ||
| 26 | // local are the providers probed for the first question's default, in this | 26 | // local are the providers probed for the first question's default, in this |
| 27 | // order: the first that answers is proposed — llamacpp when llama-server | 27 | // order: the first that answers is proposed — llamacpp when llama-server |
| 28 | // runs (9931, then 8080), else a running llmman, Ollama… Never `openai`, | 28 | // runs (9931, then 8080), else a running llmman, Ollama… Never `openai`, |
| 29 | // whose default address is the OpenAI API — mm init must not call a remote | 29 | // whose default address is the OpenAI API — mm init must not call a remote |
| 30 | // service nobody asked for. | 30 | // service nobody asked for. |
| 31 | -var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk"} | 31 | +var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve"} |
| 32 | 32 | ||
| 33 | // Window asks the flow's questions in a full-screen window (internal/tui's | 33 | // Window asks the flow's questions in a full-screen window (internal/tui's |
| 34 | // RunInit): it returns false when the user quit without writing. main hands | 34 | // RunInit): it returns false when the user quit without writing. main hands |
modified
internal/config/config.go +1 -1 | @@ -23,7 +23,7 @@ import ( | ||
| 23 | 23 | // Config: everything that can be tuned without touching the code. |
| 24 | 24 | type Config struct { |
| 25 | 25 | // Provider: which LLM server is behind BaseURL — a key of the engine |
| 26 | - // registry ("dmr", "llamacpp", "llmman", "ollama"). Defaults to "dmr" so that every agent.yaml | |
| 26 | + // registry ("dmr", "llamacpp", "llmman", "ollama", "kronk", "mlxserve", "openai"…). Defaults to "dmr" so that every agent.yaml | |
| 27 | 27 | // written before this key existed keeps its meaning. |
| 28 | 28 | Provider string `yaml:"provider"` |
| 29 | 29 | |
| @@ -23,7 +23,7 @@ import ( | |||
| 23 | // Config: everything that can be tuned without touching the code. | 23 | // Config: everything that can be tuned without touching the code. |
| 24 | type Config struct { | 24 | type Config struct { |
| 25 | // Provider: which LLM server is behind BaseURL — a key of the engine | 25 | // Provider: which LLM server is behind BaseURL — a key of the engine |
| 26 | - // registry ("dmr", "llamacpp", "llmman", "ollama"). Defaults to "dmr" so that every agent.yaml | 26 | + // registry ("dmr", "llamacpp", "llmman", "ollama", "kronk", "mlxserve", "openai"…). Defaults to "dmr" so that every agent.yaml |
| 27 | // written before this key existed keeps its meaning. | 27 | // written before this key existed keeps its meaning. |
| 28 | Provider string `yaml:"provider"` | 28 | Provider string `yaml:"provider"` |
| 29 | 29 | ||
added
internal/engine/mlxserve.go +121 -0 | new file mode 100644 | ||
| @@ -0,0 +1,121 @@ | ||
| 1 | +package engine | |
| 2 | + | |
| 3 | +import ( | |
| 4 | + "context" | |
| 5 | + "errors" | |
| 6 | + "fmt" | |
| 7 | + "net/http" | |
| 8 | + "strings" | |
| 9 | +) | |
| 10 | + | |
| 11 | +// MLX-Serve (ticket 252, https://github.com/ddalcu/mlx-serve) is a native | |
| 12 | +// server for Apple Silicon (MLX, no Python; NVIDIA builds on Linux) that | |
| 13 | +// speaks the OpenAI, Anthropic and Ollama APIs on one port, 11234. mm talks | |
| 14 | +// to its OpenAI side. Measured on mlx-serve 26.11.3, 2026-11-24, from an sbx | |
| 15 | +// sandbox on the Mac's server (lmstudio-community/gemma-4-E4B-it-MLX-8bit): | |
| 16 | +// | |
| 17 | +// - GET /v1/models lists every downloaded model, loaded or not, each with | |
| 18 | +// `loaded` and `context_length`. Loaded, that is the window it is SERVED | |
| 19 | +// with — 101376, then 73728 after a reload with less free memory —; | |
| 20 | +// unloaded, the model's trained length (131072), too large to trust; | |
| 21 | +// - a model loads on the first request that names it. A model it does NOT | |
| 22 | +// have is no error: the request is answered, HTTP 200, by the server's | |
| 23 | +// default model under the requested name. The probe's warning is the only | |
| 24 | +// place the mistake shows; | |
| 25 | +// - reasoning streams in `reasoning_content`; it is on when either | |
| 26 | +// chat_template_kwargs.enable_thinking or reasoning_effort says so, and | |
| 27 | +// off only when both say no (thinkingOffBoth, usage.go); | |
| 28 | +// - no prompt_progress (return_progress is ignored); | |
| 29 | +// - POST /api/pull is Ollama's wire: `{"status":"success"}` for a model it | |
| 30 | +// has, `{"error":…}` at the end of a failed one, always HTTP 200; | |
| 31 | +// - POST /v1/unload-model {"model": id} answers the model with | |
| 32 | +// `state: "unloaded"` — also when it was not loaded —, and 404 | |
| 33 | +// `model_not_found` for an id it does not know; | |
| 34 | +// - `--api-key` protects every caller but localhost: a sandbox or a | |
| 35 | +// container is not localhost, so the key is sent on every route. | |
| 36 | + | |
| 37 | +// mlxModels is the body of MLX-Serve's GET /v1/models: the OpenAI list plus | |
| 38 | +// whether each model is loaded and the window it has. | |
| 39 | +type mlxModels struct { | |
| 40 | + Data []mlxModel `json:"data"` | |
| 41 | +} | |
| 42 | + | |
| 43 | +type mlxModel struct { | |
| 44 | + ID string `json:"id"` | |
| 45 | + Loaded bool `json:"loaded"` | |
| 46 | + ContextLength int `json:"context_length"` | |
| 47 | +} | |
| 48 | + | |
| 49 | +// find returns the listed model whose id is id. | |
| 50 | +func (l mlxModels) find(id string) (mlxModel, bool) { | |
| 51 | + for _, m := range l.Data { | |
| 52 | + if m.ID == id { | |
| 53 | + return m, true | |
| 54 | + } | |
| 55 | + } | |
| 56 | + return mlxModel{}, false | |
| 57 | +} | |
| 58 | + | |
| 59 | +// listMlxModels reads GET /v1/models with the backend's key. | |
| 60 | +func listMlxModels(ctx context.Context, b Backend) (mlxModels, error) { | |
| 61 | + var list mlxModels | |
| 62 | + err := getWithKey(ctx, b, strings.TrimSuffix(b.BaseURL, "/")+"/models", &list) | |
| 63 | + return list, err | |
| 64 | +} | |
| 65 | + | |
| 66 | +// probeMlxServe: reachable when /v1/models answers, a warning when the | |
| 67 | +// server refuses the key or does not have the model, and the served window | |
| 68 | +// when the model is loaded. An unloaded model's window stays unknown — | |
| 69 | +// EnsureContextWindow learns it once the first question has loaded it. | |
| 70 | +func probeMlxServe(ctx context.Context, b Backend) Info { | |
| 71 | + ctx, cancel := context.WithTimeout(ctx, probeClient.Timeout) | |
| 72 | + defer cancel() | |
| 73 | + | |
| 74 | + list, err := listMlxModels(ctx, b) | |
| 75 | + var status *httpStatusError | |
| 76 | + switch { | |
| 77 | + case errors.As(err, &status) && (status.code == http.StatusUnauthorized || status.code == http.StatusForbidden): | |
| 78 | + return Info{Reachable: true, Warnings: []string{ | |
| 79 | + fmt.Sprintf("mlxserve: the server refuses the key (%d) — is $%s set to its --api-key?", status.code, b.APIKeyEnv), | |
| 80 | + }} | |
| 81 | + case err != nil: | |
| 82 | + return Info{} | |
| 83 | + } | |
| 84 | + | |
| 85 | + info := Info{Reachable: true} | |
| 86 | + m, found := list.find(b.Model) | |
| 87 | + switch { | |
| 88 | + case !found: | |
| 89 | + info.Warnings = append(info.Warnings, fmt.Sprintf( | |
| 90 | + "mlxserve: model %q is not downloaded — mlx-serve pull %s (or autoPull: true); until then the server answers with its default model", b.Model, b.Model)) | |
| 91 | + case m.Loaded && m.ContextLength > 0: | |
| 92 | + info.ContextWindow, info.ContextSource = m.ContextLength, "/v1/models" | |
| 93 | + } | |
| 94 | + return info | |
| 95 | +} | |
| 96 | + | |
| 97 | +// unloadMlxServe frees model with POST /v1/unload-model. The server answers | |
| 98 | +// "unloaded" whether or not the model was loaded, so the list is read first: | |
| 99 | +// a model that is not loaded — or that the server does not have — is | |
| 100 | +// "nothing to unload", not a failure. | |
| 101 | +func unloadMlxServe(ctx context.Context, b Backend, model string) (string, error) { | |
| 102 | + list, err := listMlxModels(ctx, b) | |
| 103 | + if err != nil { | |
| 104 | + return "", err | |
| 105 | + } | |
| 106 | + if m, found := list.find(model); !found || !m.Loaded { | |
| 107 | + return fmt.Sprintf("%s was not loaded: nothing to unload", model), nil | |
| 108 | + } | |
| 109 | + var reply struct { | |
| 110 | + Model struct { | |
| 111 | + State string `json:"state"` | |
| 112 | + } `json:"model"` | |
| 113 | + } | |
| 114 | + if err := postJSON(ctx, b, rootURL(b.BaseURL)+"/v1/unload-model", map[string]string{"model": model}, &reply); err != nil { | |
| 115 | + return "", err | |
| 116 | + } | |
| 117 | + if reply.Model.State != "unloaded" { | |
| 118 | + return "", fmt.Errorf("the server did not confirm (state %q)", reply.Model.State) | |
| 119 | + } | |
| 120 | + return "unloaded " + model, nil | |
| 121 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | +package engine | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "errors" | ||
| 6 | + "fmt" | ||
| 7 | + "net/http" | ||
| 8 | + "strings" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +// MLX-Serve (ticket 252, https://github.com/ddalcu/mlx-serve) is a native | ||
| 12 | +// server for Apple Silicon (MLX, no Python; NVIDIA builds on Linux) that | ||
| 13 | +// speaks the OpenAI, Anthropic and Ollama APIs on one port, 11234. mm talks | ||
| 14 | +// to its OpenAI side. Measured on mlx-serve 26.11.3, 2026-11-24, from an sbx | ||
| 15 | +// sandbox on the Mac's server (lmstudio-community/gemma-4-E4B-it-MLX-8bit): | ||
| 16 | +// | ||
| 17 | +// - GET /v1/models lists every downloaded model, loaded or not, each with | ||
| 18 | +// `loaded` and `context_length`. Loaded, that is the window it is SERVED | ||
| 19 | +// with — 101376, then 73728 after a reload with less free memory —; | ||
| 20 | +// unloaded, the model's trained length (131072), too large to trust; | ||
| 21 | +// - a model loads on the first request that names it. A model it does NOT | ||
| 22 | +// have is no error: the request is answered, HTTP 200, by the server's | ||
| 23 | +// default model under the requested name. The probe's warning is the only | ||
| 24 | +// place the mistake shows; | ||
| 25 | +// - reasoning streams in `reasoning_content`; it is on when either | ||
| 26 | +// chat_template_kwargs.enable_thinking or reasoning_effort says so, and | ||
| 27 | +// off only when both say no (thinkingOffBoth, usage.go); | ||
| 28 | +// - no prompt_progress (return_progress is ignored); | ||
| 29 | +// - POST /api/pull is Ollama's wire: `{"status":"success"}` for a model it | ||
| 30 | +// has, `{"error":…}` at the end of a failed one, always HTTP 200; | ||
| 31 | +// - POST /v1/unload-model {"model": id} answers the model with | ||
| 32 | +// `state: "unloaded"` — also when it was not loaded —, and 404 | ||
| 33 | +// `model_not_found` for an id it does not know; | ||
| 34 | +// - `--api-key` protects every caller but localhost: a sandbox or a | ||
| 35 | +// container is not localhost, so the key is sent on every route. | ||
| 36 | + | ||
| 37 | +// mlxModels is the body of MLX-Serve's GET /v1/models: the OpenAI list plus | ||
| 38 | +// whether each model is loaded and the window it has. | ||
| 39 | +type mlxModels struct { | ||
| 40 | + Data []mlxModel `json:"data"` | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +type mlxModel struct { | ||
| 44 | + ID string `json:"id"` | ||
| 45 | + Loaded bool `json:"loaded"` | ||
| 46 | + ContextLength int `json:"context_length"` | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +// find returns the listed model whose id is id. | ||
| 50 | +func (l mlxModels) find(id string) (mlxModel, bool) { | ||
| 51 | + for _, m := range l.Data { | ||
| 52 | + if m.ID == id { | ||
| 53 | + return m, true | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + return mlxModel{}, false | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +// listMlxModels reads GET /v1/models with the backend's key. | ||
| 60 | +func listMlxModels(ctx context.Context, b Backend) (mlxModels, error) { | ||
| 61 | + var list mlxModels | ||
| 62 | + err := getWithKey(ctx, b, strings.TrimSuffix(b.BaseURL, "/")+"/models", &list) | ||
| 63 | + return list, err | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +// probeMlxServe: reachable when /v1/models answers, a warning when the | ||
| 67 | +// server refuses the key or does not have the model, and the served window | ||
| 68 | +// when the model is loaded. An unloaded model's window stays unknown — | ||
| 69 | +// EnsureContextWindow learns it once the first question has loaded it. | ||
| 70 | +func probeMlxServe(ctx context.Context, b Backend) Info { | ||
| 71 | + ctx, cancel := context.WithTimeout(ctx, probeClient.Timeout) | ||
| 72 | + defer cancel() | ||
| 73 | + | ||
| 74 | + list, err := listMlxModels(ctx, b) | ||
| 75 | + var status *httpStatusError | ||
| 76 | + switch { | ||
| 77 | + case errors.As(err, &status) && (status.code == http.StatusUnauthorized || status.code == http.StatusForbidden): | ||
| 78 | + return Info{Reachable: true, Warnings: []string{ | ||
| 79 | + fmt.Sprintf("mlxserve: the server refuses the key (%d) — is $%s set to its --api-key?", status.code, b.APIKeyEnv), | ||
| 80 | + }} | ||
| 81 | + case err != nil: | ||
| 82 | + return Info{} | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + info := Info{Reachable: true} | ||
| 86 | + m, found := list.find(b.Model) | ||
| 87 | + switch { | ||
| 88 | + case !found: | ||
| 89 | + info.Warnings = append(info.Warnings, fmt.Sprintf( | ||
| 90 | + "mlxserve: model %q is not downloaded — mlx-serve pull %s (or autoPull: true); until then the server answers with its default model", b.Model, b.Model)) | ||
| 91 | + case m.Loaded && m.ContextLength > 0: | ||
| 92 | + info.ContextWindow, info.ContextSource = m.ContextLength, "/v1/models" | ||
| 93 | + } | ||
| 94 | + return info | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +// unloadMlxServe frees model with POST /v1/unload-model. The server answers | ||
| 98 | +// "unloaded" whether or not the model was loaded, so the list is read first: | ||
| 99 | +// a model that is not loaded — or that the server does not have — is | ||
| 100 | +// "nothing to unload", not a failure. | ||
| 101 | +func unloadMlxServe(ctx context.Context, b Backend, model string) (string, error) { | ||
| 102 | + list, err := listMlxModels(ctx, b) | ||
| 103 | + if err != nil { | ||
| 104 | + return "", err | ||
| 105 | + } | ||
| 106 | + if m, found := list.find(model); !found || !m.Loaded { | ||
| 107 | + return fmt.Sprintf("%s was not loaded: nothing to unload", model), nil | ||
| 108 | + } | ||
| 109 | + var reply struct { | ||
| 110 | + Model struct { | ||
| 111 | + State string `json:"state"` | ||
| 112 | + } `json:"model"` | ||
| 113 | + } | ||
| 114 | + if err := postJSON(ctx, b, rootURL(b.BaseURL)+"/v1/unload-model", map[string]string{"model": model}, &reply); err != nil { | ||
| 115 | + return "", err | ||
| 116 | + } | ||
| 117 | + if reply.Model.State != "unloaded" { | ||
| 118 | + return "", fmt.Errorf("the server did not confirm (state %q)", reply.Model.State) | ||
| 119 | + } | ||
| 120 | + return "unloaded " + model, nil | ||
| 121 | +} | ||
added
internal/engine/mlxserve_test.go +164 -0 | new file mode 100644 | ||
| @@ -0,0 +1,164 @@ | ||
| 1 | +package engine | |
| 2 | + | |
| 3 | +import ( | |
| 4 | + "context" | |
| 5 | + "encoding/json" | |
| 6 | + "fmt" | |
| 7 | + "io" | |
| 8 | + "net/http" | |
| 9 | + "net/http/httptest" | |
| 10 | + "strings" | |
| 11 | + "sync" | |
| 12 | + "testing" | |
| 13 | +) | |
| 14 | + | |
| 15 | +const mlxTestModel = "lmstudio-community/gemma-4-E4B-it-MLX-8bit" | |
| 16 | + | |
| 17 | +// fakeMlxServe replays the routes measured on mlx-serve 26.11.3 | |
| 18 | +// (mlxserve.go): the model list with `loaded` and `context_length`, and the | |
| 19 | +// unload answer — "unloaded" whether or not the model was loaded, 404 for an | |
| 20 | +// id it does not know. | |
| 21 | +type fakeMlxServe struct { | |
| 22 | + mu sync.Mutex | |
| 23 | + loaded bool | |
| 24 | + key string // a required key; "" = no --api-key | |
| 25 | + gotUnload string | |
| 26 | +} | |
| 27 | + | |
| 28 | +func newFakeMlxServe(t *testing.T, f *fakeMlxServe) Backend { | |
| 29 | + t.Helper() | |
| 30 | + srv := httptest.NewServer(f) | |
| 31 | + t.Cleanup(srv.Close) | |
| 32 | + return Backend{Provider: "mlxserve", BaseURL: srv.URL + "/v1", Model: mlxTestModel, APIKey: "not-needed", APIKeyEnv: "MLX_SERVE_API_KEY"} | |
| 33 | +} | |
| 34 | + | |
| 35 | +func (f *fakeMlxServe) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
| 36 | + f.mu.Lock() | |
| 37 | + defer f.mu.Unlock() | |
| 38 | + if f.key != "" && r.Header.Get("Authorization") != "Bearer "+f.key { | |
| 39 | + w.WriteHeader(http.StatusUnauthorized) | |
| 40 | + _, _ = io.WriteString(w, `{"error":{"message":"invalid api key","type":"authentication_error","code":401}}`) | |
| 41 | + return | |
| 42 | + } | |
| 43 | + switch r.URL.Path { | |
| 44 | + case "/v1/models": | |
| 45 | + window, state := 131072, "unloaded" | |
| 46 | + if f.loaded { | |
| 47 | + window, state = 101376, "ready" | |
| 48 | + } | |
| 49 | + _, _ = fmt.Fprintf(w, `{"object":"list","data":[{"id":%q,"object":"model","owned_by":"mlx-serve","loaded":%v,"state":%q,"context_length":%d}]}`, | |
| 50 | + mlxTestModel, f.loaded, state, window) | |
| 51 | + case "/v1/unload-model": | |
| 52 | + var body struct{ Model string } | |
| 53 | + _ = json.NewDecoder(r.Body).Decode(&body) | |
| 54 | + f.gotUnload = body.Model | |
| 55 | + if body.Model != mlxTestModel { | |
| 56 | + w.WriteHeader(http.StatusNotFound) | |
| 57 | + _, _ = io.WriteString(w, `{"error":{"message":"Unknown model id","type":"model_not_found","param":null,"code":404}}`) | |
| 58 | + return | |
| 59 | + } | |
| 60 | + f.loaded = false | |
| 61 | + _, _ = fmt.Fprintf(w, `{"model":{"id":%q,"object":"model","loaded":false,"state":"unloaded"}}`, mlxTestModel) | |
| 62 | + default: | |
| 63 | + w.WriteHeader(http.StatusNotFound) | |
| 64 | + } | |
| 65 | +} | |
| 66 | + | |
| 67 | +// The probe gives the served window only for a loaded model: an unloaded | |
| 68 | +// one lists its trained length, which can be more than it will be served with. | |
| 69 | +func TestProbeMlxServe(t *testing.T) { | |
| 70 | + p, _ := Lookup("mlxserve") | |
| 71 | + f := &fakeMlxServe{loaded: true} | |
| 72 | + b := newFakeMlxServe(t, f) | |
| 73 | + | |
| 74 | + info := p.Probe(context.Background(), b) | |
| 75 | + if !info.Reachable || info.ContextWindow != 101376 || info.ContextSource != "/v1/models" || len(info.Warnings) != 0 { | |
| 76 | + t.Errorf("loaded: %+v, want reachable, 101376 from /v1/models, no warning", info) | |
| 77 | + } | |
| 78 | + | |
| 79 | + f.loaded = false | |
| 80 | + if info := p.Probe(context.Background(), b); !info.Reachable || info.ContextWindow != 0 || len(info.Warnings) != 0 { | |
| 81 | + t.Errorf("not loaded: %+v, want reachable, window unknown, no warning", info) | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 85 | +// A model the server does not have is answered anyway — by its default | |
| 86 | +// model —, so the warning must say so and name the pull. | |
| 87 | +func TestProbeMlxServeMissingModel(t *testing.T) { | |
| 88 | + p, _ := Lookup("mlxserve") | |
| 89 | + b := newFakeMlxServe(t, &fakeMlxServe{loaded: true}) | |
| 90 | + b.Model = "mlx-community/Qwen3.8-27B-4bit" | |
| 91 | + info := p.Probe(context.Background(), b) | |
| 92 | + if len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "mlx-serve pull "+b.Model) || | |
| 93 | + !strings.Contains(info.Warnings[0], "default model") || info.ContextWindow != 0 { | |
| 94 | + t.Errorf("missing model: %+v, want one warning naming mlx-serve pull and the default model", info) | |
| 95 | + } | |
| 96 | +} | |
| 97 | + | |
| 98 | +// A server started with --api-key refuses a caller that is not localhost | |
| 99 | +// (a sandbox, a container): the warning names the variable to set. | |
| 100 | +func TestProbeMlxServeRefusedKey(t *testing.T) { | |
| 101 | + p, _ := Lookup("mlxserve") | |
| 102 | + b := newFakeMlxServe(t, &fakeMlxServe{loaded: true, key: "secret"}) | |
| 103 | + info := p.Probe(context.Background(), b) | |
| 104 | + if !info.Reachable || len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "$MLX_SERVE_API_KEY") { | |
| 105 | + t.Errorf("refused key: %+v, want reachable and one warning naming MLX_SERVE_API_KEY", info) | |
| 106 | + } | |
| 107 | + b.APIKey = "secret" | |
| 108 | + if info := p.Probe(context.Background(), b); len(info.Warnings) != 0 || info.ContextWindow != 101376 { | |
| 109 | + t.Errorf("good key: %+v, want no warning and the window", info) | |
| 110 | + } | |
| 111 | +} | |
| 112 | + | |
| 113 | +// The server says "unloaded" for a model that was not loaded: mm reads the | |
| 114 | +// list first, so that case is "nothing to unload" and no request is sent. | |
| 115 | +func TestUnloadMlxServe(t *testing.T) { | |
| 116 | + f := &fakeMlxServe{loaded: true} | |
| 117 | + b := newFakeMlxServe(t, f) | |
| 118 | + | |
| 119 | + got, err := unloadMlxServe(context.Background(), b, mlxTestModel) | |
| 120 | + if err != nil || got != "unloaded "+mlxTestModel || f.gotUnload != mlxTestModel || f.loaded { | |
| 121 | + t.Fatalf("loaded: %q, %v (sent %q, still loaded %v)", got, err, f.gotUnload, f.loaded) | |
| 122 | + } | |
| 123 | + | |
| 124 | + f.gotUnload = "" | |
| 125 | + got, err = unloadMlxServe(context.Background(), b, mlxTestModel) | |
| 126 | + if err != nil || !strings.Contains(got, "nothing to unload") || f.gotUnload != "" { | |
| 127 | + t.Errorf("not loaded: %q, %v (sent %q), want nothing to unload and no request", got, err, f.gotUnload) | |
| 128 | + } | |
| 129 | + | |
| 130 | + got, err = unloadMlxServe(context.Background(), b, "nobody/unknown") | |
| 131 | + if err != nil || !strings.Contains(got, "nothing to unload") { | |
| 132 | + t.Errorf("unknown model: %q, %v, want nothing to unload", got, err) | |
| 133 | + } | |
| 134 | +} | |
| 135 | + | |
| 136 | +// MLX-Serve reasons when either switch says so: the summary request must | |
| 137 | +// turn off both, over whatever the sampling chose, and keep the other | |
| 138 | +// template variables. | |
| 139 | +func TestStreamOptionsWithoutThinkingMlxServe(t *testing.T) { | |
| 140 | + send := func(ctx context.Context, body string) string { | |
| 141 | + req, _ := http.NewRequestWithContext(ctx, http.MethodPost, "http://x/v1/chat/completions", strings.NewReader(body)) | |
| 142 | + var seen string | |
| 143 | + _, _ = streamOptions(false, thinkingOffBoth)(req, func(r *http.Request) (*http.Response, error) { | |
| 144 | + b, _ := io.ReadAll(r.Body) | |
| 145 | + seen = string(b) | |
| 146 | + return &http.Response{StatusCode: 200, Body: http.NoBody}, nil | |
| 147 | + }) | |
| 148 | + return seen | |
| 149 | + } | |
| 150 | + marked := withoutThinking(context.Background()) | |
| 151 | + chose := `{"stream":true,"reasoning_effort":"high","chat_template_kwargs":{"enable_thinking":true,"custom":1}}` | |
| 152 | + got := send(marked, chose) | |
| 153 | + for _, want := range []string{`"reasoning_effort":"none"`, `"enable_thinking":false`, `"custom":1`} { | |
| 154 | + if !strings.Contains(got, want) { | |
| 155 | + t.Errorf("mlxserve, marked: %s lacks %s", got, want) | |
| 156 | + } | |
| 157 | + } | |
| 158 | + if strings.Contains(got, "return_progress") { | |
| 159 | + t.Errorf("mlxserve asks for progress: %s", got) | |
| 160 | + } | |
| 161 | + if got := send(context.Background(), chose); !strings.Contains(got, `"reasoning_effort":"high"`) || !strings.Contains(got, `"enable_thinking":true`) { | |
| 162 | + t.Errorf("mlxserve, not marked, the request was changed: %s", got) | |
| 163 | + } | |
| 164 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,164 @@ | |||
| 1 | +package engine | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "encoding/json" | ||
| 6 | + "fmt" | ||
| 7 | + "io" | ||
| 8 | + "net/http" | ||
| 9 | + "net/http/httptest" | ||
| 10 | + "strings" | ||
| 11 | + "sync" | ||
| 12 | + "testing" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +const mlxTestModel = "lmstudio-community/gemma-4-E4B-it-MLX-8bit" | ||
| 16 | + | ||
| 17 | +// fakeMlxServe replays the routes measured on mlx-serve 26.11.3 | ||
| 18 | +// (mlxserve.go): the model list with `loaded` and `context_length`, and the | ||
| 19 | +// unload answer — "unloaded" whether or not the model was loaded, 404 for an | ||
| 20 | +// id it does not know. | ||
| 21 | +type fakeMlxServe struct { | ||
| 22 | + mu sync.Mutex | ||
| 23 | + loaded bool | ||
| 24 | + key string // a required key; "" = no --api-key | ||
| 25 | + gotUnload string | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func newFakeMlxServe(t *testing.T, f *fakeMlxServe) Backend { | ||
| 29 | + t.Helper() | ||
| 30 | + srv := httptest.NewServer(f) | ||
| 31 | + t.Cleanup(srv.Close) | ||
| 32 | + return Backend{Provider: "mlxserve", BaseURL: srv.URL + "/v1", Model: mlxTestModel, APIKey: "not-needed", APIKeyEnv: "MLX_SERVE_API_KEY"} | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (f *fakeMlxServe) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
| 36 | + f.mu.Lock() | ||
| 37 | + defer f.mu.Unlock() | ||
| 38 | + if f.key != "" && r.Header.Get("Authorization") != "Bearer "+f.key { | ||
| 39 | + w.WriteHeader(http.StatusUnauthorized) | ||
| 40 | + _, _ = io.WriteString(w, `{"error":{"message":"invalid api key","type":"authentication_error","code":401}}`) | ||
| 41 | + return | ||
| 42 | + } | ||
| 43 | + switch r.URL.Path { | ||
| 44 | + case "/v1/models": | ||
| 45 | + window, state := 131072, "unloaded" | ||
| 46 | + if f.loaded { | ||
| 47 | + window, state = 101376, "ready" | ||
| 48 | + } | ||
| 49 | + _, _ = fmt.Fprintf(w, `{"object":"list","data":[{"id":%q,"object":"model","owned_by":"mlx-serve","loaded":%v,"state":%q,"context_length":%d}]}`, | ||
| 50 | + mlxTestModel, f.loaded, state, window) | ||
| 51 | + case "/v1/unload-model": | ||
| 52 | + var body struct{ Model string } | ||
| 53 | + _ = json.NewDecoder(r.Body).Decode(&body) | ||
| 54 | + f.gotUnload = body.Model | ||
| 55 | + if body.Model != mlxTestModel { | ||
| 56 | + w.WriteHeader(http.StatusNotFound) | ||
| 57 | + _, _ = io.WriteString(w, `{"error":{"message":"Unknown model id","type":"model_not_found","param":null,"code":404}}`) | ||
| 58 | + return | ||
| 59 | + } | ||
| 60 | + f.loaded = false | ||
| 61 | + _, _ = fmt.Fprintf(w, `{"model":{"id":%q,"object":"model","loaded":false,"state":"unloaded"}}`, mlxTestModel) | ||
| 62 | + default: | ||
| 63 | + w.WriteHeader(http.StatusNotFound) | ||
| 64 | + } | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +// The probe gives the served window only for a loaded model: an unloaded | ||
| 68 | +// one lists its trained length, which can be more than it will be served with. | ||
| 69 | +func TestProbeMlxServe(t *testing.T) { | ||
| 70 | + p, _ := Lookup("mlxserve") | ||
| 71 | + f := &fakeMlxServe{loaded: true} | ||
| 72 | + b := newFakeMlxServe(t, f) | ||
| 73 | + | ||
| 74 | + info := p.Probe(context.Background(), b) | ||
| 75 | + if !info.Reachable || info.ContextWindow != 101376 || info.ContextSource != "/v1/models" || len(info.Warnings) != 0 { | ||
| 76 | + t.Errorf("loaded: %+v, want reachable, 101376 from /v1/models, no warning", info) | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + f.loaded = false | ||
| 80 | + if info := p.Probe(context.Background(), b); !info.Reachable || info.ContextWindow != 0 || len(info.Warnings) != 0 { | ||
| 81 | + t.Errorf("not loaded: %+v, want reachable, window unknown, no warning", info) | ||
| 82 | + } | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +// A model the server does not have is answered anyway — by its default | ||
| 86 | +// model —, so the warning must say so and name the pull. | ||
| 87 | +func TestProbeMlxServeMissingModel(t *testing.T) { | ||
| 88 | + p, _ := Lookup("mlxserve") | ||
| 89 | + b := newFakeMlxServe(t, &fakeMlxServe{loaded: true}) | ||
| 90 | + b.Model = "mlx-community/Qwen3.8-27B-4bit" | ||
| 91 | + info := p.Probe(context.Background(), b) | ||
| 92 | + if len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "mlx-serve pull "+b.Model) || | ||
| 93 | + !strings.Contains(info.Warnings[0], "default model") || info.ContextWindow != 0 { | ||
| 94 | + t.Errorf("missing model: %+v, want one warning naming mlx-serve pull and the default model", info) | ||
| 95 | + } | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +// A server started with --api-key refuses a caller that is not localhost | ||
| 99 | +// (a sandbox, a container): the warning names the variable to set. | ||
| 100 | +func TestProbeMlxServeRefusedKey(t *testing.T) { | ||
| 101 | + p, _ := Lookup("mlxserve") | ||
| 102 | + b := newFakeMlxServe(t, &fakeMlxServe{loaded: true, key: "secret"}) | ||
| 103 | + info := p.Probe(context.Background(), b) | ||
| 104 | + if !info.Reachable || len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "$MLX_SERVE_API_KEY") { | ||
| 105 | + t.Errorf("refused key: %+v, want reachable and one warning naming MLX_SERVE_API_KEY", info) | ||
| 106 | + } | ||
| 107 | + b.APIKey = "secret" | ||
| 108 | + if info := p.Probe(context.Background(), b); len(info.Warnings) != 0 || info.ContextWindow != 101376 { | ||
| 109 | + t.Errorf("good key: %+v, want no warning and the window", info) | ||
| 110 | + } | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +// The server says "unloaded" for a model that was not loaded: mm reads the | ||
| 114 | +// list first, so that case is "nothing to unload" and no request is sent. | ||
| 115 | +func TestUnloadMlxServe(t *testing.T) { | ||
| 116 | + f := &fakeMlxServe{loaded: true} | ||
| 117 | + b := newFakeMlxServe(t, f) | ||
| 118 | + | ||
| 119 | + got, err := unloadMlxServe(context.Background(), b, mlxTestModel) | ||
| 120 | + if err != nil || got != "unloaded "+mlxTestModel || f.gotUnload != mlxTestModel || f.loaded { | ||
| 121 | + t.Fatalf("loaded: %q, %v (sent %q, still loaded %v)", got, err, f.gotUnload, f.loaded) | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + f.gotUnload = "" | ||
| 125 | + got, err = unloadMlxServe(context.Background(), b, mlxTestModel) | ||
| 126 | + if err != nil || !strings.Contains(got, "nothing to unload") || f.gotUnload != "" { | ||
| 127 | + t.Errorf("not loaded: %q, %v (sent %q), want nothing to unload and no request", got, err, f.gotUnload) | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + got, err = unloadMlxServe(context.Background(), b, "nobody/unknown") | ||
| 131 | + if err != nil || !strings.Contains(got, "nothing to unload") { | ||
| 132 | + t.Errorf("unknown model: %q, %v, want nothing to unload", got, err) | ||
| 133 | + } | ||
| 134 | +} | ||
| 135 | + | ||
| 136 | +// MLX-Serve reasons when either switch says so: the summary request must | ||
| 137 | +// turn off both, over whatever the sampling chose, and keep the other | ||
| 138 | +// template variables. | ||
| 139 | +func TestStreamOptionsWithoutThinkingMlxServe(t *testing.T) { | ||
| 140 | + send := func(ctx context.Context, body string) string { | ||
| 141 | + req, _ := http.NewRequestWithContext(ctx, http.MethodPost, "http://x/v1/chat/completions", strings.NewReader(body)) | ||
| 142 | + var seen string | ||
| 143 | + _, _ = streamOptions(false, thinkingOffBoth)(req, func(r *http.Request) (*http.Response, error) { | ||
| 144 | + b, _ := io.ReadAll(r.Body) | ||
| 145 | + seen = string(b) | ||
| 146 | + return &http.Response{StatusCode: 200, Body: http.NoBody}, nil | ||
| 147 | + }) | ||
| 148 | + return seen | ||
| 149 | + } | ||
| 150 | + marked := withoutThinking(context.Background()) | ||
| 151 | + chose := `{"stream":true,"reasoning_effort":"high","chat_template_kwargs":{"enable_thinking":true,"custom":1}}` | ||
| 152 | + got := send(marked, chose) | ||
| 153 | + for _, want := range []string{`"reasoning_effort":"none"`, `"enable_thinking":false`, `"custom":1`} { | ||
| 154 | + if !strings.Contains(got, want) { | ||
| 155 | + t.Errorf("mlxserve, marked: %s lacks %s", got, want) | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + if strings.Contains(got, "return_progress") { | ||
| 159 | + t.Errorf("mlxserve asks for progress: %s", got) | ||
| 160 | + } | ||
| 161 | + if got := send(context.Background(), chose); !strings.Contains(got, `"reasoning_effort":"high"`) || !strings.Contains(got, `"enable_thinking":true`) { | ||
| 162 | + t.Errorf("mlxserve, not marked, the request was changed: %s", got) | ||
| 163 | + } | ||
| 164 | +} | ||
modified
internal/engine/openai_compat.go +23 -2 | @@ -22,7 +22,7 @@ import ( | ||
| 22 | 22 | |
| 23 | 23 | // openaiCompat is the Provider for every server that speaks the OpenAI |
| 24 | 24 | // chat-completions protocol. Docker Model Runner, llama-server, llmman, |
| 25 | -// Ollama's /v1 and Kronk are five parametrisations of it (`openai`, in | |
| 25 | +// Ollama's /v1, Kronk and MLX-Serve are six parametrisations of it (`openai`, in | |
| 26 | 26 | // openai.go, is the generic one); vLLM and the remote APIs would be more |
| 27 | 27 | // entries in init() below — the point of keeping the struct data-only. |
| 28 | 28 | // Each server keeps its own entry even when two look alike today: a difference |
| @@ -228,6 +228,27 @@ func init() { | ||
| 228 | 228 | unload: unloadKronk, |
| 229 | 229 | pull: pullKronk, |
| 230 | 230 | }) |
| 231 | + register(&openaiCompat{ | |
| 232 | + name: "mlxserve", | |
| 233 | + // `mlx-serve serve` binds 0.0.0.0:11234 by default, so the host's | |
| 234 | + // name answers from a container or a sandbox without a flag. | |
| 235 | + baseURL: "http://127.0.0.1:11234/v1", | |
| 236 | + fallback: "http://host.docker.internal:11234/v1", | |
| 237 | + // The server checks a key only when started with --api-key, and then | |
| 238 | + // for every caller but localhost. mlx-serve reads it from no variable: | |
| 239 | + // MLX_SERVE_API_KEY is mm's name for it. | |
| 240 | + apiKeyEnv: "MLX_SERVE_API_KEY", | |
| 241 | + dummyKey: "not-needed", | |
| 242 | + startHint: "start it: mlx-serve serve (or open the MLX-Serve app)", | |
| 243 | + notFoundHint: "mlx-serve pull %s", | |
| 244 | + probe: probeMlxServe, | |
| 245 | + // Measured 2026-11-24 on mlx-serve 26.11.3 (mlxserve.go): no | |
| 246 | + // prompt_progress; reasoning off only with both switches off. | |
| 247 | + progress: false, | |
| 248 | + thinkingOff: thinkingOffBoth, | |
| 249 | + unload: unloadMlxServe, | |
| 250 | + pull: pullOllamaAPI, | |
| 251 | + }) | |
| 231 | 252 | } |
| 232 | 253 | |
| 233 | 254 | func (p *openaiCompat) Name() string { return p.name } |
| @@ -337,7 +358,7 @@ func modelSupports() *ai.ModelSupports { | ||
| 337 | 358 | // last, next to the network: it records the request as it leaves, after the |
| 338 | 359 | // others have added their fields, and the response before they read it. |
| 339 | 360 | func middlewares(p *openaiCompat) []option.Middleware { |
| 340 | - chain := []option.Middleware{streamOptions(p.progress, p.thinkingOff), reasoningTap} | |
| 361 | + chain := []option.Middleware{streamOptions(p.progress, p.thinkingOff), reasoningTap, dropSSEComments} | |
| 341 | 362 | // toolFormat: xml_tools (ticket 207) goes first: Genkit then sees an |
| 342 | 363 | // ordinary tool call, and the trace records the request as rewritten. |
| 343 | 364 | if config.Cfg.ToolFormat == config.ToolFormatXML { |
| @@ -22,7 +22,7 @@ import ( | |||
| 22 | 22 | ||
| 23 | // openaiCompat is the Provider for every server that speaks the OpenAI | 23 | // openaiCompat is the Provider for every server that speaks the OpenAI |
| 24 | // chat-completions protocol. Docker Model Runner, llama-server, llmman, | 24 | // chat-completions protocol. Docker Model Runner, llama-server, llmman, |
| 25 | -// Ollama's /v1 and Kronk are five parametrisations of it (`openai`, in | 25 | +// Ollama's /v1, Kronk and MLX-Serve are six parametrisations of it (`openai`, in |
| 26 | // openai.go, is the generic one); vLLM and the remote APIs would be more | 26 | // openai.go, is the generic one); vLLM and the remote APIs would be more |
| 27 | // entries in init() below — the point of keeping the struct data-only. | 27 | // entries in init() below — the point of keeping the struct data-only. |
| 28 | // Each server keeps its own entry even when two look alike today: a difference | 28 | // Each server keeps its own entry even when two look alike today: a difference |
| @@ -228,6 +228,27 @@ func init() { | |||
| 228 | unload: unloadKronk, | 228 | unload: unloadKronk, |
| 229 | pull: pullKronk, | 229 | pull: pullKronk, |
| 230 | }) | 230 | }) |
| 231 | + register(&openaiCompat{ | ||
| 232 | + name: "mlxserve", | ||
| 233 | + // `mlx-serve serve` binds 0.0.0.0:11234 by default, so the host's | ||
| 234 | + // name answers from a container or a sandbox without a flag. | ||
| 235 | + baseURL: "http://127.0.0.1:11234/v1", | ||
| 236 | + fallback: "http://host.docker.internal:11234/v1", | ||
| 237 | + // The server checks a key only when started with --api-key, and then | ||
| 238 | + // for every caller but localhost. mlx-serve reads it from no variable: | ||
| 239 | + // MLX_SERVE_API_KEY is mm's name for it. | ||
| 240 | + apiKeyEnv: "MLX_SERVE_API_KEY", | ||
| 241 | + dummyKey: "not-needed", | ||
| 242 | + startHint: "start it: mlx-serve serve (or open the MLX-Serve app)", | ||
| 243 | + notFoundHint: "mlx-serve pull %s", | ||
| 244 | + probe: probeMlxServe, | ||
| 245 | + // Measured 2026-11-24 on mlx-serve 26.11.3 (mlxserve.go): no | ||
| 246 | + // prompt_progress; reasoning off only with both switches off. | ||
| 247 | + progress: false, | ||
| 248 | + thinkingOff: thinkingOffBoth, | ||
| 249 | + unload: unloadMlxServe, | ||
| 250 | + pull: pullOllamaAPI, | ||
| 251 | + }) | ||
| 231 | } | 252 | } |
| 232 | 253 | ||
| 233 | func (p *openaiCompat) Name() string { return p.name } | 254 | func (p *openaiCompat) Name() string { return p.name } |
| @@ -337,7 +358,7 @@ func modelSupports() *ai.ModelSupports { | |||
| 337 | // last, next to the network: it records the request as it leaves, after the | 358 | // last, next to the network: it records the request as it leaves, after the |
| 338 | // others have added their fields, and the response before they read it. | 359 | // others have added their fields, and the response before they read it. |
| 339 | func middlewares(p *openaiCompat) []option.Middleware { | 360 | func middlewares(p *openaiCompat) []option.Middleware { |
| 340 | - chain := []option.Middleware{streamOptions(p.progress, p.thinkingOff), reasoningTap} | 361 | + chain := []option.Middleware{streamOptions(p.progress, p.thinkingOff), reasoningTap, dropSSEComments} |
| 341 | // toolFormat: xml_tools (ticket 207) goes first: Genkit then sees an | 362 | // toolFormat: xml_tools (ticket 207) goes first: Genkit then sees an |
| 342 | // ordinary tool call, and the trace records the request as rewritten. | 363 | // ordinary tool call, and the trace records the request as rewritten. |
| 343 | if config.Cfg.ToolFormat == config.ToolFormatXML { | 364 | if config.Cfg.ToolFormat == config.ToolFormatXML { |
modified
internal/engine/provider_test.go +6 -2 | @@ -75,14 +75,14 @@ func ptr(s string) *string { return &s } | ||
| 75 | 75 | // where DMR_BASE_URL is often exported. |
| 76 | 76 | func clearEnv(t *testing.T) { |
| 77 | 77 | t.Helper() |
| 78 | - for _, k := range []string{"AGENT_BASE_URL", "DMR_BASE_URL", "LLAMA_API_KEY", "LLMMAN_API_KEY", "OLLAMA_API_KEY", "KRONK_TOKEN", "OPENAI_API_KEY", "AGENT_PROVIDER", "AGENT_MODEL"} { | |
| 78 | + for _, k := range []string{"AGENT_BASE_URL", "DMR_BASE_URL", "LLAMA_API_KEY", "LLMMAN_API_KEY", "OLLAMA_API_KEY", "KRONK_TOKEN", "MLX_SERVE_API_KEY", "OPENAI_API_KEY", "AGENT_PROVIDER", "AGENT_MODEL"} { | |
| 79 | 79 | t.Setenv(k, "") |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | func TestLookupListsKnownProviders(t *testing.T) { |
| 84 | 84 | _, err := Lookup("vllm") |
| 85 | - if err == nil || !strings.Contains(err.Error(), "dmr, kronk, llamacpp, llmman, ollama, openai") { | |
| 85 | + if err == nil || !strings.Contains(err.Error(), "dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai") { | |
| 86 | 86 | t.Fatalf("Lookup(vllm) = %v, want an error naming the known providers", err) |
| 87 | 87 | } |
| 88 | 88 | } |
| @@ -124,6 +124,9 @@ func TestResolveURLPrecedence(t *testing.T) { | ||
| 124 | 124 | {"kronk falls back to the host's server", "kronk", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11435/v1", "not-needed"}, |
| 125 | 125 | {"kronk keeps a reachable baseUrl", "kronk", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"}, |
| 126 | 126 | {"kronk reads KRONK_TOKEN when set", "kronk", config.Config{BaseURL: up.URL}, map[string]string{"KRONK_TOKEN": "jwt", "OLLAMA_API_KEY": "k4"}, up.URL, "jwt"}, |
| 127 | + {"mlxserve falls back to the host's server", "mlxserve", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11234/v1", "not-needed"}, | |
| 128 | + {"mlxserve keeps a reachable baseUrl", "mlxserve", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"}, | |
| 129 | + {"mlxserve reads MLX_SERVE_API_KEY when set", "mlxserve", config.Config{BaseURL: up.URL}, map[string]string{"MLX_SERVE_API_KEY": "k5", "OLLAMA_API_KEY": "k4"}, up.URL, "k5"}, | |
| 127 | 130 | } |
| 128 | 131 | for _, tc := range cases { |
| 129 | 132 | t.Run(tc.name, func(t *testing.T) { |
| @@ -602,6 +605,7 @@ func TestDefaultURLs(t *testing.T) { | ||
| 602 | 605 | {"llmman", "http://127.0.0.1:17434/v1", "http://host.docker.internal:17434/v1"}, |
| 603 | 606 | {"ollama", "http://localhost:11434/v1", "http://host.docker.internal:11434/v1"}, |
| 604 | 607 | {"kronk", "http://127.0.0.1:11435/v1", "http://host.docker.internal:11435/v1"}, |
| 608 | + {"mlxserve", "http://127.0.0.1:11234/v1", "http://host.docker.internal:11234/v1"}, | |
| 605 | 609 | {"dmr", "http://localhost:12434/engines/v1", "http://host.docker.internal:12434/engines/v1"}, |
| 606 | 610 | {"llamacpp", "http://127.0.0.1:9931/v1", "http://host.docker.internal:9931/v1"}, |
| 607 | 611 | {"openai", "https://api.openai.com/v1", ""}, |
| @@ -75,14 +75,14 @@ func ptr(s string) *string { return &s } | |||
| 75 | // where DMR_BASE_URL is often exported. | 75 | // where DMR_BASE_URL is often exported. |
| 76 | func clearEnv(t *testing.T) { | 76 | func clearEnv(t *testing.T) { |
| 77 | t.Helper() | 77 | t.Helper() |
| 78 | - for _, k := range []string{"AGENT_BASE_URL", "DMR_BASE_URL", "LLAMA_API_KEY", "LLMMAN_API_KEY", "OLLAMA_API_KEY", "KRONK_TOKEN", "OPENAI_API_KEY", "AGENT_PROVIDER", "AGENT_MODEL"} { | 78 | + for _, k := range []string{"AGENT_BASE_URL", "DMR_BASE_URL", "LLAMA_API_KEY", "LLMMAN_API_KEY", "OLLAMA_API_KEY", "KRONK_TOKEN", "MLX_SERVE_API_KEY", "OPENAI_API_KEY", "AGENT_PROVIDER", "AGENT_MODEL"} { |
| 79 | t.Setenv(k, "") | 79 | t.Setenv(k, "") |
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | func TestLookupListsKnownProviders(t *testing.T) { | 83 | func TestLookupListsKnownProviders(t *testing.T) { |
| 84 | _, err := Lookup("vllm") | 84 | _, err := Lookup("vllm") |
| 85 | - if err == nil || !strings.Contains(err.Error(), "dmr, kronk, llamacpp, llmman, ollama, openai") { | 85 | + if err == nil || !strings.Contains(err.Error(), "dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai") { |
| 86 | t.Fatalf("Lookup(vllm) = %v, want an error naming the known providers", err) | 86 | t.Fatalf("Lookup(vllm) = %v, want an error naming the known providers", err) |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| @@ -124,6 +124,9 @@ func TestResolveURLPrecedence(t *testing.T) { | |||
| 124 | {"kronk falls back to the host's server", "kronk", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11435/v1", "not-needed"}, | 124 | {"kronk falls back to the host's server", "kronk", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11435/v1", "not-needed"}, |
| 125 | {"kronk keeps a reachable baseUrl", "kronk", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"}, | 125 | {"kronk keeps a reachable baseUrl", "kronk", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"}, |
| 126 | {"kronk reads KRONK_TOKEN when set", "kronk", config.Config{BaseURL: up.URL}, map[string]string{"KRONK_TOKEN": "jwt", "OLLAMA_API_KEY": "k4"}, up.URL, "jwt"}, | 126 | {"kronk reads KRONK_TOKEN when set", "kronk", config.Config{BaseURL: up.URL}, map[string]string{"KRONK_TOKEN": "jwt", "OLLAMA_API_KEY": "k4"}, up.URL, "jwt"}, |
| 127 | + {"mlxserve falls back to the host's server", "mlxserve", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11234/v1", "not-needed"}, | ||
| 128 | + {"mlxserve keeps a reachable baseUrl", "mlxserve", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"}, | ||
| 129 | + {"mlxserve reads MLX_SERVE_API_KEY when set", "mlxserve", config.Config{BaseURL: up.URL}, map[string]string{"MLX_SERVE_API_KEY": "k5", "OLLAMA_API_KEY": "k4"}, up.URL, "k5"}, | ||
| 127 | } | 130 | } |
| 128 | for _, tc := range cases { | 131 | for _, tc := range cases { |
| 129 | t.Run(tc.name, func(t *testing.T) { | 132 | t.Run(tc.name, func(t *testing.T) { |
| @@ -602,6 +605,7 @@ func TestDefaultURLs(t *testing.T) { | |||
| 602 | {"llmman", "http://127.0.0.1:17434/v1", "http://host.docker.internal:17434/v1"}, | 605 | {"llmman", "http://127.0.0.1:17434/v1", "http://host.docker.internal:17434/v1"}, |
| 603 | {"ollama", "http://localhost:11434/v1", "http://host.docker.internal:11434/v1"}, | 606 | {"ollama", "http://localhost:11434/v1", "http://host.docker.internal:11434/v1"}, |
| 604 | {"kronk", "http://127.0.0.1:11435/v1", "http://host.docker.internal:11435/v1"}, | 607 | {"kronk", "http://127.0.0.1:11435/v1", "http://host.docker.internal:11435/v1"}, |
| 608 | + {"mlxserve", "http://127.0.0.1:11234/v1", "http://host.docker.internal:11234/v1"}, | ||
| 605 | {"dmr", "http://localhost:12434/engines/v1", "http://host.docker.internal:12434/engines/v1"}, | 609 | {"dmr", "http://localhost:12434/engines/v1", "http://host.docker.internal:12434/engines/v1"}, |
| 606 | {"llamacpp", "http://127.0.0.1:9931/v1", "http://host.docker.internal:9931/v1"}, | 610 | {"llamacpp", "http://127.0.0.1:9931/v1", "http://host.docker.internal:9931/v1"}, |
| 607 | {"openai", "https://api.openai.com/v1", ""}, | 611 | {"openai", "https://api.openai.com/v1", ""}, |
added
internal/engine/ssecomments.go +102 -0 | new file mode 100644 | ||
| @@ -0,0 +1,102 @@ | ||
| 1 | +package engine | |
| 2 | + | |
| 3 | +import ( | |
| 4 | + "bytes" | |
| 5 | + "io" | |
| 6 | + "net/http" | |
| 7 | + "strings" | |
| 8 | + | |
| 9 | + "github.com/openai/openai-go/option" | |
| 10 | +) | |
| 11 | + | |
| 12 | +// A Server-Sent Events comment is a line that starts with ":". Servers send | |
| 13 | +// them to keep a quiet connection open — MLX-Serve writes `: keepalive` | |
| 14 | +// while it reads a long prompt (measured 2026-11-24, mlx-serve 26.11.3, the | |
| 15 | +// first request of every run). The SSE spec says to ignore them, and | |
| 16 | +// openai-go's decoder skips the line — but the blank line that ends the | |
| 17 | +// comment's block then dispatches an event with NO data, which the stream | |
| 18 | +// decodes as JSON: "unexpected end of JSON input", the stream is dropped and | |
| 19 | +// mm retries the call without streaming. dropSSEComments removes such | |
| 20 | +// comment-only blocks before the decoder sees them, for every provider: a | |
| 21 | +// server that sends none is unaffected. | |
| 22 | + | |
| 23 | +// dropSSEComments is the openai-go middleware: it wraps a streamed response's | |
| 24 | +// body in an sseCommentFilter and leaves everything else as it came. | |
| 25 | +func dropSSEComments(req *http.Request, next option.MiddlewareNext) (*http.Response, error) { | |
| 26 | + resp, err := next(req) | |
| 27 | + if err != nil || resp == nil || resp.Body == nil || !strings.Contains(resp.Header.Get("Content-Type"), "text/event-stream") { | |
| 28 | + return resp, err | |
| 29 | + } | |
| 30 | + resp.Body = &sseCommentFilter{rc: resp.Body} | |
| 31 | + return resp, nil | |
| 32 | +} | |
| 33 | + | |
| 34 | +// sseCommentFilter hands the stream on line by line, without the comment | |
| 35 | +// lines and without the blank line that would end a block made only of | |
| 36 | +// comments. A line is handed on as soon as its newline arrives, so nothing | |
| 37 | +// is delayed; the last bytes of a stream that does not end with a newline | |
| 38 | +// are handed on at EOF. | |
| 39 | +type sseCommentFilter struct { | |
| 40 | + rc io.ReadCloser | |
| 41 | + pending []byte // received, not yet a whole line | |
| 42 | + out []byte // filtered, not yet read | |
| 43 | + inBlock bool // the current block has a line that is not a comment | |
| 44 | + eof error | |
| 45 | +} | |
| 46 | + | |
| 47 | +func (f *sseCommentFilter) Read(p []byte) (int, error) { | |
| 48 | + for len(f.out) == 0 && f.eof == nil { | |
| 49 | + buf := make([]byte, 32*1024) | |
| 50 | + n, err := f.rc.Read(buf) | |
| 51 | + f.feed(buf[:n]) | |
| 52 | + if err != nil { | |
| 53 | + f.eof = err | |
| 54 | + f.out = append(f.out, f.pending...) | |
| 55 | + f.pending = nil | |
| 56 | + } | |
| 57 | + } | |
| 58 | + if len(f.out) == 0 { | |
| 59 | + return 0, f.eof | |
| 60 | + } | |
| 61 | + n := copy(p, f.out) | |
| 62 | + f.out = f.out[n:] | |
| 63 | + return n, nil | |
| 64 | +} | |
| 65 | + | |
| 66 | +func (f *sseCommentFilter) Close() error { return f.rc.Close() } | |
| 67 | + | |
| 68 | +// feed adds b to the pending bytes and moves every whole line that survives | |
| 69 | +// the filter to out. | |
| 70 | +func (f *sseCommentFilter) feed(b []byte) { | |
| 71 | + f.pending = append(f.pending, b...) | |
| 72 | + for { | |
| 73 | + i := bytes.IndexByte(f.pending, '\n') | |
| 74 | + if i < 0 { | |
| 75 | + return | |
| 76 | + } | |
| 77 | + line := f.pending[:i+1] | |
| 78 | + f.pending = f.pending[i+1:] | |
| 79 | + if f.keep(bytes.TrimRight(line, "\r\n")) { | |
| 80 | + f.out = append(f.out, line...) | |
| 81 | + } | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 85 | +// keep says whether a line (without its line ending) goes on. | |
| 86 | +// | |
| 87 | +// ": keepalive" → false (a comment) | |
| 88 | +// "" → true only when the block it ends had something else | |
| 89 | +// "data: {…}" → true | |
| 90 | +func (f *sseCommentFilter) keep(line []byte) bool { | |
| 91 | + switch { | |
| 92 | + case len(line) == 0: | |
| 93 | + kept := f.inBlock | |
| 94 | + f.inBlock = false | |
| 95 | + return kept | |
| 96 | + case line[0] == ':': | |
| 97 | + return false | |
| 98 | + default: | |
| 99 | + f.inBlock = true | |
| 100 | + return true | |
| 101 | + } | |
| 102 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | +package engine | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "bytes" | ||
| 5 | + "io" | ||
| 6 | + "net/http" | ||
| 7 | + "strings" | ||
| 8 | + | ||
| 9 | + "github.com/openai/openai-go/option" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +// A Server-Sent Events comment is a line that starts with ":". Servers send | ||
| 13 | +// them to keep a quiet connection open — MLX-Serve writes `: keepalive` | ||
| 14 | +// while it reads a long prompt (measured 2026-11-24, mlx-serve 26.11.3, the | ||
| 15 | +// first request of every run). The SSE spec says to ignore them, and | ||
| 16 | +// openai-go's decoder skips the line — but the blank line that ends the | ||
| 17 | +// comment's block then dispatches an event with NO data, which the stream | ||
| 18 | +// decodes as JSON: "unexpected end of JSON input", the stream is dropped and | ||
| 19 | +// mm retries the call without streaming. dropSSEComments removes such | ||
| 20 | +// comment-only blocks before the decoder sees them, for every provider: a | ||
| 21 | +// server that sends none is unaffected. | ||
| 22 | + | ||
| 23 | +// dropSSEComments is the openai-go middleware: it wraps a streamed response's | ||
| 24 | +// body in an sseCommentFilter and leaves everything else as it came. | ||
| 25 | +func dropSSEComments(req *http.Request, next option.MiddlewareNext) (*http.Response, error) { | ||
| 26 | + resp, err := next(req) | ||
| 27 | + if err != nil || resp == nil || resp.Body == nil || !strings.Contains(resp.Header.Get("Content-Type"), "text/event-stream") { | ||
| 28 | + return resp, err | ||
| 29 | + } | ||
| 30 | + resp.Body = &sseCommentFilter{rc: resp.Body} | ||
| 31 | + return resp, nil | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +// sseCommentFilter hands the stream on line by line, without the comment | ||
| 35 | +// lines and without the blank line that would end a block made only of | ||
| 36 | +// comments. A line is handed on as soon as its newline arrives, so nothing | ||
| 37 | +// is delayed; the last bytes of a stream that does not end with a newline | ||
| 38 | +// are handed on at EOF. | ||
| 39 | +type sseCommentFilter struct { | ||
| 40 | + rc io.ReadCloser | ||
| 41 | + pending []byte // received, not yet a whole line | ||
| 42 | + out []byte // filtered, not yet read | ||
| 43 | + inBlock bool // the current block has a line that is not a comment | ||
| 44 | + eof error | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +func (f *sseCommentFilter) Read(p []byte) (int, error) { | ||
| 48 | + for len(f.out) == 0 && f.eof == nil { | ||
| 49 | + buf := make([]byte, 32*1024) | ||
| 50 | + n, err := f.rc.Read(buf) | ||
| 51 | + f.feed(buf[:n]) | ||
| 52 | + if err != nil { | ||
| 53 | + f.eof = err | ||
| 54 | + f.out = append(f.out, f.pending...) | ||
| 55 | + f.pending = nil | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + if len(f.out) == 0 { | ||
| 59 | + return 0, f.eof | ||
| 60 | + } | ||
| 61 | + n := copy(p, f.out) | ||
| 62 | + f.out = f.out[n:] | ||
| 63 | + return n, nil | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +func (f *sseCommentFilter) Close() error { return f.rc.Close() } | ||
| 67 | + | ||
| 68 | +// feed adds b to the pending bytes and moves every whole line that survives | ||
| 69 | +// the filter to out. | ||
| 70 | +func (f *sseCommentFilter) feed(b []byte) { | ||
| 71 | + f.pending = append(f.pending, b...) | ||
| 72 | + for { | ||
| 73 | + i := bytes.IndexByte(f.pending, '\n') | ||
| 74 | + if i < 0 { | ||
| 75 | + return | ||
| 76 | + } | ||
| 77 | + line := f.pending[:i+1] | ||
| 78 | + f.pending = f.pending[i+1:] | ||
| 79 | + if f.keep(bytes.TrimRight(line, "\r\n")) { | ||
| 80 | + f.out = append(f.out, line...) | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +// keep says whether a line (without its line ending) goes on. | ||
| 86 | +// | ||
| 87 | +// ": keepalive" → false (a comment) | ||
| 88 | +// "" → true only when the block it ends had something else | ||
| 89 | +// "data: {…}" → true | ||
| 90 | +func (f *sseCommentFilter) keep(line []byte) bool { | ||
| 91 | + switch { | ||
| 92 | + case len(line) == 0: | ||
| 93 | + kept := f.inBlock | ||
| 94 | + f.inBlock = false | ||
| 95 | + return kept | ||
| 96 | + case line[0] == ':': | ||
| 97 | + return false | ||
| 98 | + default: | ||
| 99 | + f.inBlock = true | ||
| 100 | + return true | ||
| 101 | + } | ||
| 102 | +} | ||
added
internal/engine/ssecomments_test.go +72 -0 | new file mode 100644 | ||
| @@ -0,0 +1,72 @@ | ||
| 1 | +package engine | |
| 2 | + | |
| 3 | +import ( | |
| 4 | + "io" | |
| 5 | + "net/http" | |
| 6 | + "strings" | |
| 7 | + "testing" | |
| 8 | + "testing/iotest" | |
| 9 | + | |
| 10 | + "github.com/openai/openai-go" | |
| 11 | + "github.com/openai/openai-go/packages/ssestream" | |
| 12 | +) | |
| 13 | + | |
| 14 | +// The stream MLX-Serve sends while it reads a prompt (trace of 2026-11-24): | |
| 15 | +// a first chunk, then a comment-only block, then the answer. | |
| 16 | +const keepaliveStream = "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"}}]}\n\n" + | |
| 17 | + ": keepalive\n\n" + | |
| 18 | + ": keepalive\r\n\r\n" + | |
| 19 | + "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"}}]}\n" + | |
| 20 | + ": a comment inside a block\n\n" + | |
| 21 | + "data: [DONE]\n\n" | |
| 22 | + | |
| 23 | +// The comment-only blocks go, the data and the blank lines that end them | |
| 24 | +// stay — whatever size the reads come in. | |
| 25 | +func TestSSECommentFilter(t *testing.T) { | |
| 26 | + want := "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"}}]}\n\n" + | |
| 27 | + "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"}}]}\n\n" + | |
| 28 | + "data: [DONE]\n\n" | |
| 29 | + for name, r := range map[string]io.Reader{ | |
| 30 | + "whole": strings.NewReader(keepaliveStream), | |
| 31 | + "byte by byte": iotest.OneByteReader(strings.NewReader(keepaliveStream)), | |
| 32 | + } { | |
| 33 | + got, err := io.ReadAll(&sseCommentFilter{rc: io.NopCloser(r)}) | |
| 34 | + if err != nil || string(got) != want { | |
| 35 | + t.Errorf("%s: %q, %v\nwant %q", name, got, err, want) | |
| 36 | + } | |
| 37 | + } | |
| 38 | + // A last line with no newline is not lost. | |
| 39 | + got, _ := io.ReadAll(&sseCommentFilter{rc: io.NopCloser(strings.NewReader("data: x"))}) | |
| 40 | + if string(got) != "data: x" { | |
| 41 | + t.Errorf("unterminated last line: %q", got) | |
| 42 | + } | |
| 43 | +} | |
| 44 | + | |
| 45 | +// The bug itself: openai-go's decoder fails on the keepalive block | |
| 46 | +// ("unexpected end of JSON input") and reads the whole stream once the | |
| 47 | +// middleware has removed it. | |
| 48 | +func TestDropSSECommentsLetsOpenAIGoReadTheStream(t *testing.T) { | |
| 49 | + read := func(body io.ReadCloser) (string, error) { | |
| 50 | + resp := &http.Response{Header: http.Header{"Content-Type": {"text/event-stream"}}, Body: body} | |
| 51 | + s := ssestream.NewStream[openai.ChatCompletionChunk](ssestream.NewDecoder(resp), nil) | |
| 52 | + text := "" | |
| 53 | + for s.Next() { | |
| 54 | + if c := s.Current(); len(c.Choices) > 0 { | |
| 55 | + text += c.Choices[0].Delta.Content | |
| 56 | + } | |
| 57 | + } | |
| 58 | + return text, s.Err() | |
| 59 | + } | |
| 60 | + if _, err := read(io.NopCloser(strings.NewReader(keepaliveStream))); err == nil { | |
| 61 | + t.Log("openai-go now reads SSE comments: dropSSEComments may no longer be needed") | |
| 62 | + } | |
| 63 | + resp, err := dropSSEComments(&http.Request{}, func(*http.Request) (*http.Response, error) { | |
| 64 | + return &http.Response{Header: http.Header{"Content-Type": {"text/event-stream"}}, Body: io.NopCloser(strings.NewReader(keepaliveStream))}, nil | |
| 65 | + }) | |
| 66 | + if err != nil { | |
| 67 | + t.Fatal(err) | |
| 68 | + } | |
| 69 | + if text, err := read(resp.Body); err != nil || text != "Hello" { | |
| 70 | + t.Errorf("filtered: %q, %v; want Hello and no error", text, err) | |
| 71 | + } | |
| 72 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | +package engine | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "io" | ||
| 5 | + "net/http" | ||
| 6 | + "strings" | ||
| 7 | + "testing" | ||
| 8 | + "testing/iotest" | ||
| 9 | + | ||
| 10 | + "github.com/openai/openai-go" | ||
| 11 | + "github.com/openai/openai-go/packages/ssestream" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +// The stream MLX-Serve sends while it reads a prompt (trace of 2026-11-24): | ||
| 15 | +// a first chunk, then a comment-only block, then the answer. | ||
| 16 | +const keepaliveStream = "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"}}]}\n\n" + | ||
| 17 | + ": keepalive\n\n" + | ||
| 18 | + ": keepalive\r\n\r\n" + | ||
| 19 | + "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"}}]}\n" + | ||
| 20 | + ": a comment inside a block\n\n" + | ||
| 21 | + "data: [DONE]\n\n" | ||
| 22 | + | ||
| 23 | +// The comment-only blocks go, the data and the blank lines that end them | ||
| 24 | +// stay — whatever size the reads come in. | ||
| 25 | +func TestSSECommentFilter(t *testing.T) { | ||
| 26 | + want := "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"}}]}\n\n" + | ||
| 27 | + "data: {\"id\":\"c\",\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"}}]}\n\n" + | ||
| 28 | + "data: [DONE]\n\n" | ||
| 29 | + for name, r := range map[string]io.Reader{ | ||
| 30 | + "whole": strings.NewReader(keepaliveStream), | ||
| 31 | + "byte by byte": iotest.OneByteReader(strings.NewReader(keepaliveStream)), | ||
| 32 | + } { | ||
| 33 | + got, err := io.ReadAll(&sseCommentFilter{rc: io.NopCloser(r)}) | ||
| 34 | + if err != nil || string(got) != want { | ||
| 35 | + t.Errorf("%s: %q, %v\nwant %q", name, got, err, want) | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + // A last line with no newline is not lost. | ||
| 39 | + got, _ := io.ReadAll(&sseCommentFilter{rc: io.NopCloser(strings.NewReader("data: x"))}) | ||
| 40 | + if string(got) != "data: x" { | ||
| 41 | + t.Errorf("unterminated last line: %q", got) | ||
| 42 | + } | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +// The bug itself: openai-go's decoder fails on the keepalive block | ||
| 46 | +// ("unexpected end of JSON input") and reads the whole stream once the | ||
| 47 | +// middleware has removed it. | ||
| 48 | +func TestDropSSECommentsLetsOpenAIGoReadTheStream(t *testing.T) { | ||
| 49 | + read := func(body io.ReadCloser) (string, error) { | ||
| 50 | + resp := &http.Response{Header: http.Header{"Content-Type": {"text/event-stream"}}, Body: body} | ||
| 51 | + s := ssestream.NewStream[openai.ChatCompletionChunk](ssestream.NewDecoder(resp), nil) | ||
| 52 | + text := "" | ||
| 53 | + for s.Next() { | ||
| 54 | + if c := s.Current(); len(c.Choices) > 0 { | ||
| 55 | + text += c.Choices[0].Delta.Content | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + return text, s.Err() | ||
| 59 | + } | ||
| 60 | + if _, err := read(io.NopCloser(strings.NewReader(keepaliveStream))); err == nil { | ||
| 61 | + t.Log("openai-go now reads SSE comments: dropSSEComments may no longer be needed") | ||
| 62 | + } | ||
| 63 | + resp, err := dropSSEComments(&http.Request{}, func(*http.Request) (*http.Response, error) { | ||
| 64 | + return &http.Response{Header: http.Header{"Content-Type": {"text/event-stream"}}, Body: io.NopCloser(strings.NewReader(keepaliveStream))}, nil | ||
| 65 | + }) | ||
| 66 | + if err != nil { | ||
| 67 | + t.Fatal(err) | ||
| 68 | + } | ||
| 69 | + if text, err := read(resp.Body); err != nil || text != "Hello" { | ||
| 70 | + t.Errorf("filtered: %q, %v; want Hello and no error", text, err) | ||
| 71 | + } | ||
| 72 | +} | ||
modified
internal/engine/usage.go +25 -13 | @@ -67,6 +67,12 @@ const ( | ||
| 67 | 67 | thinkingOffTemplate |
| 68 | 68 | // thinkingOffEffort: reasoning_effort = "none" (Ollama). |
| 69 | 69 | thinkingOffEffort |
| 70 | + // thinkingOffBoth: both of the above at once (MLX-Serve). That server | |
| 71 | + // reasons when EITHER switch says so (measured 2026-11-24, mlx-serve | |
| 72 | + // 26.11.3, Gemma 4 E4B): enable_thinking:false alone is overruled by a | |
| 73 | + // reasoning_effort "high" from the sampling, and reasoning_effort "none" | |
| 74 | + // alone by an enable_thinking:true. Only both off turn it off. | |
| 75 | + thinkingOffBoth | |
| 70 | 76 | ) |
| 71 | 77 | |
| 72 | 78 | // noThinkKey is the context key marking a request whose reasoning is off. |
| @@ -143,23 +149,14 @@ func withoutReasoning(body []byte, off thinkingOff) []byte { | ||
| 143 | 149 | if off == thinkingOffUnknown || json.Unmarshal(body, &m) != nil { |
| 144 | 150 | return body |
| 145 | 151 | } |
| 146 | - switch off { | |
| 147 | - case thinkingOffTemplate: | |
| 148 | - var kw map[string]any | |
| 149 | - if json.Unmarshal(m["chat_template_kwargs"], &kw) != nil || kw == nil { | |
| 150 | - kw = map[string]any{} | |
| 151 | - } | |
| 152 | - kw["enable_thinking"] = false | |
| 153 | - // gpt-oss's template has no "off": low is the least it reasons. | |
| 154 | - if _, set := kw["reasoning_effort"]; set { | |
| 155 | - kw["reasoning_effort"] = "low" | |
| 156 | - } | |
| 157 | - raw, err := json.Marshal(kw) | |
| 152 | + if off == thinkingOffTemplate || off == thinkingOffBoth { | |
| 153 | + raw, err := templateWithoutThinking(m["chat_template_kwargs"]) | |
| 158 | 154 | if err != nil { |
| 159 | 155 | return body |
| 160 | 156 | } |
| 161 | 157 | m["chat_template_kwargs"] = raw |
| 162 | - case thinkingOffEffort: | |
| 158 | + } | |
| 159 | + if off == thinkingOffEffort || off == thinkingOffBoth { | |
| 163 | 160 | m["reasoning_effort"] = json.RawMessage(`"none"`) |
| 164 | 161 | } |
| 165 | 162 | out, err := json.Marshal(m) |
| @@ -168,3 +165,18 @@ func withoutReasoning(body []byte, off thinkingOff) []byte { | ||
| 168 | 165 | } |
| 169 | 166 | return out |
| 170 | 167 | } |
| 168 | + | |
| 169 | +// templateWithoutThinking returns the chat_template_kwargs object `raw` with | |
| 170 | +// enable_thinking set to false, its other variables kept. | |
| 171 | +func templateWithoutThinking(raw json.RawMessage) (json.RawMessage, error) { | |
| 172 | + var kw map[string]any | |
| 173 | + if json.Unmarshal(raw, &kw) != nil || kw == nil { | |
| 174 | + kw = map[string]any{} | |
| 175 | + } | |
| 176 | + kw["enable_thinking"] = false | |
| 177 | + // gpt-oss's template has no "off": low is the least it reasons. | |
| 178 | + if _, set := kw["reasoning_effort"]; set { | |
| 179 | + kw["reasoning_effort"] = "low" | |
| 180 | + } | |
| 181 | + return json.Marshal(kw) | |
| 182 | +} | |
| @@ -67,6 +67,12 @@ const ( | |||
| 67 | thinkingOffTemplate | 67 | thinkingOffTemplate |
| 68 | // thinkingOffEffort: reasoning_effort = "none" (Ollama). | 68 | // thinkingOffEffort: reasoning_effort = "none" (Ollama). |
| 69 | thinkingOffEffort | 69 | thinkingOffEffort |
| 70 | + // thinkingOffBoth: both of the above at once (MLX-Serve). That server | ||
| 71 | + // reasons when EITHER switch says so (measured 2026-11-24, mlx-serve | ||
| 72 | + // 26.11.3, Gemma 4 E4B): enable_thinking:false alone is overruled by a | ||
| 73 | + // reasoning_effort "high" from the sampling, and reasoning_effort "none" | ||
| 74 | + // alone by an enable_thinking:true. Only both off turn it off. | ||
| 75 | + thinkingOffBoth | ||
| 70 | ) | 76 | ) |
| 71 | 77 | ||
| 72 | // noThinkKey is the context key marking a request whose reasoning is off. | 78 | // noThinkKey is the context key marking a request whose reasoning is off. |
| @@ -143,23 +149,14 @@ func withoutReasoning(body []byte, off thinkingOff) []byte { | |||
| 143 | if off == thinkingOffUnknown || json.Unmarshal(body, &m) != nil { | 149 | if off == thinkingOffUnknown || json.Unmarshal(body, &m) != nil { |
| 144 | return body | 150 | return body |
| 145 | } | 151 | } |
| 146 | - switch off { | 152 | + if off == thinkingOffTemplate || off == thinkingOffBoth { |
| 147 | - case thinkingOffTemplate: | 153 | + raw, err := templateWithoutThinking(m["chat_template_kwargs"]) |
| 148 | - var kw map[string]any | ||
| 149 | - if json.Unmarshal(m["chat_template_kwargs"], &kw) != nil || kw == nil { | ||
| 150 | - kw = map[string]any{} | ||
| 151 | - } | ||
| 152 | - kw["enable_thinking"] = false | ||
| 153 | - // gpt-oss's template has no "off": low is the least it reasons. | ||
| 154 | - if _, set := kw["reasoning_effort"]; set { | ||
| 155 | - kw["reasoning_effort"] = "low" | ||
| 156 | - } | ||
| 157 | - raw, err := json.Marshal(kw) | ||
| 158 | if err != nil { | 154 | if err != nil { |
| 159 | return body | 155 | return body |
| 160 | } | 156 | } |
| 161 | m["chat_template_kwargs"] = raw | 157 | m["chat_template_kwargs"] = raw |
| 162 | - case thinkingOffEffort: | 158 | + } |
| 159 | + if off == thinkingOffEffort || off == thinkingOffBoth { | ||
| 163 | m["reasoning_effort"] = json.RawMessage(`"none"`) | 160 | m["reasoning_effort"] = json.RawMessage(`"none"`) |
| 164 | } | 161 | } |
| 165 | out, err := json.Marshal(m) | 162 | out, err := json.Marshal(m) |
| @@ -168,3 +165,18 @@ func withoutReasoning(body []byte, off thinkingOff) []byte { | |||
| 168 | } | 165 | } |
| 169 | return out | 166 | return out |
| 170 | } | 167 | } |
| 168 | + | ||
| 169 | +// templateWithoutThinking returns the chat_template_kwargs object `raw` with | ||
| 170 | +// enable_thinking set to false, its other variables kept. | ||
| 171 | +func templateWithoutThinking(raw json.RawMessage) (json.RawMessage, error) { | ||
| 172 | + var kw map[string]any | ||
| 173 | + if json.Unmarshal(raw, &kw) != nil || kw == nil { | ||
| 174 | + kw = map[string]any{} | ||
| 175 | + } | ||
| 176 | + kw["enable_thinking"] = false | ||
| 177 | + // gpt-oss's template has no "off": low is the least it reasons. | ||
| 178 | + if _, set := kw["reasoning_effort"]; set { | ||
| 179 | + kw["reasoning_effort"] = "low" | ||
| 180 | + } | ||
| 181 | + return json.Marshal(kw) | ||
| 182 | +} | ||