bootstrap: split --llm-url (local) from --codegen-url (guppy), pull the local model

The small self-assessment model runs on this box's local ollama; only codegen
travels to the peer host. Replace the single --peer-ollama (which pointed llm
and codegen at guppy) with --llm-url (default http://127.0.0.1:11434) and
--codegen-url (default guppy). Bootstrap now pulls llm.model from the local
ollama if missing (API /api/pull, CLI fallback) and probes llm and codegen
separately (codegen WARN-only, never auto-pulled). Correct AGENTS: guppy is the
codegen host, jarvis runs its own ollama for qwen3.5:4b.
This commit is contained in:
Denton Social committed 2026-09-26 19:27:12 -05:00
1 parent 221edb827e
commit 5f05c5c749
3 files changed
+109 -59

No files matched your search

+35 -21
View File
@@ -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 - Decision rows logged before the `run_id` threading landed show up under
run_id `"?"` in the dashboard — that's expected, not a bug. run_id `"?"` in the dashboard — that's expected, not a bug.
Machine split (Sep 2026): **guppy** is the ollama **model server only**; Machine split (Sep 2026): **guppy** hosts the remote **codegen** model (the
**jarvis** is the staging/test target (semif-agent + SemIf engine + deps). 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)"). Provision jarvis with `scripts/bootstrap.sh` (see "### jarvis (staging)").
Guppy key facts: 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 - **Dev box**: Python 3.13, GTX 780M (Kepler, useless), ~1.4G disk free. Never
pip-install heavy deps here. pip-install heavy deps here.
- **guppy box**: Python 3.14, AMD RX 6950 XT (gfx1030), 32 cores, 30G RAM, - **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 passwordless sudo. Now serves **codegen only** (`qwen38-iq3s`). SemIf runs via
backend forces `n_gpu_layers=0`), so the GPU is NOT used by the decision llama.cpp **CPU** backend (its llamacpp backend forces `n_gpu_layers=0`), so
engine — it IS used by ollama. 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 - 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) ### SemIf install (box)
- **Legacy layout** (predates the `.runtime/` containment rule; kept for the - **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 - 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. `~/models/`. Load ~34s; score ~0.9s/decision on CPU at 8 threads.
### ollama (box) ### ollama
- Installed at `/home/abby/ollama/bin/ollama` (not on PATH), systemd service - **guppy = codegen host.** Installed at `/home/abby/ollama/bin/ollama` (not on
`ollama.service`, ROCm backend with `HSA_OVERRIDE_GFX_VERSION=10.3.0` and KV PATH), systemd service `ollama.service`, ROCm backend with
cache q4_0 + flash attention. This is expected, not a bug. `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) — - `semif-hermes` / `semif-hermes-v3` are for ANOTHER project (hermes agent) —
ignore them; they spew "token repeat limit" errors. 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 - If generation hangs with no log output, restart the service
(`sudo systemctl restart ollama`) — the ROCm runner can wedge. (`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 - **jarvis = local small model.** Runs its own ollama (`/usr/local/bin/ollama`,
remote API at `http://192.168.8.181:11434` (no auth — LAN-visible, same systemd `ollama.service`, `127.0.0.1:11434`) serving `qwen3.5:4b` for
exposure as the old dashboard POST endpoints). 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) ### 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 `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 script derives all paths from wherever it is run, so any path works — just
register its SSH key on Gitea first), then 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 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 `config.example.json` and never re-clones the agent repo (only the SemIf
engine and the simplex-chat binary). Idempotent and rerunnable; every stage 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 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 - **All installation artifacts live inside the checkout under a gitignored
`.runtime/`** (`venv/`, `engine/`, `models/`, `hf/`, `bin/simplex-chat`, `.runtime/`** (`venv/`, `engine/`, `models/`, `hf/`, `bin/simplex-chat`,
`simplex/`, `systemd/`), so an end user can find and debug the whole stack in `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 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; 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. do not "fix" them by installing torch.
- Generates `config.json` with `codegen.timeout: 3600` (codegen now travels the - Generates `config.json` with `llm.base_url` = `--llm-url` (this box, local) and
LAN), a repo-relative `.runtime/models` GGUF path, and a backup of any prior `codegen.base_url` = `--codegen-url` (the remote codegen host; `codegen.timeout:
file. `--threads N` overrides engine threads; `--copy-data SRC` rsyncs guppy's 3600` since it travels the LAN), a repo-relative `.runtime/models` GGUF path,
`data/` for continuity; `--public-dashboard` binds the dashboard to `0.0.0.0`. 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`, It also enables the SimpleX gateway (`gateway.simplex.enabled = true`,
`ws_url` from `simplex_chat.port`) and renders/enables the two user services `ws_url` from `simplex_chat.port`) and renders/enables the two user services
`semif-simplex.service` (the pinned `simplex-chat` bot daemon, `semif-simplex.service` (the pinned `simplex-chat` bot daemon,
+6 -2
View File
@@ -15,9 +15,13 @@
"context_tokens": 4096, "context_tokens": 4096,
"threads": 8 "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": { "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<x<1 fraction of window); chars_per_token converts chars to the token estimate. temperature/top_p/presence_penalty/frequency_penalty follow the Qwen3.8 model card's instruct-mode anti-repetition guidance (high presence_penalty, not greedy temperature); generate_skill_body escalates to presence 2.0 / temp 0.5 on retries (max_attempts attempts, fresh short prompt each time). elicitation asks the product owner implementation questions before the body is written (REPL inline; dashboard deferred). After the body lands it is reviewed for real-action fidelity, then the data contract (contract.json) is derived in a separate call, then skill.test.py (hermetic mechanics test: loopback http.server for HTTP bodies, fixtures inline, no external network) in a shared-context call, and the test is auto-run as a subprocess (test_timeout seconds); on failure a 3-option SemIf decision (code/contract/test) regenerates the failing piece, bounded by test_max_attempts. contract_search.enabled auto-populates the skill config.json via SemIf against the global + category config.", "_comment": "OpenAI-compatible model that writes runnable skill bodies. Runs on a REMOTE ollama host (bootstrap sets base_url from --codegen-url, default guppy http://192.168.8.181:11434); the local small model is `llm` above. 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<x<1 fraction of window); chars_per_token converts chars to the token estimate. temperature/top_p/presence_penalty/frequency_penalty follow the Qwen3.8 model card's instruct-mode anti-repetition guidance (high presence_penalty, not greedy temperature); generate_skill_body escalates to presence 2.0 / temp 0.5 on retries (max_attempts attempts, fresh short prompt each time). elicitation asks the product owner implementation questions before the body is written (REPL inline; dashboard deferred). After the body lands it is reviewed for real-action fidelity, then the data contract (contract.json) is derived in a separate call, then skill.test.py (hermetic mechanics test: loopback http.server for HTTP bodies, fixtures inline, no external network) in a shared-context call, and the test is auto-run as a subprocess (test_timeout seconds); on failure a 3-option SemIf decision (code/contract/test) regenerates the failing piece, bounded by test_max_attempts. contract_search.enabled auto-populates the skill config.json via SemIf against the global + category config.",
"base_url": "http://localhost:11434/v1", "base_url": "http://localhost:11434/v1",
"model": "qwen38-iq3s", "model": "qwen38-iq3s",
"timeout": 1200, "timeout": 1200,
+68 -36
View File
@@ -2,8 +2,9 @@
# Provision a new Ubuntu machine into a running semif-agent staging box. # Provision a new Ubuntu machine into a running semif-agent staging box.
# #
# Idempotent: safe to rerun; every stage no-ops on already-provisioned state, # Idempotent: safe to rerun; every stage no-ops on already-provisioned state,
# so it can also bootstrap a machine of unknown state. All LLM traffic points # so it can also bootstrap a machine of unknown state. The small self-assessment
# at a peer ollama endpoint (default: guppy) — this script installs NO ollama. # model runs on this machine's local ollama (bootstrap pulls it); only codegen
# points at a remote ollama host (default: guppy). This script installs NO ollama.
# #
# Must be run from a semif-agent checkout (it reads pins from this checkout's # Must be run from a semif-agent checkout (it reads pins from this checkout's
# config.example.json); the checkout is used as-is and never re-cloned — only # config.example.json); the checkout is used as-is and never re-cloned — only
@@ -25,15 +26,16 @@
# truth; bump those and rerun to upgrade. # truth; bump those and rerun to upgrade.
# #
# Usage: # Usage:
# scripts/bootstrap.sh [--peer-ollama URL] [--threads N] [--copy-data SRC] # scripts/bootstrap.sh [--llm-url URL] [--codegen-url URL] [--threads N]
# [--public-dashboard] # [--copy-data SRC] [--public-dashboard]
# [--simplex-allowed-users CSV] [--simplex-home-channel X] # [--simplex-allowed-users CSV] [--simplex-home-channel X]
# [--simplex-display-name NAME] [-h] # [--simplex-display-name NAME] [-h]
# #
# Run as the human user; sudo is used internally for system bits. # Run as the human user; sudo is used internally for system bits.
set -euo pipefail set -euo pipefail
PEER_OLLAMA="http://192.168.8.181:11434" LLM_URL="http://127.0.0.1:11434"
CODEGEN_URL="http://192.168.8.181:11434"
THREADS="" THREADS=""
COPY_DATA="" COPY_DATA=""
PUBLIC_DASHBOARD=0 PUBLIC_DASHBOARD=0
@@ -42,9 +44,10 @@ SIMPLEX_HOME_CHANNEL=""
SIMPLEX_DISPLAY_NAME="" SIMPLEX_DISPLAY_NAME=""
usage() { usage() {
sed -n '2,31p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//' sed -n '2,32p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
echo echo
echo " --peer-ollama URL remote ollama API for llm+codegen (default: $PEER_OLLAMA)" echo " --llm-url URL ollama API for the small self-assessment model (default: $LLM_URL; this machine)"
echo " --codegen-url URL ollama API for codegen skill bodies (default: $CODEGEN_URL)"
echo " --threads N engine threads for config.json (default: config.example value)" echo " --threads N engine threads for config.json (default: config.example value)"
echo " --copy-data SRC rsync SRC (e.g. abby@box:~/repos/semif-agent/data) to data/ — opt-in" echo " --copy-data SRC rsync SRC (e.g. abby@box:~/repos/semif-agent/data) to data/ — opt-in"
echo " --public-dashboard bind dashboard to 0.0.0.0 instead of 127.0.0.1" echo " --public-dashboard bind dashboard to 0.0.0.0 instead of 127.0.0.1"
@@ -57,7 +60,8 @@ usage() {
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--peer-ollama) PEER_OLLAMA="$2"; shift 2 ;; --llm-url) LLM_URL="$2"; shift 2 ;;
--codegen-url) CODEGEN_URL="$2"; shift 2 ;;
--threads) THREADS="$2"; shift 2 ;; --threads) THREADS="$2"; shift 2 ;;
--copy-data) COPY_DATA="$2"; shift 2 ;; --copy-data) COPY_DATA="$2"; shift 2 ;;
--public-dashboard) PUBLIC_DASHBOARD=1; shift ;; --public-dashboard) PUBLIC_DASHBOARD=1; shift ;;
@@ -91,7 +95,7 @@ fi
# --- read pins from config.example.json ------------------------------------ # --- read pins from config.example.json ------------------------------------
read -r SEMIF_REPO SEMIF_REF GGUF_URL GGUF_SHA256 HF_SOURCE HF_REV \ read -r SEMIF_REPO SEMIF_REF GGUF_URL GGUF_SHA256 HF_SOURCE HF_REV \
SIMPLEX_BIN_URL SIMPLEX_SHA256 SIMPLEX_PORT SIMPLEX_DISPLAY < <( SIMPLEX_BIN_URL SIMPLEX_SHA256 SIMPLEX_PORT SIMPLEX_DISPLAY LLM_MODEL < <(
python3 - "$EXAMPLE" <<'PY' python3 - "$EXAMPLE" <<'PY'
import json, sys import json, sys
cfg = json.load(open(sys.argv[1])) cfg = json.load(open(sys.argv[1]))
@@ -110,6 +114,7 @@ print(
str(s.get("sha256", "")), str(s.get("sha256", "")),
str(s.get("port", "")), str(s.get("port", "")),
str(s.get("display_name", "")), str(s.get("display_name", "")),
str(cfg.get("llm", {}).get("model", "")),
] ]
) )
) )
@@ -130,7 +135,14 @@ if [[ -n "$SIMPLEX_DISPLAY_NAME" ]]; then
fi fi
SIMPLEX_DISPLAY="${SIMPLEX_DISPLAY:-semif}" SIMPLEX_DISPLAY="${SIMPLEX_DISPLAY:-semif}"
echo "== pins: semif @ $SEMIF_REF | gguf sha256 ${GGUF_SHA256:0:12}… | simplex-chat sha256 ${SIMPLEX_SHA256:0:12}… | peer $PEER_OLLAMA" # Native ollama API bases (no /v1) for tags/pull; the clients use /v1.
LLM_API="${LLM_URL%/v1}"; LLM_API="${LLM_API%/}"
CODEGEN_API="${CODEGEN_URL%/v1}"; CODEGEN_API="${CODEGEN_API%/}"
with_v1() { local u="${1%/}"; [[ "$u" == */v1 ]] && printf '%s' "$u" || printf '%s/v1' "$u"; }
LLM_V1="$(with_v1 "$LLM_URL")"
echo "== pins: semif @ $SEMIF_REF | gguf sha256 ${GGUF_SHA256:0:12}… | simplex-chat sha256 ${SIMPLEX_SHA256:0:12}…"
echo "== llm $LLM_URL (local, model $LLM_MODEL) | codegen $CODEGEN_URL"
echo "== runtime tree: $RUNTIME" echo "== runtime tree: $RUNTIME"
mkdir -p "$RUNTIME" "$MODELS" "$HF_CACHE" "$TOOLDIR" "$SIMPLEX_DB" "$UNITS" "$USER_UNITS" mkdir -p "$RUNTIME" "$MODELS" "$HF_CACHE" "$TOOLDIR" "$SIMPLEX_DB" "$UNITS" "$USER_UNITS"
@@ -238,12 +250,12 @@ echo "== simplex-chat verified ($SIMPLEX_BIN)"
if [[ -f "$REPO_ROOT/config.json" ]]; then if [[ -f "$REPO_ROOT/config.json" ]]; then
cp "$REPO_ROOT/config.json" "$REPO_ROOT/config.json.bak.$(date +%s)" cp "$REPO_ROOT/config.json" "$REPO_ROOT/config.json.bak.$(date +%s)"
fi fi
echo "== writing config.json (llm/codegen -> $PEER_OLLAMA, runtime -> $RUNTIME)" echo "== writing config.json (llm -> $LLM_URL, codegen -> $CODEGEN_URL, runtime -> $RUNTIME)"
python3 - "$REPO_ROOT/config.example.json" "$REPO_ROOT/config.json" "$THREADS" "$PEER_OLLAMA" \ 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)" \ "$([ "$PUBLIC_DASHBOARD" = 1 ] && echo 0.0.0.0 || echo 127.0.0.1)" \
"$REPO_ROOT" "$SIMPLEX_ALLOWED_USERS" "$SIMPLEX_HOME_CHANNEL" "$SIMPLEX_DISPLAY" <<'PY' "$REPO_ROOT" "$SIMPLEX_ALLOWED_USERS" "$SIMPLEX_HOME_CHANNEL" "$SIMPLEX_DISPLAY" <<'PY'
import json, os, sys 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:] allowed_csv, home_channel, display) = sys.argv[1:]
cfg = json.load(open(example)) cfg = json.load(open(example))
eng = cfg["engine"] 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__": if threads and threads != "__example__":
eng["threads"] = int(threads) eng["threads"] = int(threads)
# The clients hit {base_url}/chat/completions on ollama's OpenAI-compat path, # 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 # which lives under /v1. The native API (/api/tags, /api/show) has no /v1.
# the raw `peer` is kept for those; llm/codegen base_url must end in /v1. def v1(url):
base_url = peer.rstrip("/") url = url.rstrip("/")
if not base_url.endswith("/v1"): return url if url.endswith("/v1") else url + "/v1"
base_url += "/v1" cfg["llm"]["base_url"] = v1(llm_url)
cfg["llm"]["base_url"] = base_url cfg["codegen"]["base_url"] = v1(codegen_url)
cfg["codegen"]["base_url"] = base_url
cfg["codegen"]["timeout"] = 3600 cfg["codegen"]["timeout"] = 3600
cfg.setdefault("simplex_chat", {})["display_name"] = display cfg.setdefault("simplex_chat", {})["display_name"] = display
cfg.setdefault("dashboard", {})["port"] = 8765 cfg.setdefault("dashboard", {})["port"] = 8765
@@ -345,28 +356,49 @@ if [[ -n "$COPY_DATA" ]]; then
rsync -a "$COPY_DATA/" "$REPO_ROOT/data/" rsync -a "$COPY_DATA/" "$REPO_ROOT/data/"
fi fi
# --- stage 10: verify ------------------------------------------------------------------- # --- stage 10: verify + pull the local self-assessment model -------------------------
echo "== verifying imports" echo "== verifying imports"
"$PYTHON" -c "import semif_phase1, semif_agent; print('engine + agent import OK')" "$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 small self-assessment model runs on this machine's local ollama; ensure it
# The OpenAI-compat chat path is what llm/codegen actually hit; a bare reachable # is pulled so assess/elicitation/fidelity work without a remote dependency.
# root ("Ollama is running") does not prove it. Probe it explicitly. echo "== llm ollama ($LLM_API), model $LLM_MODEL"
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 ! curl -sf --max-time 5 "$LLM_API/api/tags" >/dev/null 2>&1; then
if grep -qE 'chatcmpl|"choices"' <<<"$PEER_V1"; then echo "WARN: no local ollama at $LLM_API — install/run ollama and pull $LLM_MODEL" >&2
echo "peer /v1/chat/completions (OpenAI-compat): OK" echo " (bootstrap installs no ollama; only codegen is remote)" >&2
else 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
if grep -qE "qwen3\.5:4b" <<<"$PEER_TAGS"; then
echo "peer serves qwen3.5:4b (self-assessment): OK"
else
echo "WARN: peer /api/tags shows no qwen3.5:4b" >&2
fi fi
if grep -qE "qwen38-iq3s" <<<"$PEER_TAGS"; then fi
echo "peer serves qwen38-iq3s (codegen): OK" # 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 else
echo "WARN: peer /api/tags shows no qwen38-iq3s" >&2 echo "WARN: local llm /v1/chat/completions returned no completion" >&2
fi
fi
# 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: codegen host $CODEGEN_API serves no qwen38-iq3s (offline? new-skill authoring will fail)" >&2
fi fi
if command -v systemctl >/dev/null 2>&1; then if command -v systemctl >/dev/null 2>&1; then