Run everything on the local model; no cloud tier

GLM-4.7-Flash can reach core over SSH, check, diagnose and upgrade, so
operator messages, alert triage, health findings and the weekly upgrade all
route to the one local profile. The Anthropic profile and its cloud-first
routing go, and with them the API key and metered billing the first draft
needed. The local profile's context_tokens rises to 131072, the window Ollama
loads GLM with, so long runs are not trimmed early.

Profiles and routing stay in configuration: a second model can still be
added, with hand-over when the first is unreachable or fails the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
paulandClaude Opus 5.5 committed 2026-09-26 01:59:28 +12:00
1 parent 61dca2c3ca
commit 9aa1abf0e2
7 files changed
+89 -93

No files matched your search

+30 -39
View File
@@ -9,9 +9,9 @@ stack on AWS Lightsail (`Semprini-Core`) healthy and current:
It is the *unattended driver* for the canonical stack-support agent in the **semprini-core**
repo (`agents/stack-support.agent.md`). The daemon notices events and hands the judgement
calls to that agent, which it runs in-process with [pydantic-ai](https://ai.pydantic.dev) on a
cloud model (Claude) or a local one (Ollama on the workstation's RTX 4090), chosen per kind of
task. Design and decisions: [`docs/architecture.md`](docs/architecture.md).
calls to that agent, which it runs in-process with [pydantic-ai](https://ai.pydantic.dev) on the
workstation's own model: GLM-4.7-Flash on Ollama, on the RTX 4090. Any model pydantic-ai
supports can be configured instead. Design and decisions: [`docs/architecture.md`](docs/architecture.md).
## Talking to it
@@ -24,7 +24,7 @@ Two rooms on chat.semprini.me:
Messages are read with a long-poll `/sync`: the homeserver answers as soon as something is
posted, so there is no polling delay. Every reply ends with a small line saying which model
answered, how long it took and, for a cloud model, what it cost.
answered and how long it took.
A message that is exactly one of these is handled at once, even mid-run:
@@ -35,8 +35,7 @@ A message that is exactly one of these is handled at once, even mid-run:
| `hold 45m <why>` | Stand down for a while: `hold` alone is 30 minutes, 8 hours is the most. Your messages still run and alerts still collect; health checks, triage, upgrades and the service desk wait, and it says so when the hold starts and when it runs out |
| `resume` | End a hold now, this machine's and the core host's |
| `new` | Forget this room's conversation |
| `model` | The model profiles and which kinds of task try which, in order |
| `model local` / `model cloud` | Your messages in this room try that profile first; `model auto` goes back to the default |
| `model` | The model it runs on. With more than one configured, `model <name>` puts that one first for your messages in this room, and `model auto` goes back to the default |
| `upgrade` | Run the weekly upgrade now |
| `help` | The list |
@@ -52,7 +51,7 @@ A message that is exactly one of these is handled at once, even mid-run:
| — Disk ≥ 85%, memory < 400 MB, kernel OOM kill, restart loop, stale Kuma | Investigate and fix; 12h cooldown per finding |
| — Core host rebooted | Verify every stack came back |
| — Core host unreachable for 3 checks | 🚨 in Stack Maintenance (delivered once Matrix, which lives there, is back) |
| Daily, 21:00 UTC | 📋 report: monitors, downtime, alerts, agent runs by model, cloud spend, commits, pending reboot or decision |
| Daily, 21:00 UTC | 📋 report: monitors, downtime, alerts, agent runs, commits, pending reboot or decision |
| Weekly, Sat 22:00 UTC | Upgrade every image and host package on core: test, pin, commit, push, roll back on failure. Majors and reboots are escalated |
| Every minute | Service desk: semprini-core's `service-desk.py`, run on the core host over SSH, fulfils the open requests in [Semprini/service-desk](https://git.semprini.me/Semprini/service-desk). What needs you is posted here: 🙋 an approval (`/approve` or `/reject` on the issue), ⛔ a failure (`/retry` once fixed), 📨 an "Ask core" request, ✅ a finished one. Waits out a hold |
| Hourly | Self-update from this repo |
@@ -72,11 +71,11 @@ image on the core host.
│ (operator > alerts > health > upgrade) │ │ service-desk.py
│ agent.py (pydantic-ai): shell · read/write/edit │ │ ~/semprini-core: the agent
│ file · fetch_url, on a named host │ │ edits, commits and pushes here
└───────┬───────────────────────────┬───────────────┘ └──────────────────────────────
│ cloud │ local
▼ ▼
Anthropic API Ollama on Windows (RTX 4090)
(claude-sonnet-5) (GLM-4.7-Flash) powershell.exe → Hyper-V (read-only)
└───────┬──────────────────────────┬────────────────┘ └──────────────────────────────
│ model │ powershell.exe
▼ ▼
Ollama on Windows (RTX 4090) Hyper-V: the home cluster VMs (inspect only)
GLM-4.7-Flash
```
The agent's result is a typed envelope the daemon relays:
@@ -87,37 +86,31 @@ The agent's result is a typed envelope the daemon relays:
## Models
`config.json` → `models` names profiles; `routing` gives each kind of task the profiles to try,
best first:
One local model does everything: your messages, alert triage, health findings and the weekly
upgrade. In `config.json`:
```json
"models": {
"cloud": {"model": "anthropic:claude-sonnet-5", "api_key": "…"},
"local": {"model": "ollama:hf.co/bartowski/zai-org_GLM-4.7-Flash-GGUF:Q5_K_S",
"base_url": "http://{windows_host}:11434/v1", "context_tokens": 32768}
"base_url": "http://{windows_host}:11434/v1", "context_tokens": 131072}
},
"routing": {"operator": ["cloud", "local"], "alerts": ["local", "cloud"],
"health": ["cloud", "local"], "upgrade": ["cloud"]}
"routing": {"operator": ["local"], "alerts": ["local"], "health": ["local"], "upgrade": ["local"]}
```
- **An unreachable model** (Ollama stopped, an API outage, a revoked key) hands the run to
the next profile at once. When none is left, the task stays queued and the maintainer
reports itself degraded.
- **A run that fails as a run** (the model loops until its budget is spent, or cannot produce
the result) starts again on the next profile, told which commands the failed attempt ran.
- A profile is `provider:model`. `anthropic:` and `ollama:` are built in; `openai:` with a
- A profile is `provider:model`. `ollama:` and `anthropic:` are built in; `openai:` with a
`base_url` is any OpenAI-compatible server (llama.cpp's `llama-server`, vLLM, LM Studio);
anything else pydantic-ai knows (`openai:gpt-…`, `google-gla:…`, `openrouter:…`) works with
its key in `api_key` or the provider's environment variable. `settings` passes model
settings through, e.g. `{"anthropic_effort": "high"}`.
- `limits` caps each run: `request_limit`, `tool_calls_limit`, and `cost_usd` per kind of task
for metered (Anthropic) runs.
**Cloud billing.** pydantic-ai calls the Anthropic API with an API key, billed per token. The
`claude setup-token` subscription token of the Claude Code era does not work here. Claude
Sonnet 5 is $2 / $10 per million input / output tokens; the system prompt, tool list and
conversation are prompt-cached, so repeated steps cost much less. The footer on each reply
and the daily report show the spend.
its key in `api_key` (`--set-api-key <profile>`) or the provider's environment variable.
`settings` passes model settings through. `context_tokens` is the window the model is run
with; older tool output is shortened as a conversation nears it.
- `routing` lists the profiles each kind of task tries, best first. With a second profile in a
list, an unreachable model hands the run to the next at once, and a run that fails as a run
(it loops until its budget is spent, or cannot produce the result) starts again on the next,
told which commands the failed attempt ran.
- `limits` caps each run: `request_limit`, `tool_calls_limit`, and `cost_usd` per kind of task,
which only a priced (cloud) model is held to.
- A cloud model is billed per token and needs an API key; a Claude subscription token (from
`claude setup-token`) is for Claude Code only and does not work here.
**Choosing a local model.** A local model is only useful if it calls tools and *uses what they
return*. `--try-model <profile>` checks both with one request, and checks Ollama's context
@@ -157,7 +150,6 @@ git clone https://git.semprini.me/paul/semprini-maintainer.git ~/semprini-mainta
cd ~/semprini-maintainer
cp config.example.json config.json # then copy matrix.* and gitea.token from the host's config.json
./install.sh # uv, .venv, SSH check, --check, systemd unit, takes over from the host
.venv/bin/python maintainer.py --set-api-key cloud # checks it with one request, saves it
.venv/bin/python maintainer.py --try-model local # tool use and context window
```
@@ -225,10 +217,9 @@ and disable the broader one.
### When no model can run
A revoked or missing API key, Ollama stopped, a provider outage: the agent never started. That
is a *maintainer* outage, not a stack verdict (`AgentUnavailable`). It is tracked per kind of
task, because each kind has its own models: with no cloud key, the cloud-only weekly upgrade
waits while your messages and alerts go to the local model.
Ollama stopped or unreachable, or (for a cloud profile) a revoked key or a provider outage: the
agent never started. That is a *maintainer* outage, not a stack verdict (`AgentUnavailable`). It
is tracked per kind of task, because each kind can be routed to its own models.
- The task stays in the persisted queue; nothing is lost.
- One `⛔ maintainer degraded` message per kind names the likely cause and the fix, then it