No description
Find a file
2026-11-04 10:13:16 +01:00
src chore(deps): ureq 2.12 -> 3.5, the version the code was written against is two majors behind 2026-11-03 09:57:22 +01:00
tests test(parity): a missing Python reference is a failure, not a skip 2026-10-31 09:07:30 +01:00
.gitignore chore: initial commit 2026-10-30 12:45:06 +01:00
Cargo.lock chore(deps): ureq 3.5.1 (connection reuse and cookie header fixes) 2026-11-04 10:13:16 +01:00
Cargo.toml chore(deps): ureq 2.12 -> 3.5, the version the code was written against is two majors behind 2026-11-03 09:57:22 +01:00
README.md fix: the default endpoint is no longer a private address 2026-11-03 09:12:08 +01:00

ollama-check (Rust)

Rust-Port von ~/.hermes/scripts/ollama_check.py. Fragt /api/ps der Ollama-Instanz ab und meldet, wie viele Instanzen laufen und wie viele Slots frei sind — die Entscheidungsgrundlage vor jedem Subagenten-Spawn.

Warum

Das Python-Skript läuft bei jedem Agenten-Lauf, oft mehrmals (vor jedem Spawn). Der Rust-Port startet in ~2 ms statt ~20 ms, braucht keine Interpreter-Abhängigkeit und ist byte-identisch in der Ausgabe — damit die Aufrufer in SOUL.md und .hermes.md unverändert bleiben können.

Bauen und installieren

cargo build --release
install -m 755 target/release/ollama-check ~/bin/ollama-check

Benutzen

ollama-check          # JSON
ollama-check --human  # menschenlesbar
ollama-check --slots  # nur <frei>/<max>

Umgebung:

  • OLLAMA_URL — Default http://127.0.0.1:11434 (lokale Ollama-Instanz). Für eine Instanz auf einem anderen Host oder hinter einem Proxy muss die Variable gesetzt werden; die Adresse steht bewusst nicht im Quellcode.
  • OLLAMA_MAX_INSTANCES — Default 3

Exit-Code: 0 = Slot frei, 1 = Pool voll oder API nicht erreichbar, 2 = Aufruffehler. Bei nicht erreichbarer API wird dasselbe JSON-Fehlerobjekt wie im Original ausgegeben ({"error": ..., "running": -1, "free": -1, "max": N}).

Tests

cargo test
  • json_output_matches_python — Rust und Python gegen denselben Mock-Server, Byte-Vergleich bis auf den Timestamp-Wert
  • slots_output_matches_python — --slots byte-identisch, gleicher Exit-Code
  • human_output_matches_python — --human byte-identisch
  • full_pool_exits_one — drei laufende Instanzen → 0/3, Exit 1
  • unreachable_api_reports_error_and_exits_one — Fehlerobjekt, Exit 1

Die Paritätstests überspringen sich selbst, wenn python3 oder das Original fehlt.

Gemessen (2026-10-29)

Rust    ~2 ms Start
Python  ~20 ms Start

Verifiziert mit diff gegen das Original auf der echten API: identische Ausgabe.