diff --git a/AGENTS.md b/AGENTS.md index af6b97a..79e3af3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -156,8 +156,10 @@ Integration tests run on the staging machine `jarvis` (see "### jarvis (staging) - Decision rows logged before the `run_id` threading landed show up under run_id `"?"` in the dashboard — that's expected, not a bug. -Machine split (Sep 2026): **guppy** is the ollama **model server only**; -**jarvis** is the staging/test target (semif-agent + SemIf engine + deps). +Machine split (Sep 2026): **guppy** hosts the remote **codegen** model (the +12G `qwen38-iq3s`) only; **jarvis** is the staging/test target (semif-agent + +SemIf engine + deps) and runs its **own local ollama** serving the small +self-assessment model (`qwen3.5:4b`). Only codegen traffic travels to guppy. Provision jarvis with `scripts/bootstrap.sh` (see "### jarvis (staging)"). Guppy key facts: @@ -292,11 +294,14 @@ unit tests (24) + box integration tests (2). - **Dev box**: Python 3.13, GTX 780M (Kepler, useless), ~1.4G disk free. Never pip-install heavy deps here. - **guppy box**: Python 3.14, AMD RX 6950 XT (gfx1030), 32 cores, 30G RAM, - passwordless sudo. SemIf runs via llama.cpp **CPU** backend (its llamacpp - backend forces `n_gpu_layers=0`), so the GPU is NOT used by the decision - engine — it IS used by ollama. + passwordless sudo. Now serves **codegen only** (`qwen38-iq3s`). SemIf runs via + llama.cpp **CPU** backend (its llamacpp backend forces `n_gpu_layers=0`), so + the GPU is NOT used by the decision engine — it IS used by ollama. +- **jarvis box**: runs the agent and its **own local ollama** serving the small + self-assessment model (`qwen3.5:4b`). `config.json` `llm.base_url` points at + `http://127.0.0.1:11434/v1`; only `codegen.base_url` points at guppy. - The SemIf tokenizer is fetched from HF (`Qwen/Qwen3.5-4B` at the pinned - revision). Set `HF_HOME=/home/abby/hf` or the tokenizer re-downloads. + revision), cached under each checkout's `.runtime/hf` (`HF_HOME`). ### SemIf install (box) - **Legacy layout** (predates the `.runtime/` containment rule; kept for the @@ -325,19 +330,23 @@ unit tests (24) + box integration tests (2). - The pinned GGUF: `Qwen3.5-4B-Q4_K_M.gguf` from bartowski (2.8G) at `~/models/`. Load ~34s; score ~0.9s/decision on CPU at 8 threads. -### ollama (box) -- Installed at `/home/abby/ollama/bin/ollama` (not on PATH), systemd service - `ollama.service`, ROCm backend with `HSA_OVERRIDE_GFX_VERSION=10.3.0` and KV - cache q4_0 + flash attention. This is expected, not a bug. +### ollama +- **guppy = codegen host.** Installed at `/home/abby/ollama/bin/ollama` (not on + PATH), systemd service `ollama.service`, ROCm backend with + `HSA_OVERRIDE_GFX_VERSION=10.3.0` and KV cache q4_0 + flash attention. Serves + `qwen38-iq3s` (12G 27B, the codegen model). Binds `OLLAMA_HOST=0.0.0.0`, so + jarvis reaches it as a plain remote API at `http://192.168.8.181:11434` (no + auth — LAN-visible, same exposure as the old dashboard POST endpoints). - `semif-hermes` / `semif-hermes-v3` are for ANOTHER project (hermes agent) — ignore them; they spew "token repeat limit" errors. -- Use `qwen3.5:4b` for self-assessment (works, ~3s). `qwen38-iq3s` (12G 27B) - also works but is huge/slow. - If generation hangs with no log output, restart the service (`sudo systemctl restart ollama`) — the ROCm runner can wedge. -- Ollama already binds `OLLAMA_HOST=0.0.0.0`, so jarvis reaches it as a plain - remote API at `http://192.168.8.181:11434` (no auth — LAN-visible, same - exposure as the old dashboard POST endpoints). +- **jarvis = local small model.** Runs its own ollama (`/usr/local/bin/ollama`, + systemd `ollama.service`, `127.0.0.1:11434`) serving `qwen3.5:4b` for + self-assessment (assess/elicitation/fidelity, ~3s). `bootstrap.sh` ensures + that model is pulled; `config.json` `llm.base_url` points here. +- `bootstrap.sh` installs **no ollama**: it expects the target box to already + run one for `llm` (and pulls `llm.model` into it), while codegen is remote. ### jarvis (staging) @@ -345,12 +354,15 @@ unit tests (24) + box integration tests (2). `semif-agent` to a checkout (jarvis keeps it at `~/repos/semif-agent`; the script derives all paths from wherever it is run, so any path works — just register its SSH key on Gitea first), then - `scripts/bootstrap.sh --peer-ollama http://192.168.8.181:11434`. + `scripts/bootstrap.sh --llm-url http://127.0.0.1:11434 --codegen-url http://192.168.8.181:11434`. The script must be run from a checkout — it reads pins from that checkout's `config.example.json` and never re-clones the agent repo (only the SemIf engine and the simplex-chat binary). Idempotent and rerunnable; every stage no-ops on existing state, so it also boots an unknown-state machine. It - installs **no ollama** — llm + codegen both point at guppy. + installs **no ollama**: `llm` is this box's local ollama (bootstrap pulls + `llm.model`), only `codegen` points at the peer guppy. It pulls the pinned + small model into the local ollama and WARNs (never auto-pulls) if the remote + codegen host is missing. - **All installation artifacts live inside the checkout under a gitignored `.runtime/`** (`venv/`, `engine/`, `models/`, `hf/`, `bin/simplex-chat`, `simplex/`, `systemd/`), so an end user can find and debug the whole stack in @@ -372,10 +384,12 @@ unit tests (24) + box integration tests (2). that we intentionally do not install — the llama.cpp CPU path doesn't need them; numpy 2.3.5 is deliberate, 2.2.6 has no cp314 wheel). Same as the box; do not "fix" them by installing torch. -- Generates `config.json` with `codegen.timeout: 3600` (codegen now travels the - LAN), a repo-relative `.runtime/models` GGUF path, and a backup of any prior - file. `--threads N` overrides engine threads; `--copy-data SRC` rsyncs guppy's - `data/` for continuity; `--public-dashboard` binds the dashboard to `0.0.0.0`. +- Generates `config.json` with `llm.base_url` = `--llm-url` (this box, local) and + `codegen.base_url` = `--codegen-url` (the remote codegen host; `codegen.timeout: + 3600` since it travels the LAN), a repo-relative `.runtime/models` GGUF path, + and a backup of any prior file. `--threads N` overrides engine threads; + `--copy-data SRC` rsyncs guppy's `data/` for continuity; `--public-dashboard` + binds the dashboard to `0.0.0.0`. It also enables the SimpleX gateway (`gateway.simplex.enabled = true`, `ws_url` from `simplex_chat.port`) and renders/enables the two user services `semif-simplex.service` (the pinned `simplex-chat` bot daemon, diff --git a/config.example.json b/config.example.json index 1948c42..4bf6c20 100644 --- a/config.example.json +++ b/config.example.json @@ -15,9 +15,13 @@ "context_tokens": 4096, "threads": 8 }, - "llm": {"base_url": "http://localhost:11434/v1", "model": "qwen3.5:4b"}, + "llm": { + "_comment": "Small self-assessment model (assess/elicitation/fidelity review). Runs on THIS machine's local ollama; bootstrap sets base_url from --llm-url (default http://127.0.0.1:11434) and pulls `model` if it is missing. This is deliberately local — only codegen travels to a remote host.", + "base_url": "http://localhost:11434/v1", + "model": "qwen3.5:4b" + }, "codegen": { - "_comment": "OpenAI-compatible model that writes runnable skill bodies. Bodies perform real actions against the user's configured services via stdlib transports, read every operational value from ctx.config, and declare their integration (INTEGRATION: service/transport/config_vars). Larger/slower than the decision or self-assessment model. The transport always streams so the client-side token budget (output cap / peak total fill) can abort a runaway in real time; stream only toggles console echo of tokens. timeout is total seconds; idle_warn/idle_timeout surface a silent (wedged) stream. The context window is auto-detected via ollama /api/show; context_window is the manual fallback (0 = auto/default 100000). smart_limit/warn_limit and max_fill_ratio/warn_fill_ratio bound total fill; max_output caps streamed output (>=1 absolute tokens, 0=1 absolute tokens, 0 $PEER_OLLAMA, runtime -> $RUNTIME)" -python3 - "$REPO_ROOT/config.example.json" "$REPO_ROOT/config.json" "$THREADS" "$PEER_OLLAMA" \ +echo "== writing config.json (llm -> $LLM_URL, codegen -> $CODEGEN_URL, runtime -> $RUNTIME)" +python3 - "$REPO_ROOT/config.example.json" "$REPO_ROOT/config.json" "$THREADS" "$LLM_URL" "$CODEGEN_URL" \ "$([ "$PUBLIC_DASHBOARD" = 1 ] && echo 0.0.0.0 || echo 127.0.0.1)" \ "$REPO_ROOT" "$SIMPLEX_ALLOWED_USERS" "$SIMPLEX_HOME_CHANNEL" "$SIMPLEX_DISPLAY" <<'PY' import json, os, sys -(example, out, threads, peer, dash_host, repo, +(example, out, threads, llm_url, codegen_url, dash_host, repo, allowed_csv, home_channel, display) = sys.argv[1:] cfg = json.load(open(example)) eng = cfg["engine"] @@ -252,13 +264,12 @@ eng["gguf"] = os.path.join(runtime, "models", os.path.basename(eng["gguf_url"])) if threads and threads != "__example__": eng["threads"] = int(threads) # The clients hit {base_url}/chat/completions on ollama's OpenAI-compat path, -# which lives under /v1. The native API (/api/tags, /api/show) has no /v1, so -# the raw `peer` is kept for those; llm/codegen base_url must end in /v1. -base_url = peer.rstrip("/") -if not base_url.endswith("/v1"): - base_url += "/v1" -cfg["llm"]["base_url"] = base_url -cfg["codegen"]["base_url"] = base_url +# which lives under /v1. The native API (/api/tags, /api/show) has no /v1. +def v1(url): + url = url.rstrip("/") + return url if url.endswith("/v1") else url + "/v1" +cfg["llm"]["base_url"] = v1(llm_url) +cfg["codegen"]["base_url"] = v1(codegen_url) cfg["codegen"]["timeout"] = 3600 cfg.setdefault("simplex_chat", {})["display_name"] = display cfg.setdefault("dashboard", {})["port"] = 8765 @@ -345,28 +356,49 @@ if [[ -n "$COPY_DATA" ]]; then rsync -a "$COPY_DATA/" "$REPO_ROOT/data/" fi -# --- stage 10: verify ------------------------------------------------------------------- +# --- stage 10: verify + pull the local self-assessment model ------------------------- echo "== verifying imports" "$PYTHON" -c "import semif_phase1, semif_agent; print('engine + agent import OK')" -echo "== peer ollama check ($PEER_OLLAMA)" -PEER_TAGS="$(curl -sf --max-time 5 "$PEER_OLLAMA/api/tags" || true)" -# The OpenAI-compat chat path is what llm/codegen actually hit; a bare reachable -# root ("Ollama is running") does not prove it. Probe it explicitly. -PEER_V1="$(curl -sf --max-time 60 "$PEER_OLLAMA/v1/chat/completions" -H 'Content-Type: application/json' -d '{"model":"qwen3.5:4b","messages":[{"role":"user","content":"hi"}],"stream":false,"options":{"num_predict":1}}' || true)" -if grep -qE 'chatcmpl|"choices"' <<<"$PEER_V1"; then - echo "peer /v1/chat/completions (OpenAI-compat): OK" + +# The small self-assessment model runs on this machine's local ollama; ensure it +# is pulled so assess/elicitation/fidelity work without a remote dependency. +echo "== llm ollama ($LLM_API), model $LLM_MODEL" +if ! curl -sf --max-time 5 "$LLM_API/api/tags" >/dev/null 2>&1; then + echo "WARN: no local ollama at $LLM_API — install/run ollama and pull $LLM_MODEL" >&2 + echo " (bootstrap installs no ollama; only codegen is remote)" >&2 else - echo "WARN: peer /v1/chat/completions returned no completion — llm/codegen will fail" >&2 + LLM_TAGS="$(curl -sf --max-time 5 "$LLM_API/api/tags" || true)" + if grep -qF "\"$LLM_MODEL\"" <<<"$LLM_TAGS"; then + echo "llm model $LLM_MODEL: present" + else + echo "== pulling llm model $LLM_MODEL from $LLM_API" + if ! curl -sf --max-time 3600 "$LLM_API/api/pull" -H 'Content-Type: application/json' \ + -d "{\"model\":\"$LLM_MODEL\",\"stream\":false}" >/dev/null; then + echo "WARN: /api/pull failed; trying the ollama CLI" >&2 + if command -v ollama >/dev/null 2>&1; then + ollama pull "$LLM_MODEL" || echo "WARN: could not pull $LLM_MODEL" >&2 + else + echo "WARN: could not pull $LLM_MODEL (no ollama CLI)" >&2 + fi + fi + fi + # The OpenAI-compat chat path is what llm actually hits; probe it explicitly. + LLM_V1_OK="$(curl -sf --max-time 60 "$LLM_V1/chat/completions" -H 'Content-Type: application/json' \ + -d "{\"model\":\"$LLM_MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}],\"stream\":false,\"options\":{\"num_predict\":1}}" || true)" + if grep -qE 'chatcmpl|"choices"' <<<"$LLM_V1_OK"; then + echo "llm /v1/chat/completions ($LLM_MODEL): OK" + else + echo "WARN: local llm /v1/chat/completions returned no completion" >&2 + fi fi -if grep -qE "qwen3\.5:4b" <<<"$PEER_TAGS"; then - echo "peer serves qwen3.5:4b (self-assessment): OK" + +# Codegen is the remote larger model (e.g. guppy). Warn only — never auto-pull. +echo "== codegen ollama ($CODEGEN_API)" +CODEGEN_TAGS="$(curl -sf --max-time 5 "$CODEGEN_API/api/tags" || true)" +if grep -qE "qwen38-iq3s" <<<"$CODEGEN_TAGS"; then + echo "codegen serves qwen38-iq3s: OK" else - echo "WARN: peer /api/tags shows no qwen3.5:4b" >&2 -fi -if grep -qE "qwen38-iq3s" <<<"$PEER_TAGS"; then - echo "peer serves qwen38-iq3s (codegen): OK" -else - echo "WARN: peer /api/tags shows no qwen38-iq3s" >&2 + echo "WARN: codegen host $CODEGEN_API serves no qwen38-iq3s (offline? new-skill authoring will fail)" >&2 fi if command -v systemctl >/dev/null 2>&1; then