my-homelab-configs/docs/doctor-context-lab.md

5.6 KiB

Doctor context benchmark

The optional Headroom lab replays one saved Holmes decision. It never executes the model's proposed tools and does not change production Doctor compression. Use it to compare inference and context handling; it is not an end-to-end remediation benchmark or a substitute for diagnostic review.

Run on Debian

First capture the baseline with a saved private Holmes conversation.json:

./jeannie ai-lab doctor-context-bench baseline /absolute/path/to/conversation.json 3

The default is three repeats; one to five are supported. The last final answer is removed, while preceding evidence and tool results are retained. The replay uses the current local Doctor proxy and a compatible Bash schema with qwen2.5-coder:7b; it does not launch Holmes or execute Bash. Native proxy sampling defaults apply. Do not compare different inference models/settings as if compression alone caused a change.

The command prints a private baseline report path. Then install Headroom into its own virtual environment and compare against that exact saved request:

./jeannie ai-lab headroom-install
./jeannie ai-lab doctor-context-bench compare /absolute/path/to/baseline/report.json

Headroom is pinned to headroom-ai==0.45.0; installation downloads Python dependencies into the AI lab's headroom-venv, without changing Holmes's environment. Comparisons re-execute using that venv. JEANNIE_AI_LAB_DIR can override the default ~/.local/share/homelab/ai-lab directory. A context-lab lock prevents overlapping benchmark commands; separately avoid other Ollama workloads during measurement.

Compression policy

The initial experiment uses Headroom's mode=agent, lossless verification, offline operation and disabled model-based compression. Only tool content may change. System/user messages, tool-call IDs, tool names, arguments, ordering and other metadata must remain unchanged. An unverified or incompatible compression result is an error, not a successful optimized run. No retrieval tool is injected. Zero savings is a valid outcome.

Headroom uses gpt-4o only as a lightweight token-count estimator, avoiding Qwen tokenizer/model downloads. This does not change the inference model. Estimated compression counts are labeled separately from actual Ollama counts.

Reports and interpretation

Reports are private JSON files under the lab's reports/doctor-context-* directory. They contain the frozen request and responses, so keep them private: the original conversation may contain operational data. Each report records request and proxy source hashes. Compare reuses the original repeat count and includes baseline responses rather than rerunning every engine.

Captured fields include actual prompt/completion counts, raw nanosecond durations, model load and evaluation timings, stop reason, each retry request, compression time, schema validity, and total elapsed time. Aggregate model durations are converted to seconds; missing measurements stay null. Inspect the proxy hashes when comparing a baseline produced by older code. Prompt caches, cold loading and stochastic generation can affect timings; these runs are exploratory measurements, not a statistically controlled performance claim.

Review whether the same observed facts, uncertainty, resource identities and supported next step survive. A valid tool-call schema does not prove a correct diagnosis, a suitable command, or a completed repair. No automatic quality score is assigned by this benchmark.

Production local Holmes repair now also writes ollama-metrics.jsonl in its existing private doctor-k8s/repair.* artifact directory. It records per-call counts, durations and reasons without prompts or tool output. The proxy preserves OpenAI-style usage and maps Ollama length termination to length, while retaining the original reason under ollama.done_reason. Streaming responses include usage and Ollama metadata in their final chunk. Headroom remains confined to this explicit lab command.

Initial Debian measurement, December 2, 2026

The attempted live doctor cluster n8n --ai baseline exited with code 2 because the selected item could not be resolved. It is not an inference measurement. A saved Holmes conversation (repair.FtxkUhg4/conversation.json) was therefore used for two decision replays before the adapter changes and two with Headroom.

Measurement Uncompressed baseline Headroom lossless tool mode
Actual prompt tokens per request 10,420 10,420
Elapsed seconds by repeat 236.13; 1.10 175.91; 0.53
Completion tokens across both repeats 6 1,025
Stop reasons stop; stop length; stop
Schema-valid proposed tool decisions 0 / 2 0 / 2

Headroom's estimator reported 9,917 tokens before and after, with lossless verification. This input produced no compression benefit. Baseline responses were whitespace; neither configuration established a usable tool decision. Differences in model loading, prompt caching and stochastic output make these elapsed times unsuitable as a compression speedup claim. The second variant also uses the instrumented proxy; source hashes are recorded for both.

Private reports on Debian:

  • Baseline: ~/.local/share/homelab/ai-lab/reports/doctor-context-20261203T022655Z-f9522757/report.json
  • Comparison: ~/.local/share/homelab/ai-lab/reports/doctor-context-20261203T023135Z-122b9f1e/report.json

Directory timestamps use UTC; this measurement was taken on December 2 in America/Mexico_City. These are a single-case exploratory benchmark, not an assessment of Headroom across all Doctor workloads. Production compression remains disabled.