strix icon indicating copy to clipboard operation
strix copied to clipboard

Docs: Prevent context clipping issues with local models

Open 0xallam opened this issue 10 months ago • 3 comments

Improve Strix docs for running local models (especially Ollama) to clearly explain context window sizing. Many users run with very limited context to save VRAM, and Ollama often defaults to ~4096 context unless configured otherwise, which makes Strix unreliable/unusable.

0xallam avatar Jan 21 '26 19:01 0xallam

Hi! I'd like to work on this.

Proposed scope for the docs update:

  1. Minimum context window requirements -- document the recommended context size for each scan mode (quick / standard / deep) based on observed agent behavior
  2. Ollama configuration -- show how to set num_ctx via Modelfile or API parameter, and explain why the default ~4096 is insufficient
  3. Other local model runtimes -- cover LM Studio and llama.cpp equivalents for users not on Ollama
  4. Symptoms of context clipping -- help users recognize when context is too small (e.g., agents looping, incomplete tool calls, mid-scan failures) so they can self-diagnose
  5. Hardware guidance -- rough VRAM requirements per context size to set expectations

I'd add this as a new page in the docs (e.g., docs/llm-providers/local-models.md or as a section under the existing local model provider page) -- happy to follow whatever structure fits best.

Would it be okay to submit a PR for this?

mason5052 avatar Feb 23 '26 19:02 mason5052

The documentation could also do with some explanation of how the default memory compressor works as from what i can tell its set pretty high and isn't currently controllable by the user. This results in continuous out of context errors which then become non-recoverable as you can't restart the same agent as just keeps trying to load a context which if far to large and just keeps failing.

AkikoOrenji avatar Jun 02 '26 23:06 AkikoOrenji

I hit this today running Strix against a local target with qwen3.5:4b via Ollama, and traced the exact mechanism — might help close out the docs scope discussed above.

Root cause, precisely: Ollama's llama_server.go truncates the input prompt to roughly half of num_ctx (I measured limit = num_ctx/2 + 2, e.g. num_ctx=32768 → limit=16386), keeping only n_keep tokens from the start (default 4) plus the tail. Strix's system prompt (tool catalog + skills) sits at the very start of the prompt — so once the full prompt exceeds that half-of-num_ctx limit, the tool definitions are the first thing cut. The model never "refuses" to use tools; it never receives them.

Symptom on the Strix side: every turn ends NextStepFinalOutput with zero tool_calls, indistinguishable from a model that just doesn't support tool-calling — until you check journalctl -u ollama (or equivalent) for "truncating input prompt".

I confirmed this with an A/B: same model, same scan, only num_ctx changed (32768 → 65536, matched to roughly 2× the observed prompt size). At 32k: 8/8 turns exhausted, zero real tool_calls, truncating input prompt on every single attempt. At 65k: prompt arrived intact, zero truncation, and the model produced structured tool_calls normally (including multi-agent coordination — create_agent/wait_for_agents).

Practical rule of thumb for the docs: num_ctx needs to be roughly 2× the expected prompt size, not just "big enough for the prompt" — because of how Ollama reserves the other half. Worth noting since Strix's own system prompt (skills + ~30 tools) can be 15-20k tokens before any target-specific content, so even a trivial target can need a surprisingly large num_ctx.

Two more things I ran into that might be worth a line in the same doc:

  • With a large num_ctx, plain prefill on CPU can take longer than LLM_STREAM_IDLE_TIMEOUT's default — since prefill emits no stream events, the client-side idle watchdog can fire on a request that's still being served correctly server-side (confirmed via llama-server's own print_timing logs continuing after Strix logged "abandoning the turn"). Reused KV cache means retries usually recover fast, but it's a footgun worth flagging next to the num_ctx guidance.
  • Multi-agent scans (root + child agents) can issue concurrent LLM calls; against a single-slot local backend (n_slots=1, Ollama's default) these serialize, and if the wait exceeds the idle timeout, both the queued and the in-flight request can time out together and get cancelled (not gracefully retried) — worth a note if the docs cover multi-agent local setups.

Happy to turn this into a PR against the docs if useful — I have the full log trail if it helps.

FabioLeitao avatar Aug 09 '26 04:08 FabioLeitao