Skip to content

Autonomous OODA-loop pentesting agent. Hermes brain, Kali + Playwright tools over MCP, ATT&CK as the Orient language.

feat: opt-in local/remote Ollama inference via OLLAMA_BASE_URL

irrazb0949a8a8384
diff --git a/.env.example b/.env.example
index 135bd7c..5136ce4 100644
--- a/.env.example
+++ b/.env.example
@@ -17,6 +17,27 @@ OPENROUTER_API_KEY=
# agent refuse to work.
OPENROUTER_MODEL=
+# --- Local/remote Ollama inference (OPTIONAL, opt-in) -------------------------
+# Empty = use OpenRouter (default behavior; OPENROUTER_API_KEY is required above).
+# Set OLLAMA_BASE_URL to an Ollama OpenAI-compatible endpoint to use Ollama INSTEAD of
+# OpenRouter. In that case OPENROUTER_API_KEY is NOT required.
+# - Local Ollama on the host: http://host.docker.internal:11434/v1
+# - Remote Ollama host: http://<host>:11434/v1
+# On Linux, reaching a host-run Ollama relies on the extra_hosts
+# "host.docker.internal:host-gateway" mapping (already set on ooda-agent in docker-compose.yml).
+# Also start Ollama listening on all interfaces so the container can reach it: OLLAMA_HOST=0.0.0.0.
+OLLAMA_BASE_URL=
+
+# OLLAMA_MODEL: the Ollama model name used when OLLAMA_BASE_URL is set, e.g. qwen2.5-coder:32b.
+OLLAMA_MODEL=
+# CAVEAT 1 (context window): Hermes refuses to start against an endpoint serving less than
+# ~64K tokens of context, and Ollama defaults to as low as 4K. Raise it SERVER-SIDE when you
+# run Ollama: OLLAMA_CONTEXT_LENGTH=64000 (it cannot be raised via the API).
+# CAVEAT 2 (model suitability): the chosen model MUST support reliable tool/function-calling
+# (every pentest action routes through MCP) and must not refuse the authorized-offensive
+# pentest framing. Parity with Mistral-Large-on-OpenRouter is NOT guaranteed; treat local
+# inference as experimental and validate the model before relying on it.
+
# --- Hermes API server --------------------------------------------------------
# REQUIRED. Key for Hermes' internal API server (min. 8 chars). Generate one with:
# openssl rand -hex 32
diff --git a/README.md b/README.md
index a6cd934..9ec37d2 100644
--- a/README.md
+++ b/README.md
@@ -69,6 +69,36 @@ change them. Once your `.env` is ready:
docker compose up -d --build
```
+### Local inference with Ollama (optional)
+
+By default Hermes reasons with Mistral Large on OpenRouter. If you prefer to run the model
+yourself, you can point Hermes at an [Ollama](https://ollama.com) endpoint (OpenAI-compatible)
+instead. This is **opt-in** and fully controlled from the `.env`:
+
+| Variable | Required | Where to put it / how to get it |
+| --- | --- | --- |
+| `OLLAMA_BASE_URL` | No | Empty = use OpenRouter (default). Set it to an Ollama OpenAI-compatible endpoint to use Ollama instead: `http://host.docker.internal:11434/v1` for a local host Ollama, or `http://<host>:11434/v1` for a remote one. When set, `OPENROUTER_API_KEY` is **not** required. |
+| `OLLAMA_MODEL` | No | The Ollama model name used in Ollama mode, e.g. `qwen2.5-coder:32b`. |
+
+At startup the stack branches on `OLLAMA_BASE_URL`: when it is empty the OpenRouter path is used
+exactly as before (and a missing `OPENROUTER_API_KEY` still aborts startup); when it is set, the
+startup script runs `hermes config set model.provider custom`, `model.base_url <OLLAMA_BASE_URL>`
+and `model.default <OLLAMA_MODEL>`, so Hermes talks to Ollama.
+
+Caveats before you rely on it:
+
+- **Context window (hard blocker):** Hermes refuses to start against an endpoint serving less than
+ ~64K tokens of context, and Ollama defaults to as low as 4K. Raise it **server-side** where Ollama
+ runs with `OLLAMA_CONTEXT_LENGTH=64000` (it cannot be raised through the API).
+- **Networking:** make Ollama listen on all interfaces (`OLLAMA_HOST=0.0.0.0`) so the container can
+ reach it. On Linux, reaching a host-run Ollama relies on the
+ `extra_hosts: ["host.docker.internal:host-gateway"]` mapping already set on `ooda-agent` (Docker
+ Desktop on macOS/Windows resolves `host.docker.internal` automatically).
+- **Model suitability (experimental):** every pentest action routes through MCP, so the model must do
+ reliable tool/function-calling and must not refuse the authorized-offensive pentest framing. Parity
+ with Mistral-Large-on-OpenRouter is **not guaranteed** — treat local inference as experimental and
+ validate your chosen model before relying on it.
+
## How to drive the pentest (interactive TUI)
```sh
diff --git a/VERSION b/VERSION
index 7dea76e..9084fa2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.1
+1.1.0
diff --git a/agent-ooda/profile/config.yaml b/agent-ooda/profile/config.yaml
index b55c964..655ded7 100644
--- a/agent-ooda/profile/config.yaml
+++ b/agent-ooda/profile/config.yaml
@@ -27,6 +27,11 @@ model:
# variable de entorno OPENROUTER_MODEL (ver docker-compose.yml / .env.example): si OPENROUTER_MODEL
# esta definida y no vacia, el arranque hace `hermes config set model.default <valor>`; si esta
# vacia o sin definir, se usa este valor tal cual.
+ # INFERENCIA LOCAL/REMOTA (opcional): si se define OLLAMA_BASE_URL en el .env, el arranque
+ # selecciona un endpoint Ollama (OpenAI-compatible) en tiempo de ejecucion via
+ # `hermes config set model.provider custom` + `model.base_url <OLLAMA_BASE_URL>` +
+ # `model.default <OLLAMA_MODEL>`, y Hermes usa Ollama en vez de OpenRouter. Si OLLAMA_BASE_URL
+ # esta vacia/sin definir, el fallback es OpenRouter + este model.default (sin cambios).
default: "mistralai/mistral-large-4-0"
# --- Primer servidor MCP: la Kali (contenedor `kali`) -----------------------
diff --git a/docker-compose.yml b/docker-compose.yml
index e82e353..9a7ebc5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -89,11 +89,36 @@ services:
cp -r /opt/profile-src/skills/. "$$DEF/skills/" 2>/dev/null || true
# (b) inject the API server KEY (secret, not versioned) BEFORE starting.
hermes config set platforms.api_server.key "$$HERMES_API_SERVER_KEY" >/dev/null
- # (b2) OPTIONAL model override: if OPENROUTER_MODEL is set and non-empty, override
- # model.default at runtime. If empty/unset, do nothing so the profile's model.default
- # (mistralai/mistral-large-4-0) is used as-is (fallback).
- if [ -n "$$OPENROUTER_MODEL" ]; then
- hermes config set model.default "$$OPENROUTER_MODEL" >/dev/null
+ # (b2) LLM PROVIDER SELECTION (opt-in, fallback = OpenRouter):
+ if [ -n "$$OLLAMA_BASE_URL" ]; then
+ # --- Ollama mode -------------------------------------------------------
+ # OLLAMA_BASE_URL is set => point Hermes at a local/remote Ollama endpoint
+ # (OpenAI-compatible). OPENROUTER_API_KEY is NOT required in this branch.
+ # Hermes reaches the endpoint via the generic OpenAI-compatible "custom"
+ # provider: provider=custom + model.base_url (confirmed key names against the
+ # nousresearch/hermes-agent image: `hermes config set model.provider|base_url|default`).
+ hermes config set model.provider custom >/dev/null
+ hermes config set model.base_url "$$OLLAMA_BASE_URL" >/dev/null
+ # Ollama model name (only if provided; otherwise the profile default is kept,
+ # though for Ollama you normally want an Ollama-served model name here).
+ if [ -n "$$OLLAMA_MODEL" ]; then
+ hermes config set model.default "$$OLLAMA_MODEL" >/dev/null
+ fi
+ else
+ # --- OpenRouter mode (default, OLLAMA_BASE_URL empty) ------------------
+ # Preserve EXACTLY today's v1.0.1 behavior. The compose var no longer uses the
+ # fail-closed `:?` form (so Ollama mode can boot without a key), so re-create the
+ # fail-closed guarantee here: a missing OPENROUTER_API_KEY aborts with non-zero exit.
+ if [ -z "$$OPENROUTER_API_KEY" ]; then
+ echo "ERROR: OPENROUTER_API_KEY is empty. Set it in .env (OpenRouter mode) or set OLLAMA_BASE_URL to use Ollama instead." >&2
+ exit 1
+ fi
+ # OPTIONAL model override: if OPENROUTER_MODEL is set and non-empty, override
+ # model.default at runtime. If empty/unset, do nothing so the profile's model.default
+ # (mistralai/mistral-large-4-0) is used as-is (fallback).
+ if [ -n "$$OPENROUTER_MODEL" ]; then
+ hermes config set model.default "$$OPENROUTER_MODEL" >/dev/null
+ fi
fi
# (c) start the default profile gateway: foreground (live container) + API server.
exec hermes gateway run
@@ -104,13 +129,23 @@ services:
HERMES_API_SERVER_KEY: "${HERMES_API_SERVER_KEY:?Falta HERMES_API_SERVER_KEY - genera uno con 'openssl rand -hex 32' (min 8 chars) y ponlo en .env}"
API_SERVER_KEY: "${HERMES_API_SERVER_KEY}"
# API key for Hermes' LLM provider. Hermes reads the LLM key from THIS env var
- # (OPENROUTER_API_KEY), which is why HERMES_LLM_API_KEY is NOT declared. Required
- # fail-closed: without it the agent cannot reason.
- OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:?Falta OPENROUTER_API_KEY - define la API key de OpenRouter en .env}"
+ # (OPENROUTER_API_KEY), which is why HERMES_LLM_API_KEY is NOT declared. NO LONGER
+ # fail-closed at the compose level (`:-` default), so the stack can boot in Ollama mode
+ # without an OpenRouter key. The fail-closed guarantee is re-created IN the startup script:
+ # when OLLAMA_BASE_URL is empty (OpenRouter mode) an empty OPENROUTER_API_KEY aborts startup.
+ OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:-}"
# OPTIONAL OpenRouter model override (NOT fail-closed): empty default. When set and
# non-empty, the startup command runs 'hermes config set model.default' to override the
# profile's model.default; when empty/unset, the profile default is used (fallback).
OPENROUTER_MODEL: "${OPENROUTER_MODEL:-}"
+ # --- Local/remote Ollama inference (OPTIONAL, opt-in) ---
+ # OLLAMA_BASE_URL: empty/unset => use OpenRouter (default, unchanged). Set to an Ollama
+ # OpenAI-compatible endpoint (local http://host.docker.internal:11434/v1, or a remote
+ # http://<host>:11434/v1) to make Hermes use Ollama instead; OPENROUTER_API_KEY is then
+ # not required. The startup script branches on this var.
+ OLLAMA_BASE_URL: "${OLLAMA_BASE_URL:-}"
+ # OLLAMA_MODEL: the Ollama model name used when OLLAMA_BASE_URL is set (e.g. qwen2.5-coder:32b).
+ OLLAMA_MODEL: "${OLLAMA_MODEL:-}"
volumes:
# NAMED VOLUME REQUIRED (never a bind-mount): Hermes' state.db SQLite in WAL mode
# GETS CORRUPTED on bind-mounts that cross the macOS VM (virtiofs).
@@ -139,6 +174,12 @@ services:
# Wait until the browser MCP is healthy before starting.
playwright-mcp:
condition: service_healthy
+ # host.docker.internal mapping so a host-run Ollama (OLLAMA_BASE_URL=http://host.docker.internal:11434/v1)
+ # is reachable on LINUX too (Docker Desktop on macOS/Windows resolves it automatically; the explicit
+ # host-gateway mapping is harmless there and makes the Linux host case work out of the box). Only
+ # relevant when using host Ollama; ignored otherwise.
+ extra_hosts:
+ - "host.docker.internal:host-gateway"
restart: unless-stopped
# Default compose network: reaches kali:8900 and playwright-mcp:8931 via internal DNS.