# imp tutorial routing: gateway run receipts Three patches to `research/tutorial_ticket_routing_experiment.exs` (imp 0.18.1, commit `748317d`), and the artifacts the patched script produced when it was run against live models it was not written for. Two defects were found by running the code, not by reading it, and one limitation of the tutorial's own claim is recorded at the end. ## Applying ```sh git clone https://github.com/deepfates/imp && cd imp git checkout 748317d git am /path/to/patches/*.patch ``` Patch 1 honours the `OPENROUTER_MODEL` variable the script's own header documents, and derives the receipt's `model` field from the resolved route instead of writing a literal. Patch 2 adds `IMP_LM_BASE_URL`, `IMP_LM_HEADERS` and `IMP_LM_KEY_FILE` so the experiment can reach an OpenAI-compatible gateway without editing imp. Patch 3 records the endpoint actually called as `provider_base_url`, because `provider_route` keeps saying `openrouter:…` when a base URL override sends the calls elsewhere. Unrelated to the experiment's logic: no optimizer, adapter, metric or budget behaviour is touched. ## Running ```sh mix deps.get && mix compile TUTORIAL_REPEATS=3 \ OPENROUTER_MODEL=gpt-6-luna \ IMP_LM_BASE_URL=https://opencode.ai/zen/go/v1 \ IMP_LM_KEY_FILE=~/.config/opencode-go.key \ IMP_LM_HEADERS="x-opencode-session=" \ mix run research/tutorial_ticket_routing_experiment.exs ``` ## Results `LabeledFewShot(k: 8, sample: false)`, imp's JSON adapter, imp's exact-match metric, imp's budget tracker. Twenty held-out tickets, three repeats. | artifact | model | baseline | optimized | lift | |---|---|---|---|---| | `776f9632…` | gpt-6-luna | 0.25–0.30 | 0.95–1.00 | +0.65 … +0.75 | | `97486f33…` | gpt-6-luna | 0.25–0.35 | 0.90–0.95 | +0.55 … +0.70 | | `76ef7ff7…` | claude-haiku-5-5 | 0.15–0.20 | 1.00 | +0.80 … +0.85 | | `4fe1a208…` | gpt-6-luna | 0.30–0.35 | 0.95–1.00 | +0.65 … +0.70 | Every artifact carries `git_sha` for the patched tree, `provider_base_url` for the endpoint called (patch 3 onward), and per-repeat `requests_with_usage`. The published row this mirrors is R1/R2 in `research/RESULTS.md`: 0.30–0.40 → 0.90–0.95 on `gpt-5.4-mini`. ## Defect 1: a transport failure is scored as a wrong answer `evidence/zero-usage.txt` is one line from a run whose requests were all rejected by the gateway before reaching a model — it wanted a routing header that the script had no way to send. ``` baseline 0.0 -> optimized 0.0 (2360 ms, usage %{"input_tokens" => 0, "output_tokens" => 0, "requests_with_usage" => 0, "total_tokens" => 0}) ``` Forty failed requests, forty wrong answers, no error surfaced, `exit 0` if nothing else intervenes. The run above only died later, in `verify_fresh_service!/3`, because its subprocess exited 1 for an unrelated reason; had that step passed, an artifact recording a broken setup as a 0.0 baseline would have been written and signed. The signal is already in the artifact: `requests_with_usage` is 0 while 40 requests were attempted. A cheap guard would fail the repeat when `usage.requests_with_usage` is zero (or below a caller-set floor) rather than scoring it, and record the transport error alongside. Note the same class of problem is already in `research/RESULTS.md`'s findings table: "ChatAdapter parse failures dominate per-cell variation", where parse failures score zero. ## Defect 2: a documented setting nothing reads The script's header advertises: ``` # OPENROUTER_API_KEY=... OPENROUTER_MODEL=openai/gpt-5.4-mini \ # mix run research/tutorial_ticket_routing_experiment.exs ``` `live_provider!/0` never read `OPENROUTER_MODEL`; it hard-coded `openrouter:openai/gpt-5.4-mini`. The receipt's `model` field was likewise a literal, so a reader who edited the resolver to try another model would have received a receipt naming the pinned one. Patch 1 fixes both; on the pinned route the receipt is byte-identical to what the committed `tutorial-ticket-routing-2026-09-17.receipt.json` records. ## What this experiment cannot show The four labels are opaque squad names and the instruction gives no mapping between ticket content and squad. The sixty tickets are balanced, so chance is 0.25, and every baseline above sits at or near it. Eight labelled examples reveal the mapping; every model then jumps to 0.90–1.00. So the lift is close to guaranteed by construction. What these runs show is that the examples reach the prompt and the answers parse, on three model families — a plumbing result, and a good one. They say nothing about whether an optimizer finds an improvement that a fixed eight-shot baseline would not already have found, and the baseline spread across models is sampling around chance, not a model property.