From 47ce9c524b830f1567304f97010fa01cdc51c3e7 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 21:04:15 +0200 Subject: [PATCH 01/14] docs: document firewall rules and sudo password trailing space precautions in AGENTS.md --- .agents/AGENTS.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 16a25bb5..a3260413 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -26,3 +26,53 @@ To prevent directory reorganization regressions, outdated file restorations, or 2. **Directory Rename Safety**: If Git reports conflicts related to moved directories or files, do not manually stage deletions of tracked files from moved directories (e.g., under the old `tests/` or `scripts/` paths) or re-create files at the root level. Resolve conflicts by directing all changes and file operations to the newly refactored paths. 3. **Verify Security Credentials**: Never accept resolutions that overwrite configuration files (`pod.yaml`, `start-stack.sh`) with hardcoded default passwords. Ensure placeholder-based configurations are preserved. 4. **Enforce Test Suite Count**: Run the full unit test suite (`pytest`) after conflict resolution. Verify that the total number of passing tests is equal to or greater than before the resolution. + +## Production Deployment Checklist (boy user) + +### One-Time Host Prerequisites (already configured on x570.vendeuvre.lan) +- `net.ipv4.ip_unprivileged_port_start=80` persisted in `/etc/sysctl.d/99-unprivileged-ports.conf` +- Host firewall ports `80/tcp` and `443/tcp` opened in `firewalld` (e.g. `sudo firewall-cmd --zone=public --add-port=80/tcp --permanent && sudo firewall-cmd --zone=public --add-port=443/tcp --permanent && sudo firewall-cmd --reload`) +- `boy` SSH host alias in `~/.ssh/config` — use `ssh boy` / `rsync ... boy:` throughout +- Required mount directories created under `boy`'s home: + - `/mnt/DATA/boy/.gemini/` + - `/mnt/DATA/boy/.local/bin/agy` (copy of the `agy` binary) + - `/mnt/DATA/boy/.local/share/goose/` + - `/mnt/DATA/boy/.local/share/keyrings/` +- HAProxy SSL cert: `/mnt/DATA/boy/haproxy/certs/vendeuvre.pem` +- HAProxy config: `/mnt/DATA/boy/haproxy/haproxy.cfg` + +### Fresh Deploy Steps (after a PR is merged to master) +```bash +# 1. Clean up old deploy on boy +ssh boy "rm -rf /mnt/DATA/boy/LLM-Routing" + +# 2. Clone fresh from master +ssh boy "git clone https://github.com/sheepdestroyer/LLM-Routing.git /mnt/DATA/boy/LLM-Routing" + +# 3. Start the full stack (builds and launches all containers) +ssh boy "cd /mnt/DATA/boy/LLM-Routing && ./start-stack.sh --full-rebuild" + +# 4. Start (or restart) production HAProxy +ssh boy "podman rm -f production-haproxy || true" +ssh boy "podman run -d --name production-haproxy --restart always --net host \ + -v /mnt/DATA/boy/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \ + -v /mnt/DATA/boy/haproxy/certs:/usr/local/etc/haproxy/certs:ro \ + docker.io/library/haproxy:alpine" + +# 5. Start the host-side agy daemon (runs as sheepdestroyer, not boy) +pkill -f host_agy_daemon.py || true +nohup python3 ~/LAB/IA/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 & + +# 6. Verify end-to-end +curl -k -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ + https://x570.vendeuvre.lan/llm-routing/dashboard | head -5 +``` + +### Notes +- The `agy-daemon.service` systemd unit cannot be reloaded via `systemctl --user` from + the agent terminal (DBus is not connected). Start the daemon manually with `nohup` as + shown above, or instruct the user to run it in their own session. +- **Sudo Password Precaution**: Always preserve exact bytes (including trailing spaces or newlines) when reading `/home/sheepdestroyer/.sudo_password` (e.g. `'sakamoto '`). Stripping whitespace will cause authentication to fail. +- `start-stack.sh` without `--full-rebuild` will do a fast pod restart (reuses images). + Use `--full-rebuild` after code changes or image updates. + From ee818d70daea4e01fd66675a3f337269d73bb429 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 21:10:58 +0200 Subject: [PATCH 02/14] feat: resolve console links using request host or BASEURL/BASE_URL environment variable --- router/main.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/router/main.py b/router/main.py index d8be6cfb..62fc6595 100644 --- a/router/main.py +++ b/router/main.py @@ -3070,8 +3070,16 @@ async def get_dashboard_stats(): @app.get("/dashboard", response_class=HTMLResponse) -async def get_dashboard(): +async def get_dashboard(request: Request): """Render the router main dashboard HTML showing system metrics, health checks, and recent token usage.""" + external_host = os.getenv("BASEURL") or os.getenv("BASE_URL") + if not external_host: + external_host = request.base_url.host or "localhost" + else: + if "://" in external_host: + from urllib.parse import urlparse + external_host = urlparse(external_host).hostname or "localhost" + data = await get_dashboard_data() # Unpack data for the f-string template @@ -3710,7 +3718,7 @@ async def get_dashboard():

Per-model usage, token consumption & cost are tracked with full trace detail in Langfuse.

- Open Langfuse Observability → + Open Langfuse Observability →
@@ -3846,15 +3854,15 @@ async def get_dashboard():
- + {src_badge("LANGFUSE", "#e879f9")} Observability UI - + {src_badge("LITELLM", "#34d399")} Admin UI - + {src_badge("LLAMA.CPP", "#fb923c")} Server Router UI From f542bd0e8034c880def2dbeb2b8ee88858411e47 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 21:58:41 +0200 Subject: [PATCH 03/14] Update router/main.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- router/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/main.py b/router/main.py index 62fc6595..d54ea6d8 100644 --- a/router/main.py +++ b/router/main.py @@ -3074,7 +3074,7 @@ async def get_dashboard(request: Request): """Render the router main dashboard HTML showing system metrics, health checks, and recent token usage.""" external_host = os.getenv("BASEURL") or os.getenv("BASE_URL") if not external_host: - external_host = request.base_url.host or "localhost" + external_host = request.base_url.hostname or "localhost" else: if "://" in external_host: from urllib.parse import urlparse From 3292da2f1d3025454385f008af71aeaef65ab719 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 22:00:30 +0200 Subject: [PATCH 04/14] docs: add GitHub CLI auth mapping notes to AGENTS.md --- .agents/AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index a3260413..a5ec8b7c 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -75,4 +75,5 @@ curl -k -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ - **Sudo Password Precaution**: Always preserve exact bytes (including trailing spaces or newlines) when reading `/home/sheepdestroyer/.sudo_password` (e.g. `'sakamoto '`). Stripping whitespace will cause authentication to fail. - `start-stack.sh` without `--full-rebuild` will do a fast pod restart (reuses images). Use `--full-rebuild` after code changes or image updates. +- **GitHub CLI Authentication**: If running `gh` commands fails with a 401 error, ensure that `GITHUB_TOKEN` is exported (e.g., mapped from `GITHUB_MCP_PAT` in `~/.bashrc` via `export GITHUB_TOKEN="$GITHUB_MCP_PAT"`). From 75f4851e80c5ffd74ae6c7f5a0e61700f7b7df2c Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 22:10:20 +0200 Subject: [PATCH 05/14] feat: conditionally resolve console links to subdomains if on vendeuvre.lan network --- router/main.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/router/main.py b/router/main.py index d54ea6d8..1c9edbbf 100644 --- a/router/main.py +++ b/router/main.py @@ -3080,6 +3080,20 @@ async def get_dashboard(request: Request): from urllib.parse import urlparse external_host = urlparse(external_host).hostname or "localhost" + domain = "vendeuvre.lan" + if external_host and domain in external_host: + langfuse_url = f"https://langfuse.{domain}" + litellm_url = f"https://litellm.{domain}/ui" + llama_url = f"https://llama.{domain}" + elif domain in (request.base_url.hostname or ""): + langfuse_url = f"https://langfuse.{domain}" + litellm_url = f"https://litellm.{domain}/ui" + llama_url = f"https://llama.{domain}" + else: + langfuse_url = f"http://{external_host}:3001" + litellm_url = f"http://{external_host}:4000/ui" + llama_url = f"http://{external_host}:8080" + data = await get_dashboard_data() # Unpack data for the f-string template @@ -3718,7 +3732,7 @@ async def get_dashboard(request: Request):

Per-model usage, token consumption & cost are tracked with full trace detail in Langfuse.

- Open Langfuse Observability → + Open Langfuse Observability →
@@ -3854,15 +3868,15 @@ async def get_dashboard(request: Request):
- + {src_badge("LANGFUSE", "#e879f9")} Observability UI - + {src_badge("LITELLM", "#34d399")} Admin UI - + {src_badge("LLAMA.CPP", "#fb923c")} Server Router UI From 675a59c1bfa634203f41bd5a4f7c6bad534867bc Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 22:17:32 +0200 Subject: [PATCH 06/14] feat: subdirectory routing for litellm, langfuse, and llama.cpp under single x570.vendeuvre.lan domain --- pod.yaml | 6 ++++-- router/main.py | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pod.yaml b/pod.yaml index fa8938ad..80d3bb74 100644 --- a/pod.yaml +++ b/pod.yaml @@ -45,13 +45,15 @@ spec: value: LITELLM_MASTER_KEY_PLACEHOLDER - name: OLLAMA_API_KEY value: OLLAMA_API_KEY_PLACEHOLDER + - name: SERVER_ROOT_PATH + value: /llm-routing/litellm image: ghcr.io/berriai/litellm:v1.91.0 livenessProbe: exec: command: - python3 - -c - - import urllib.request; urllib.request.urlopen('http://localhost:4000/ping') + - import urllib.request; urllib.request.urlopen('http://localhost:4000/llm-routing/litellm/ping') initialDelaySeconds: 240 periodSeconds: 15 timeoutSeconds: 5 @@ -61,7 +63,7 @@ spec: command: - python3 - -c - - import urllib.request; urllib.request.urlopen('http://localhost:4000/health/readiness') + - import urllib.request; urllib.request.urlopen('http://localhost:4000/llm-routing/litellm/health/readiness') initialDelaySeconds: 10 periodSeconds: 10 timeoutSeconds: 5 diff --git a/router/main.py b/router/main.py index 1c9edbbf..fadb794c 100644 --- a/router/main.py +++ b/router/main.py @@ -3082,13 +3082,14 @@ async def get_dashboard(request: Request): domain = "vendeuvre.lan" if external_host and domain in external_host: - langfuse_url = f"https://langfuse.{domain}" - litellm_url = f"https://litellm.{domain}/ui" - llama_url = f"https://llama.{domain}" + langfuse_url = f"https://{external_host}/llm-routing/langfuse" + litellm_url = f"https://{external_host}/llm-routing/litellm/ui" + llama_url = f"https://{external_host}/llm-routing/llama/" elif domain in (request.base_url.hostname or ""): - langfuse_url = f"https://langfuse.{domain}" - litellm_url = f"https://litellm.{domain}/ui" - llama_url = f"https://llama.{domain}" + base = f"{request.url.scheme}://{request.url.netloc}" + langfuse_url = f"{base}/llm-routing/langfuse" + litellm_url = f"{base}/llm-routing/litellm/ui" + llama_url = f"{base}/llm-routing/llama/" else: langfuse_url = f"http://{external_host}:3001" litellm_url = f"http://{external_host}:4000/ui" From 36cbc72505750c8c8d183de2751aaca01b42411c Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 22:29:11 +0200 Subject: [PATCH 07/14] fix: address PR reviews - sanitize external_host and fix credentials leak / TLS bypass --- .agents/AGENTS.md | 4 ++-- router/main.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index a5ec8b7c..8309bd73 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -64,7 +64,7 @@ pkill -f host_agy_daemon.py || true nohup python3 ~/LAB/IA/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 & # 6. Verify end-to-end -curl -k -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ +curl -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ https://x570.vendeuvre.lan/llm-routing/dashboard | head -5 ``` @@ -72,7 +72,7 @@ curl -k -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ - The `agy-daemon.service` systemd unit cannot be reloaded via `systemctl --user` from the agent terminal (DBus is not connected). Start the daemon manually with `nohup` as shown above, or instruct the user to run it in their own session. -- **Sudo Password Precaution**: Always preserve exact bytes (including trailing spaces or newlines) when reading `/home/sheepdestroyer/.sudo_password` (e.g. `'sakamoto '`). Stripping whitespace will cause authentication to fail. +- **Sudo Password Precaution**: Always preserve exact bytes (including trailing spaces or newlines) when reading `/home/sheepdestroyer/.sudo_password` (e.g. `'your_password_here '`). Stripping whitespace will cause authentication to fail. - `start-stack.sh` without `--full-rebuild` will do a fast pod restart (reuses images). Use `--full-rebuild` after code changes or image updates. - **GitHub CLI Authentication**: If running `gh` commands fails with a 401 error, ensure that `GITHUB_TOKEN` is exported (e.g., mapped from `GITHUB_MCP_PAT` in `~/.bashrc` via `export GITHUB_TOKEN="$GITHUB_MCP_PAT"`). diff --git a/router/main.py b/router/main.py index fadb794c..e426c470 100644 --- a/router/main.py +++ b/router/main.py @@ -3081,12 +3081,18 @@ async def get_dashboard(request: Request): external_host = urlparse(external_host).hostname or "localhost" domain = "vendeuvre.lan" + import re + if not isinstance(external_host, str) or not re.match(r"^[a-zA-Z0-9.-]+$", external_host): + external_host = "localhost" + if external_host and domain in external_host: langfuse_url = f"https://{external_host}/llm-routing/langfuse" litellm_url = f"https://{external_host}/llm-routing/litellm/ui" llama_url = f"https://{external_host}/llm-routing/llama/" elif domain in (request.base_url.hostname or ""): - base = f"{request.url.scheme}://{request.url.netloc}" + scheme = request.url.scheme if re.match(r"^(?:http|https)$", request.url.scheme) else "https" + netloc = request.url.netloc if re.match(r"^[a-zA-Z0-9.-]+(?::\d+)?$", request.url.netloc) else "localhost" + base = f"{scheme}://{netloc}" langfuse_url = f"{base}/llm-routing/langfuse" litellm_url = f"{base}/llm-routing/litellm/ui" llama_url = f"{base}/llm-routing/llama/" From c2a27e8b435977929f326f650675bec991ec4fcf Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 22:33:44 +0200 Subject: [PATCH 08/14] docs: document -k intent in verification curl (self-signed cert) --- .agents/AGENTS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 8309bd73..11a5f7f9 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -64,7 +64,9 @@ pkill -f host_agy_daemon.py || true nohup python3 ~/LAB/IA/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 & # 6. Verify end-to-end -curl -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ +# NOTE: -k is intentional — the HAProxy cert is self-signed (local CA). +# Replace the cert with a trusted CA-signed cert to remove -k. +curl -k -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ https://x570.vendeuvre.lan/llm-routing/dashboard | head -5 ``` From aded670bfbdaebf0d758d58ec43c3aee1484f017 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 22:39:26 +0200 Subject: [PATCH 09/14] Update AGENTS.md --- .agents/AGENTS.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 11a5f7f9..62e5f172 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -10,9 +10,9 @@ When working on this project, always refer to the dedicated **NotebookLM Compani - Local model benchmark metrics and `llama-server` configurations ### Notebook Details -- **Notebook Name:** `TriageGate-Architect-KB` +- **Notebook Name:** `LLM-Routing-KB` - **Notebook ID:** `llm-triage-gateway` -- **Notebook URL:** [TriageGate-Architect-KB](https://notebooklm.google.com/notebook/826cbd87-7969-4b0e-a38e-5517b5ab7d28) +- **Notebook URL:** [LLM-Routing-KB](https://notebooklm.google.com/notebook/826cbd87-7969-4b0e-a38e-5517b5ab7d28) ### How to Query Use the `notebooklm` MCP tools to search or ask questions about this codebase and stack: @@ -59,9 +59,9 @@ ssh boy "podman run -d --name production-haproxy --restart always --net host \ -v /mnt/DATA/boy/haproxy/certs:/usr/local/etc/haproxy/certs:ro \ docker.io/library/haproxy:alpine" -# 5. Start the host-side agy daemon (runs as sheepdestroyer, not boy) +# 5. Start the host-side agy daemon pkill -f host_agy_daemon.py || true -nohup python3 ~/LAB/IA/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 & +nohup python3 ~/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 & # 6. Verify end-to-end # NOTE: -k is intentional — the HAProxy cert is self-signed (local CA). @@ -74,7 +74,7 @@ curl -k -s --resolve x570.vendeuvre.lan:443:127.0.0.1 \ - The `agy-daemon.service` systemd unit cannot be reloaded via `systemctl --user` from the agent terminal (DBus is not connected). Start the daemon manually with `nohup` as shown above, or instruct the user to run it in their own session. -- **Sudo Password Precaution**: Always preserve exact bytes (including trailing spaces or newlines) when reading `/home/sheepdestroyer/.sudo_password` (e.g. `'your_password_here '`). Stripping whitespace will cause authentication to fail. +- **Sudo Password Precaution**: Always preserve exact bytes (including trailing spaces or newlines) when reading `~/.sudo_password` (e.g. `'your_password_here '`). Stripping whitespace will cause authentication to fail. - `start-stack.sh` without `--full-rebuild` will do a fast pod restart (reuses images). Use `--full-rebuild` after code changes or image updates. - **GitHub CLI Authentication**: If running `gh` commands fails with a 401 error, ensure that `GITHUB_TOKEN` is exported (e.g., mapped from `GITHUB_MCP_PAT` in `~/.bashrc` via `export GITHUB_TOKEN="$GITHUB_MCP_PAT"`). From 49b4f3acbe156a914308f72c4bb7230ac3dcc28f Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 23:25:58 +0200 Subject: [PATCH 10/14] chore: update success banner to show external /llm-routing/v1 endpoint URL --- start-stack.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/start-stack.sh b/start-stack.sh index 7a1a7bac..7d722e51 100755 --- a/start-stack.sh +++ b/start-stack.sh @@ -599,10 +599,11 @@ if podman pod exists agent-router-pod 2>/dev/null; then echo "" echo "=========================================================================" echo "🎉 SUCCESS: LLM Triage Gateway restarted!" - echo "📍 Entry endpoint : http://localhost:5000/v1" - echo "⚙️ Dashboard URL : http://localhost:5000/dashboard" + echo "📍 Entry endpoint : https://x570.vendeuvre.lan/llm-routing/v1" + echo " (local) : http://localhost:5000/v1" + echo "⚙️ Dashboard URL : https://x570.vendeuvre.lan/llm-routing/dashboard" echo "🔑 Gateway API Key : gateway-pass" - echo "🔐 LiteLLM Admin UI: http://localhost:4000/ui" + echo "🔐 LiteLLM Admin UI: https://x570.vendeuvre.lan/llm-routing/litellm/ui" echo " Username: admin | Password: $LITELLM_MASTER_KEY" echo "=========================================================================" exit 0 @@ -621,9 +622,10 @@ fi echo "=========================================================================" echo "🎉 SUCCESS: LLM Triage Gateway successfully deployed!" -echo "📍 Entry endpoint : http://localhost:5000/v1" -echo "⚙️ Dashboard URL : http://localhost:5000/dashboard" +echo "📍 Entry endpoint : https://x570.vendeuvre.lan/llm-routing/v1" +echo " (local) : http://localhost:5000/v1" +echo "⚙️ Dashboard URL : https://x570.vendeuvre.lan/llm-routing/dashboard" echo "🔑 Gateway API Key : gateway-pass" -echo "🔐 LiteLLM Admin UI: http://localhost:4000/ui" +echo "🔐 LiteLLM Admin UI: https://x570.vendeuvre.lan/llm-routing/litellm/ui" echo " Username: admin | Password: $LITELLM_MASTER_KEY" echo "=========================================================================" From e096379a0fcabbfeea42995d04803768865c136d Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Wed, 8 Jul 2026 23:33:00 +0200 Subject: [PATCH 11/14] fix: bump LiteLLM readiness probe initial delay to 45s to avoid startup false failures --- pod.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pod.yaml b/pod.yaml index 80d3bb74..e2b04663 100644 --- a/pod.yaml +++ b/pod.yaml @@ -63,8 +63,8 @@ spec: command: - python3 - -c - - import urllib.request; urllib.request.urlopen('http://localhost:4000/llm-routing/litellm/health/readiness') - initialDelaySeconds: 10 + - import urllib.request; urllib.request.urlopen('http://localhost:4000/health/readiness') + initialDelaySeconds: 45 periodSeconds: 10 timeoutSeconds: 5 volumeMounts: From a702b5c0f3be9931a2f03d88c2e8c409d172a047 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Thu, 9 Jul 2026 01:06:49 +0200 Subject: [PATCH 12/14] chore: sync changes from boy prod including local-qwen-3.6 config and PROXY_BASE_URL --- litellm/config.yaml | 15 +++++++-------- pod.yaml | 4 +++- router/free_models_roster.json | 23 +++++++++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/litellm/config.yaml b/litellm/config.yaml index d1043342..61c477a2 100644 --- a/litellm/config.yaml +++ b/litellm/config.yaml @@ -90,14 +90,13 @@ model_list: max_input_tokens: 524288 is_public_model_group: true -# DISABLED 2026-06-08 — 20GB on disk, 23GB GTT (system RAM as GPU buffer). -# Uncomment to re-enable once a lighter model replaces it. -#- litellm_params: -# api_base: http://127.0.0.1:8080/v1 -# api_key: local-token -# model: openai/qwen-35b-q4ks -# request_timeout: 300 -# model_name: local-qwen-3.6 +# Re-enabled 2026-07-08 — llama.cpp on port 8081, alias local-qwen-3.6 +- litellm_params: + api_base: http://127.0.0.1:8081/v1 + api_key: local-token + model: openai/local-qwen-3.6 + request_timeout: 300 + model_name: local-qwen-3.6 - litellm_params: api_base: http://127.0.0.1:8080/v1 api_key: local-token diff --git a/pod.yaml b/pod.yaml index e2b04663..c954b57a 100644 --- a/pod.yaml +++ b/pod.yaml @@ -47,13 +47,15 @@ spec: value: OLLAMA_API_KEY_PLACEHOLDER - name: SERVER_ROOT_PATH value: /llm-routing/litellm + - name: PROXY_BASE_URL + value: https://x570.vendeuvre.lan/llm-routing/litellm image: ghcr.io/berriai/litellm:v1.91.0 livenessProbe: exec: command: - python3 - -c - - import urllib.request; urllib.request.urlopen('http://localhost:4000/llm-routing/litellm/ping') + - import urllib.request; urllib.request.urlopen('http://localhost:4000/ping') initialDelaySeconds: 240 periodSeconds: 15 timeoutSeconds: 5 diff --git a/router/free_models_roster.json b/router/free_models_roster.json index 5f1dfe0c..8a71d4a5 100644 --- a/router/free_models_roster.json +++ b/router/free_models_roster.json @@ -42,6 +42,18 @@ "score": 28.0, "context_length": 256000 }, + { + "id": "tencent/hy3:free", + "name": "Tencent: Hy3 (free)", + "score": 25.0, + "context_length": 262144 + }, + { + "id": "poolside/laguna-xs-2.1:free", + "name": "Poolside: Laguna XS 2.1 (free)", + "score": 25.0, + "context_length": 262144 + }, { "id": "cohere/north-mini-code:free", "name": "Cohere: North Mini Code (free)", @@ -54,12 +66,7 @@ "score": 25.0, "context_length": 128000 }, - { - "id": "openrouter/owl-alpha", - "name": "Owl Alpha", - "score": 25.0, - "context_length": 1048756 - }, + { "id": "google/lyria-3-pro-preview", "name": "Google: Lyria 3 Pro Preview", @@ -139,6 +146,6 @@ "context_length": 32768 } ], - "updated_at": "2026-06-24T18:40:15.482014Z", - "count": 23 + "updated_at": "2026-07-08T22:55:47.271165Z", + "count": 24 } \ No newline at end of file From 86442b51f6b195c0a2e29af83cb4899f3185f464 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Thu, 9 Jul 2026 01:08:08 +0200 Subject: [PATCH 13/14] fix: address PR reviews - configurable ROUTING_DOMAIN, improve external_host/port resolution, fix agy startup SSH commands --- .agents/AGENTS.md | 4 ++-- router/main.py | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 62e5f172..36cc022f 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -60,8 +60,8 @@ ssh boy "podman run -d --name production-haproxy --restart always --net host \ docker.io/library/haproxy:alpine" # 5. Start the host-side agy daemon -pkill -f host_agy_daemon.py || true -nohup python3 ~/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 & +ssh boy "pkill -f host_agy_daemon.py || true" +ssh boy "nohup python3 /mnt/DATA/boy/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 &" # 6. Verify end-to-end # NOTE: -k is intentional — the HAProxy cert is self-signed (local CA). diff --git a/router/main.py b/router/main.py index e426c470..690f4175 100644 --- a/router/main.py +++ b/router/main.py @@ -3072,23 +3072,31 @@ async def get_dashboard_stats(): @app.get("/dashboard", response_class=HTMLResponse) async def get_dashboard(request: Request): """Render the router main dashboard HTML showing system metrics, health checks, and recent token usage.""" - external_host = os.getenv("BASEURL") or os.getenv("BASE_URL") - if not external_host: - external_host = request.base_url.hostname or "localhost" - else: - if "://" in external_host: + external_host_env = os.getenv("BASEURL") or os.getenv("BASE_URL") + if external_host_env: + if "://" not in external_host_env: + from urllib.parse import urlparse + parsed = urlparse(f"http://{external_host_env}") + else: from urllib.parse import urlparse - external_host = urlparse(external_host).hostname or "localhost" + parsed = urlparse(external_host_env) + external_host = parsed.hostname or "localhost" + external_netloc = parsed.netloc or "localhost" + else: + external_host = request.base_url.hostname or "localhost" + external_netloc = request.base_url.netloc or "localhost" - domain = "vendeuvre.lan" + domain = os.getenv("ROUTING_DOMAIN") or "vendeuvre.lan" import re if not isinstance(external_host, str) or not re.match(r"^[a-zA-Z0-9.-]+$", external_host): external_host = "localhost" + if not isinstance(external_netloc, str) or not re.match(r"^[a-zA-Z0-9.-]+(?::\d+)?$", external_netloc): + external_netloc = "localhost" - if external_host and domain in external_host: - langfuse_url = f"https://{external_host}/llm-routing/langfuse" - litellm_url = f"https://{external_host}/llm-routing/litellm/ui" - llama_url = f"https://{external_host}/llm-routing/llama/" + if external_netloc and domain in external_netloc: + langfuse_url = f"https://{external_netloc}/llm-routing/langfuse" + litellm_url = f"https://{external_netloc}/llm-routing/litellm/ui" + llama_url = f"https://{external_netloc}/llm-routing/llama/" elif domain in (request.base_url.hostname or ""): scheme = request.url.scheme if re.match(r"^(?:http|https)$", request.url.scheme) else "https" netloc = request.url.netloc if re.match(r"^[a-zA-Z0-9.-]+(?::\d+)?$", request.url.netloc) else "localhost" From 0404eff80d68864ac94c2d6d63b854564e9e2844 Mon Sep 17 00:00:00 2001 From: sheepdestroyer Date: Thu, 9 Jul 2026 01:23:12 +0200 Subject: [PATCH 14/14] fix: address review comments on PR #241 (domain validation, dynamic success endpoints, nohup stdin redirect) --- .agents/AGENTS.md | 9 ++++++--- pod.yaml | 32 ++++++++++++++++---------------- router/main.py | 12 +++++++----- start-stack.sh | 34 ++++++++++++++++++++++++---------- 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 36cc022f..33379171 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -61,13 +61,12 @@ ssh boy "podman run -d --name production-haproxy --restart always --net host \ # 5. Start the host-side agy daemon ssh boy "pkill -f host_agy_daemon.py || true" -ssh boy "nohup python3 /mnt/DATA/boy/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 &" +ssh boy "nohup python3 /mnt/DATA/boy/LLM-Routing/scripts/host_agy_daemon.py >/tmp/agy-daemon.log 2>&1 /dev/null; then fi render_pod_yaml() { - export WORKDIR HOME LITELLM_MASTER_KEY POSTGRES_PASSWORD NEXTAUTH_SECRET SALT ENCRYPTION_KEY LANGFUSE_INIT_USER_PASSWORD MINIO_ROOT_USER MINIO_ROOT_PASSWORD OLLAMA_API_KEY LANGFUSE_PUBLIC_KEY LANGFUSE_SECRET_KEY CLASSIFIER_INPUT_MAX_CHARS REDIS_AUTH CLICKHOUSE_PASSWORD + PUBLIC_BASE_URL="${PUBLIC_BASE_URL:-${BASE_URL:-${BASEURL:-https://x570.vendeuvre.lan/llm-routing}}}" + export WORKDIR HOME LITELLM_MASTER_KEY POSTGRES_PASSWORD NEXTAUTH_SECRET SALT ENCRYPTION_KEY LANGFUSE_INIT_USER_PASSWORD MINIO_ROOT_USER MINIO_ROOT_PASSWORD OLLAMA_API_KEY LANGFUSE_PUBLIC_KEY LANGFUSE_SECRET_KEY CLASSIFIER_INPUT_MAX_CHARS REDIS_AUTH CLICKHOUSE_PASSWORD PUBLIC_BASE_URL python3 - "$WORKDIR/pod.yaml" <<'PY' import os, sys, urllib.parse, json uid = os.getuid() @@ -538,7 +539,8 @@ placeholders = [ "MINIO_PASSWORD_PLACEHOLDER", "LANGFUSE_INIT_USER_PASSWORD_PLACEHOLDER", "REDIS_AUTH_PLACEHOLDER", - "CLICKHOUSE_PASSWORD_PLACEHOLDER" + "CLICKHOUSE_PASSWORD_PLACEHOLDER", + "PROXY_BASE_URL_PLACEHOLDER" ] for ph in placeholders: if ph not in text: @@ -563,6 +565,10 @@ text = text.replace("MINIO_PASSWORD_PLACEHOLDER", yaml_scalar(os.environ["MINIO_ text = text.replace("LANGFUSE_INIT_USER_PASSWORD_PLACEHOLDER", yaml_scalar(os.environ["LANGFUSE_INIT_USER_PASSWORD"])) text = text.replace("REDIS_AUTH_PLACEHOLDER", yaml_scalar(os.environ["REDIS_AUTH"])) text = text.replace("CLICKHOUSE_PASSWORD_PLACEHOLDER", yaml_scalar(os.environ["CLICKHOUSE_PASSWORD"])) +# Derive PROXY_BASE_URL from PUBLIC_BASE_URL +public_base_url = os.environ["PUBLIC_BASE_URL"].rstrip("/") +proxy_base_url = f"{public_base_url}/litellm" +text = text.replace("PROXY_BASE_URL_PLACEHOLDER", yaml_scalar(proxy_base_url)) import re unresolved = sorted(set(re.findall(r"\b[A-Z0-9_]+_PLACEHOLDER\b", text))) if unresolved: @@ -596,14 +602,18 @@ if podman pod exists agent-router-pod 2>/dev/null; then podman pod restart agent-router-pod setup_minio_buckets verify_stack_health + # Derive base URLs from configuration/env with sensible defaults + PUBLIC_BASE_URL="${PUBLIC_BASE_URL:-https://x570.vendeuvre.lan/llm-routing}" + LOCAL_BASE_URL="${LOCAL_BASE_URL:-http://localhost:5000}" + echo "" echo "=========================================================================" echo "🎉 SUCCESS: LLM Triage Gateway restarted!" - echo "📍 Entry endpoint : https://x570.vendeuvre.lan/llm-routing/v1" - echo " (local) : http://localhost:5000/v1" - echo "⚙️ Dashboard URL : https://x570.vendeuvre.lan/llm-routing/dashboard" + echo "📍 Entry endpoint : ${PUBLIC_BASE_URL}/v1" + echo " (local) : ${LOCAL_BASE_URL}/v1" + echo "⚙️ Dashboard URL : ${PUBLIC_BASE_URL}/dashboard" echo "🔑 Gateway API Key : gateway-pass" - echo "🔐 LiteLLM Admin UI: https://x570.vendeuvre.lan/llm-routing/litellm/ui" + echo "🔐 LiteLLM Admin UI: ${PUBLIC_BASE_URL}/litellm/ui" echo " Username: admin | Password: $LITELLM_MASTER_KEY" echo "=========================================================================" exit 0 @@ -620,12 +630,16 @@ else verify_stack_health fi +# Derive base URLs from configuration/env with sensible defaults +PUBLIC_BASE_URL="${PUBLIC_BASE_URL:-https://x570.vendeuvre.lan/llm-routing}" +LOCAL_BASE_URL="${LOCAL_BASE_URL:-http://localhost:5000}" + echo "=========================================================================" echo "🎉 SUCCESS: LLM Triage Gateway successfully deployed!" -echo "📍 Entry endpoint : https://x570.vendeuvre.lan/llm-routing/v1" -echo " (local) : http://localhost:5000/v1" -echo "⚙️ Dashboard URL : https://x570.vendeuvre.lan/llm-routing/dashboard" +echo "📍 Entry endpoint : ${PUBLIC_BASE_URL}/v1" +echo " (local) : ${LOCAL_BASE_URL}/v1" +echo "⚙️ Dashboard URL : ${PUBLIC_BASE_URL}/dashboard" echo "🔑 Gateway API Key : gateway-pass" -echo "🔐 LiteLLM Admin UI: https://x570.vendeuvre.lan/llm-routing/litellm/ui" +echo "🔐 LiteLLM Admin UI: ${PUBLIC_BASE_URL}/litellm/ui" echo " Username: admin | Password: $LITELLM_MASTER_KEY" echo "========================================================================="