From d2588d521b304d0141cfba1f5c8dd4ec50492097 Mon Sep 17 00:00:00 2001 From: Agando Date: Tue, 27 Oct 2026 17:08:42 +0100 Subject: fix(newos4): send num_ctx to Ollama, and make one auto-connect failure read as one line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two things I had flagged as "worth your attention" and one leftover nit. - num_ctx was never sent. Ollama's server-side default context is 2k-4k depending on the build, so a system prompt + 20 messages + up to 24k chars of tool results could be truncated server-side, which is exactly the "it forgot what it just read" class of report. Every Ollama request now carries options.num_ctx (default 16384, overridable via webx11_ollama_numctx, floor 512); the OpenAI-compatible branch is untouched because num_ctx is not one of its parameters. - Automatic connect prints one outcome instead of one line per endpoint tried (7 -> 3 on a dead endpoint). Interactive `ollamaconnect` keeps the per-endpoint detail. - write_file's failure message no longer echoes a trailing slash. Verification: - test-ollama-numctx.js (7 asserts): generate and chat payloads carry num_ctx=16384, a stored override is used, junk/too-small values fall back, and the /v1/chat/completions branch does not receive it. RED on HEAD: TypeError reading 'num_ctx' of undefined. Suite 20/20. - Live v4.6.117, capturing the real request: {"num_ctx":16384} on /api/generate with model gemma4:31b-cloud, reply "OK". - Live v4.6.118, dead endpoint (127.0.0.1:9, fallback disabled): automatic -> 3 lines ("connecting on first use…", "Connecting to dead…", "Auto-connect failed — …"); manual connect() -> 4 lines including "endpoint http://127.0.0.1:9 failed", so the suppression is conditional, not blanket. --- main.html | 6 +-- modules/core/core-bundle.js | 38 +++++++++++---- modules/core/module-aiassist.js | 2 +- modules/core/module-loader.js | 2 +- modules/core/ollama-manager.js | 36 +++++++++++---- modules/test/test-ollama-numctx.js | 95 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 155 insertions(+), 24 deletions(-) create mode 100644 modules/test/test-ollama-numctx.js diff --git a/main.html b/main.html index e32de6e..872e3cf 100644 --- a/main.html +++ b/main.html @@ -1349,13 +1349,13 @@ - + - + - +