minions-llm-proxy-ops
Use when operating or debugging the .minions LLM proxies.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 2
- Forks
- 2
01 前言 Front Matter
- name
- minions-llm-proxy-ops
- author
- .minions maintainers
- license
- MIT
- version
- 0.1.0
- metadata
- { "hermes": { "tags": [ "9router", "omniroute", "opencode", "llm-proxy", "free-tier", "combos" ], "related_skills": [ "docker-test-shell", "version-single-source" ] } }
- description
- Use when operating or debugging the .minions LLM proxies.
02 资源文件 3
- 参考文档references/opencode-free-tier.md2.7 KB
- 脚本scripts/add-ghcodespace-provider.sh25.1 KB
- 脚本scripts/add-tailscale-provider.sh12.8 KB
03 SKILL.md 正文
.minions LLM proxy stack ops
When to Use
- A model or combo through 9Router (:7352) or OmniRoute (:20128) errors, 403s, rate-limits, or returns empty content.
- opencode.ai free tier (
oc/models) breaks — FreeTierError, "Model is unavailable", or silent empty responses. - The
auto-fastestcombo needs its model list refreshed or reordered. - You need to change 9Router provider headers, combos, or settings so they
survive reboots (i.e. via
lib/9router.sh).
The stack (boot.sh) runs OmniRoute (:20128) and 9Router (:7352). 9Router routes
auto-fastest (a combo) to free OpenCode (oc/) models; OmniRoute is the
upstream LLM proxy for Hermes. lib/9router.sh (ninerouter_preconfigure)
re-applies 9Router config idempotently on every boot — edit it there so config
survives restarts, and use its API calls as the reference for ad-hoc changes.
Always-on rules
-
Verify a proxy change with real completions, never HTTP status alone. 9Router's combo fallback counts an empty
finish_reason:"in_progress"(orfinish_lengthwith 0 visible tokens) response as SUCCESS, so a combo whose first model is silently broken returns empty content forever without ever falling back. Pass signal = non-emptychoices[0].message.content; empty content is a failure regardless offinish_reason(free models sometimes return correct content withfinish_reason:"length", so don't requirestop). A 2xx with empty content is a failure. -
Lead a combo with the known-good model. Since fallback only fires on hard errors, put the model that actually produces content FIRST in the combo model list; put flaky/unverified models after.
-
Free-tier model lists rotate. Query the live list before trusting any hardcoded model id:
curl -s https://opencode.ai/zen/v1/models(only ids ending-free/-contributor-freeare actually free). A stale id either hard-errors or silently returns empty — both degrade the combo. -
9Router dashboard login: default password
123456; cookie session viaPOST /api/auth/login. All admin APIs need the cookie (-b "$COOKIE").requireLogin/requireApiKeyare disabled by preconfig. -
9Router combo model list lives in
etc/9router-models.json(single source). 9Router only —lib/omniroute.shis NOT wired to it.lib/9router.shreads that file at boot — never duplicate the list inline in a shell script.tests/test_9router_models.sh(blocking CI) is an OFFLINE structural guard;scripts/sync-9router-models.showns upstream drift (--check/--write) and live probing (--probe,--probe-writeneed a running 9Router on :7352: keep 200/429, drop 400/410). -
Config lives in 9Router's own DB, keyed by canonical provider id.
PUT /api/providers/<id>/overridesREPLACES the whole header map for that provider (idempotent; send the full map each time).POST /api/combos+ DELETE-by-id is how combos are recreated (there is no PUT on combos).
Standard procedure: audit/fix a provider's routing
- Log in and save a cookie:
curl -s -c /tmp/nr.txt -X POST $BASE/api/auth/login -H 'Content-Type: application/json' -d '{"password":"123456"}' - Inspect current state:
GET /api/combos,GET /api/settings,GET /api/providers/<id>/overrides(showsheaders+builtinHeaders). - If upstream 403s / rejects: set header overrides (see
references/opencode-free-tier.mdfor the OpenCode-specific header set and session-id generator). - Fix the combo model list against the LIVE free list (step above), known-good model first.
- Test with a real prompt at >=128 max_tokens (small budgets get eaten by
reasoning tokens and look like empty failures):
POST /v1/chat/completions {"model":"auto-fastest","messages":[...],"stream":false,"max_tokens":128}Assert non-empty content. To validate a combo's model list, test each member individually the same way — bare ids route directly (model=oc/<id>), so you can run them in parallel and prune dead ids before recreating the combo. If a model errors, read~/.minions/var/log/9router.log— it logs the upstream URL, status, and provider-side error body. - Any change must land in
lib/9router.shor it is lost: the boot preconfig deletes and recreates combos (and re-puts overrides) every boot, so live-only edits — dashboard or ad-hoc API — silently revert on next boot. Edit the script, then let boot apply it, or apply + edit together.
Add an OpenAI-compatible provider (OmniRoute :20128), wire a model into auto-fastest
Two prepared helpers in scripts/ (this repo:
skills/minions-llm-proxy-ops/scripts/; standalone install:
~/.minions/skills/minions-llm-proxy-ops/scripts/). Both idempotent, both
--dry-run capable, same 5 REST steps. Pick by the upstream's shape:
| Upstream shape | Script | Key env |
|---|---|---|
| Local keyless OpenAI-compatible peer (Ollama etc.), single known model | add-tailscale-provider.sh <host[:port]> |
TSC_PORT, MODEL_NAME, PROVIDER_NAME (defaults: 11434, qwen3.8:27b, tailscale) |
| Auth'd hosted OpenAI-compatible API (GitHub Copilot), discover models, context-window filter (≥128k), probe + wire all keepers | add-ghcodespace-provider.sh (or --renew to just rotate the token) |
GHPILOT_BASEURL, GITHUB_TOKEN (auto via codespace-gh-auth), PROVIDER_NAME (default ghcodespace), MIN_CONTEXT_K (default 128; 0 = off) |
Choosing the baseUrl shape — the most common mistake: check the upstream
first, not a template. baseUrl is appended with the chat/models path. Tailscale
peer uses /v1/chat/completions; a hosted endpoint like
https://api.individual.githubcopilot.com uses /chat/completions (bare, no
/v1). Register the wrong one and every completion 404s through the proxy
with no local trace. Verify both shapes with a 2-line curl before writing the
node body:
curl -sI $BASE/chat/completions # expect 405 (method) or 401, NOT 404
curl -sI $BASE/v1/chat/completions # the other one
Whichever is the real one sets baseUrl shape. add-tailscale-provider.sh
forces …/v1; add-ghcodespace-provider.sh uses the bare domain. For a new
upstream with a different path shape, override the base URL by env and set
chatPath on the node to the bare path (e.g. "/chat/completions") — never
a string starting with /v1/. The server generates the concrete id
openai-compatible-chat-<uuid>; that uuid is the provider id stored on the
combo entries.
Dummy vs real credential: the tailscale helper stores a dummy apiKey —
OK because the local peer ignores auth. For an endpoint that enforces Bearer
(like api.individual.githubcopilot.com), the connection apiKey must be the
real token — a dummy still registers but every completion 401s.
add-ghcodespace-provider.sh sources codespace-gh-auth skill (or an inline
fallback) to obtain the ghu_ token and redacts it in human-visible output
(ghu_****(len=N)); pass GITHUB_TOKEN=… to skip extraction.
Token rotation (--renew) — the Codespace reboot case. The OmniRoute
config (node, connection, imported models, auto-fastest combo) survives a
Codespace reboot, but the ghu_ PAT is re-issued on every restart — so
the existing ghcodespace connection holds a stale (dead) token after a
reboot, and requests 401. --renew handles exactly this case (2026-11-01,
live-verified):
skills/minions-llm-proxy-ops/scripts/add-ghcodespace-provider.sh --renew
- Finds the existing
ghcodespacenode/connection, thenDELETE /api/providers/<cid>thenPOST /api/providerswith the freshly-extractedghu_thenPUT isActive. Node / imported models /auto-fastestcombo are left untouched — no re-discovery, no re-probing. Idempotent: safe to run after every restart. - The fresh PAT is re-extracted via the same
codespace-gh-authskill path; if no node or connection is found, it falls through to the full wire. - The "auth expired" latch (401 "All credentials authentication expired") is
the classic symptom: updating the key in-place does not clear it — a
real completion test must pass first. Recreate + activate + a live
/modelsgate (the last step of--renew) clears the latch as a side effect. - Dry-run:
DRY_RUN=1 … --renewprints the planned delete + recreate without touching OmniRoute.
Model auto-discovery + probe (add-ghcodespace-provider.sh):
GET <base>/modelswith Bearer → ids plus each model'scapabilities.limits.max_context_window_tokens. Context-window floor:MIN_CONTEXT_K(default128) drops models below the floor before probing (embeddings report no context → dropped with a positive floor; setMIN_CONTEXT_K=0to accept everything). Fallback roster if no parsable ids above the floor.- For each candidate, one real completion (
max_tokens=8, polite delay). Classification (mirrorslib/9router.sh+ theminions-9router-modelspass/fail rule):200 + non-empty contentor429→ keep;400/404/410/403/401→ drop;5xx→ retry ×3 with backoff then drop. GitHub Copilot 400 codes all mean drop —model_not_supportedandno model endpoints available given user constraintsare server-side entitlement gates, not misconfigurations (2026-11-01: all 4mai-*ids return these from every lane; the GPT-4o family is the kept set). Catalogpolicy.state=enabledis not entitlement — the dispatch table decides per credential; anenabledid can still 400. - Exclude non-chat auxiliaries before the probe:
text-embedding-*andcopilot-search-*entries respond to a ping but aren't chat LLMs — including them in a chat-completions combo pollutes routing. - Never register a router alias (e.g.
auto) as a model.autois not in the/modelsroster — it's a server-resolved alias. On the free-tier Codespace PAT it resolves to MAI (A/B bucketautov2_mai_prod), which then 400s (2026-11-01: 81/81autoprobes across 3 lanes × 27 integration ids weremodel_not_supported). Registeringautowould add a 100%-fail entry that rotsauto-fastestfallbacks. Register only real model ids the credential actually serves — here, the GPT-4o family. - Import the keepers and append to the existing
auto-fastestcombo (never duplicated, existing entry shapes preserved verbatim).
The five REST steps below are the verified sequence (OmniRoute 3.8.53) and how the scripts work — use them as the manual/API reference for any new upstream that only needs a base URL:
- Create the NODE —
POST /api/provider-nodeswith{name, type:"openai-compatible", baseUrl:"http://<host:port>/v1", prefix:name, apiType:"chat"}.baseUrlMUST end in/v1(the base for the OpenAI-compatible endpoints) and OMITchatPath/modelsPathentirely — the server stores themnull(its own default), which is the correct shape. The server generates the concrete idopenai-compatible-chat-<uuid>— that uuid IS the provider id used by/api/providersand combos. Pitfalls (verified against OmniRoute 3.8.53): explicitnull→400 Invalid input(so omit the keys, don't null them); non-null strings like"/v1/chat/completions"→201but wrong — they double the/v1baseUrlalready carries, producing.../v1/v1/.... If you ever DO set them, use bare"/chat/completions"or"/models"(no/v1). - Create the CONNECTION —
POST /api/providerswith{provider:"<node-id>", name, apiKey:"<any non-empty string>", priority, providerSpecificData:{prefix, apiType:"chat", baseUrl, nodeName:name}}. Pitfall: a keyless connection is rejected ("API key is required"/"does not allow a connection without a credential"). The key value is ignored by the upstream; a dummy credential is fine.omniroute providers add openai-compatible …fails withInvalid providerbecause the CLI will not accept the abstract type — the node must exist first and the concrete id must be passed. - Activate —
PUT /api/providers/<cid> {"isActive":true}. The connection is createdisActive:false; activation returnstestStatus:"active"immediately when the upstream is reachable. - Import the model —
POST /api/provider-models {provider:"<node-id>", modelId}. The alternatevalidate-and-addendpoint requires a realAuthorizationheader on this deployment and 401s — use the plain one. - Append to
auto-fastest—GET /api/combos, findauto-fastest, add{id:"<combo>-model-<name>-<model>", kind:"model", model:"<name>/<model>", providerId:"<node-id>", weight:0}tomodels[], thenPUT /api/combos/<id>with the FULL body{name, strategy, enabled, config, models}. Pitfall:PUTrejects a body that has onlymodels(COMBO_001 Invalid JSON body).POST /api/combosupserts by name, so it works for both create and re-list.
Teardown (safe): omniroute providers remove <name> --yes does an exact
name match (no substrings) — verified in resolveRemoteConnection →
findConnectionFromResponse. DELETE /api/provider-nodes/<node-id> removes
the node. To strip a line from a combo: PUT /api/combos/<id> with the
filtered models (don't send id/sortOrder/isHidden in the body).
Watch for server-side side effects: the OmniRoute ModelSync job runs on a
timer and has been observed removing an existing duplicate connection on the
same provider node during an unrelated create/delete window (2026-10-23,
main-2 on the ollama node vanished while adding/removing a different
node). Always snapshot GET /api/providers plus the provider_nodes /
provider_connections rows before and after, so collateral damage is caught
and reported, not hidden.
Pitfalls
- Don't test with tiny max_tokens (16–32): free models spend the budget on
reasoning tokens and return empty
finish_reason=length, which looks like a routing bug but isn't. - Don't assume
curl -fpassing means the combo works — a 2xx empty-body response passes-f. Parse the JSON body. - Free-tier endpoints are flaky: a 429/"Endpoint is unavailable" on one model
is usually transient per-model, not a config error — try the other combo
members before changing config. The opposite case is a deterministic 400
Upstream request failed: Model is unavailablethat reproduces across retries and token budgets: that's a dead id — drop it from the combo and synclib/9router.sh. - Some model ids need a different protocol than openai chat completions and
fail with
ModelProtocolUnsupported— exclude them from the combo rather than trying to force them. - Codespace restarts rotate the
ghu_token (it lives in the vscode-server process env, not a file — restart = new PID = new token). The OmniRoute connection holds the old one and latches intoauthentication_error/ "All credentials expired" — that state persists even afterPUT /api/ providers/<id>with a fresh apiKey. Canonical fix (2026-11-01):skills/minions-llm-proxy-ops/scripts/add-ghcodespace-provider.sh --renew— finds the existing connection,DELETE+ re-POSTit with the freshly extractedghu_, then runs a/modelsgate that clears the latch. Node / models / combo untouched. Idempotent — safe to run after every restart. Manual fallback if the script path fails: (1) extract from the live process (/proc/$(pgrep -f server-main.js | head -1)/ environ,GITHUB_TOKEN=line), PUT it to the ghcodespace connection'sapiKey; (2) runbin/omniroute test <node> <any-served-model>— a single successful check clears the latch. Until (2), real completions still 401 with the stale-key error even though the stored key is fresh.
OmniRoute (:20128) does NOT accept this fix
The OpenCode header override is 9Router-specific. Verified live against OmniRoute 3.8.51 — do not waste time re-attempting it:
- OmniRoute has no
/api/providers/<id>/overridesequivalent. - Its open-sse build synthesizes OpenCode headers natively with
OPENCODE_CLIENT/OPENCODE_USER_AGENTenv knobs (in~/.omniroute/.env, loaded at startup). SettingOPENCODE_CLIENT=cli+ the UA and restarting does NOT clear the 403. - Passing the full
x-opencode-*header set on the request itself changes the error fromFreeTierErrortoNo active credentials for provider: opencode— OmniRoute treats a valid CLI identity as a keyed account, not a bypass. POST /api/providers/free-onboardingreturns "not eligible" foropencodeandopencode-zen— a real account/credential is required.- OmniRoute's combo also rots:
opencode-zen/mimo-v2.5-free→ 410 deprecated. - If the OpenCode free tier must be used, route through 9Router (:7352) — it already has the working fix.
See also
wiki/codespace-copilot-llm.md— how the Codespace Copilot panel reaches GitHub's LLM backend; endpoint-shape discovery.wiki/codespace-copilot-mitm-handoff.md— capture findings:auto→MAI-Prod verdict, MAI-variant 400 dictionary, MITM restart/revert playbook.skills/codespace-service-discovery/— the generic "find the backend of X" method this stack's wiring started from.
04 同仓库更多 Skills
version-single-source
Use when adding a new component dependency or versioning a binary in install/boot scripts.
tdd
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
shell-path-login
Use when a binary or script works in one shell context but not another (interactive vs non-interactive login vs non-login shell).
self-update-fix
Fix a failing dependency update PR. Use when a self-update PR's CI fails, or when invoked by scripts/self-update-fix.sh.
pr-change-log
Use when a multi-commit PR needs its description written/updated, or when closing out a long branch with many fix commits.
persistent-knowledge
Persistent skills/knowledge in Codespace via symlinks.