Die Konfiguration war an zwei Stellen unnötig sperrig:
pool bild vision, cloud as "deepseek-v4.1-flash"
pool lokal box3, box6
pool alles cloud, lokal
req vision pass bild
req for "*" pass alles
Ein Pool fasst eine Kette zusammen, darf auf einen anderen verweisen und wird beim Laden
in die Regel eingesetzt — auch "as" bleibt dabei am jeweiligen Ziel. Ein Ringschluss wird
durch eine Obergrenze von acht Durchläufen beendet; ein unbekannter Name bleibt ein Fehler.
Ausserdem: "endpoint kurz { base http://…; timeout 60 }" in einer Zeile. Der Rumpf wird
aus den Wörtern zusammengesetzt, nicht aus der Zeile — tokenize() setzt Nullen in den
Puffer, weshalb die erste Umsetzung die Klammer nicht mehr fand.
85 Prüfungen, keine Fehler.
Drei Lücken, die eine echte Kette braucht:
weight N Endpunkte sind nicht gleich viel wert. Unter round-robin bekommt
ein Ziel so viele Plätze in der Runde, wie es wiegt; unter cost
und least-usage zählt sein Verbrauch nur 1/N.
balance <modus> in der Regel: eine Kette darf reines Failover wollen, während
global round-robin gilt.
connect_timeout_ms pro Endpunkt: ein Ziel hinter einem Tunnel braucht ein anderes
Limit als eines im eigenen LAN. 0 = global erben.
Geprüft mit zwei gesunden Stubs: Gewicht 3:1 verteilt 30 zu 10 über 40 Anfragen. Eine
Regel mit "balance first" bleibt bei sechs Anfragen sechsmal auf dem ersten Ziel, obwohl
global round-robin gilt. Ein unerreichbares Ziel mit eigenem Limit von 400 ms wird nach
414 ms übersprungen und die Kette geht weiter — statt 30 s zu warten.
Dazu eine Testkorrektur: die Logprüfung für TLS wartete nicht auf den Logschreiber und
meldete gelegentlich einen Fehler, der keiner war.
80 Prüfungen, keine Fehler.
opencode spricht kein OpenAI-Protokoll, sondern eine sitzungsorientierte API
(/api/session, /prompt, /model, /message). Ein Client soll davon nichts merken:
kind opencode Endpunkt wird über die Brücke bedient statt blind weitergeleitet
auth_basic USER HTTP Basic (opencode verlangt es, junction kannte nur Bearer)
pass_cmd CMD Passwort aus einem Kommando — opencode erzeugt bei jedem Start eins
base_cmd CMD Basis-URL aus einem Kommando — der Dienst bindet einen freien Port
Ablauf je Anfrage: Sitzung anlegen, Modell setzen, Nachrichten zu einem Prompt
zusammenfassen, auf die fertige Assistenten-Nachricht warten, Antwort in OpenAI-Form
bauen, Sitzung löschen. reasoning_content wird getrennt geführt, Token-Zahlen kommen
aus der Sitzung. /v1/models wird ebenfalls übersetzt (modelID statt id, sonst landen
Varianten wie low/high als eigene Modelle in der Liste).
Bewusste Grenzen, im README benannt: Werkzeugdefinitionen werden nicht übersetzt, und
Streaming kommt als ein Stück plus [DONE], weil die Sitzungs-API keine Token-Deltas
liefert.
Geprüft: 10 neue Prüfungen gegen einen Nachbau des Sitzungs-API (tests/opencode.sh,
tests/opencode_stub.py), 76 gesamt, keine Fehler. Am echten Dienst einmal durchgelaufen
mit einem kostenlosen Modell: /v1/models 10 Modelle, Chat 200 mit Inhalt "bereit" in 4,1 s.
- Endpunkte deklarieren vision on|off; Text-Endpunkte werden für Bildanfragen
übersprungen statt mit leerem Inhalt zu antworten
- Bilderkennung vor dem Routing (image_url, input_image, type=image)
- ctx_chars_per_token aktiviert eine Prompt-Größenschätzung; Base64-Bilddaten
zählen nicht mit; ohne den Wert ist eine ctx-Regel ein Ladefehler
- Kontextprüfung rechnet jetzt Prompt + Ausgabebudget gegen den Endpunkt
- 9 neue Prüfungen in tests/ctx-vision.sh, 66 gesamt
One thread per connection plus max_inflight upstream slots; further requests wait in
line (queue_timeout) instead of being refused. A waiting caller that asked for a
stream is told why it waits with SSE comment lines (': junction: waiting for a free
slot (0 ahead of you)'), which the spec says every parser must ignore — a human
watching curl sees progress, a client sees nothing it could misinterpret. The real
answer then starts in the same stream and the comments simply stop.
Trade-off, stated in the README: a streaming caller gets its 200 before the upstream
is chosen, so a later upstream failure cannot be an HTTP status any more — it travels
as a data: {"error":...} event. Non-streaming callers get nothing injected and keep
their true status code.
Also: cache and endpoint state are locked (they are shared between threads now), and
the test stub forks per connection — a serial stub made a concurrent router look
serialised, which is exactly the kind of test that lies.
'need' now reads only max_tokens/max_completion_tokens as the client wrote them.
chars_per_token and default_max_tokens are gone (and rejected as unknown keywords, so
an old config fails loudly instead of steering nothing). A request that declares no
budget is not sized at all — the guessing is what made a 2048-context embedding
endpoint reject requests that carried no token budget in the first place.
tests: 'need' proven from a declared max_tokens, and a request without one proven to
route by model and path alone.
The sleeping box is the one on n95's own segment; a tunnel peer needs a wake hook
that talks to that side. Also marks the LAN address as a placeholder.
- A rule may send a different model name per target: 'pass peer-a as M, peer-b, cloud'
rewrites only for peer-a, so a mixed local/cloud rule still asks the cloud for the
name the client wanted.
- examples/olivia.conf: peers on the tunnel, embedding box, sleeping workstation with
WoL + energy gate, cloud fallback, and the policy rules each with its reason.
- tools/junction-wol.c replaces the Python magic-packet helper; hooks stay shell.
- Forwarding no longer duplicates Host/Content-Length/X-Forwarded-*: Ollama answered
400 to a request that was valid because it arrived with two Host headers.
- need_tokens: embeddings produce a vector, not tokens, so they are not charged
default_max_tokens (a 2048-context embed endpoint refused every request).
- /status lists every target with its model, plus the rule's need window.