Managed OLLAMA_DEBUG toggle for per-request context tracing #280

Closed
opened 2026-06-09 05:01:01 +00:00 by coilysiren · 0 comments
Owner

Make OLLAMA_DEBUG a managed toggle on the ollama role so per-request context usage is traceable from the server log.

Why

Tracing context usage during the OpenCode/Qwen-3 eval. With OLLAMA_DEBUG=1, /opt/homebrew/var/log/ollama.log records per-request prompt_eval/eval_count and - most useful - prompt-cache hit/miss (cache.go msg="cache miss" total=N matched=M). The matched= field directly explains the 3s (cache hit) vs 3min (cold prefill) first-turn behaviour.

Change

  • Refactor the keep-alive plist task into a generic ollama_service_env dict loop (idempotent add/set + drift-only reload), so additional env keys ride the same path.
  • New ollama_debug toggle (role default false, true for the mac group). On-path pins OLLAMA_DEBUG=1; symmetric off-path deletes the key. Additive - leaves the flash-attention / kv-cache perf vars alone.

Caveat

The brew ollama log is unrotated, so debug is a deliberate opt-in, not a permanent default. If left on long-term, add a newsyslog/logrotate rule.

Builds on #279 (the env-management mechanism).

Make `OLLAMA_DEBUG` a managed toggle on the ollama role so per-request context usage is traceable from the server log. ## Why Tracing context usage during the OpenCode/Qwen-3 eval. With `OLLAMA_DEBUG=1`, `/opt/homebrew/var/log/ollama.log` records per-request `prompt_eval`/`eval_count` and - most useful - prompt-cache hit/miss (`cache.go msg="cache miss" total=N matched=M`). The `matched=` field directly explains the 3s (cache hit) vs 3min (cold prefill) first-turn behaviour. ## Change - Refactor the keep-alive plist task into a generic `ollama_service_env` dict loop (idempotent add/set + drift-only reload), so additional env keys ride the same path. - New `ollama_debug` toggle (role default `false`, `true` for the mac group). On-path pins `OLLAMA_DEBUG=1`; symmetric off-path deletes the key. Additive - leaves the flash-attention / kv-cache perf vars alone. ## Caveat The brew ollama log is unrotated, so debug is a deliberate opt-in, not a permanent default. If left on long-term, add a newsyslog/logrotate rule. Builds on https://forgejo.coilysiren.me/coilyco-flight-deck/infrastructure/issues/279 (the env-management mechanism).
Sign in to join this conversation.
No description provided.