04 - Operations Cheat Sheet
7/30/2026, 9:14:46 PM · updated 7/30/2026, 11:41:45 PM
A consolidated daily-reference guide for managing an LLM operations stack — covering health checks, service restarts, model management, API keys, knowledge-base updates, and routine maintenance.
This guide consolidates daily operations for the local AI infrastructure into a single reference. It covers startup commands, server management, API key provisioning, maintenance schedules, and troubleshooting steps so you can keep the system running smoothly without searching through multiple documents.
Core Operations & Quick Access
The five buttons (double-click at the root of AI_DATA)
| Button | Does | Use it when |
|---|---|---|
Status-AI.command | Health check — services, resident models, latency | Something feels off, or weekly review |
Restart-Agent-Server.command | Restarts only the agent-server (port 8788) | After changing agent-server code or config |
Sync-Knowledge-Base.command | Ingests new/changed documents | After adding files to a knowledge bank |
Backup-AI.command | Backs up irreplaceable state | Weekly, and before any risky change |
Setup-MCP-Fetch.command / Setup-MCP-WebSearch.command | Enable web-reading / web-search tools | Once each, in that order |
Most useful single command:
/Volumes/AI_DATA/Status-AI.command watch
Leave it open in a Terminal tab — refreshes every 5 seconds.
Emergency: something's broken
- Run
Status-AI.command— find which service is down. - Agent-server down →
Restart-Agent-Server.command. - Ollama down →
stop-ai-stack.command, thenstart-ai-stack.command. - Both look up but requests fail →
Status-AI.command logs, read the error. - Nothing works at all → check whether the
AI_DATAvolume is even mounted.
Server Management & Configuration
The two servers — don't confuse them
| Port | Public port | Serves |
|---|---|---|
gateway.py (legacy) | 8787 | :443 |
| ~20 older apps, simple passthrough | ||
agent-server (current) | 8788 | :8443 |
| Everything new — RAG, memory, tools |
A key from one will not authenticate against the other. If an app suddenly reports "invalid API key," check whether :8443 got dropped from its URL.
Talking to the server from a terminal
# Non-streaming
curl https://llmpowerhouses.taila4b91f.ts.net:8443/v1/chat/completions \
-H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
-d '{"model":"qwen3.6:35b-a3b","messages":[{"role":"user","content":"hello"}]}'
# Streaming (-N disables curl's buffering)
curl -N https://llmpowerhouses.taila4b91f.ts.net:8443/v1/chat/completions \
-H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
-d '{"model":"qwen3.6:35b-a3b","stream":true,"messages":[{"role":"user","content":"count to five"}]}'
# List models, with live residency status
curl https://llmpowerhouses.taila4b91f.ts.net:8443/v1/models -H "Authorization: Bearer YOUR_KEY"
Every endpoint requires the Bearer header, /health included — a bare request returning {"detail":"missing bearer token"} is correct behavior, not a fault.
Managing API keys
cd /Volumes/AI_DATA/apps/agent-server
venv/bin/python3 keys_admin.py list
venv/bin/python3 keys_admin.py create <app-name> --scope chat,tools --rate 60
venv/bin/python3 keys_admin.py rotate <key_id>
venv/bin/python3 keys_admin.py revoke <key_id>
--rate is requests/minute. --daily-quota is tokens/day (omit for unlimited). Raw keys print exactly once — if lost, rotate; they can never be recovered.
Adding or removing a model
ollama pull <model-name>
ollama rm <model-name>
ollama list
Then update three places or an app will offer a model that doesn't exist: the app's own model table, the SOP's model table, and AGENT_SERVER_GUIDE_v2.md's daily log. Full detail in 07_Switching_LLM_Models_Guide.md. No agent-server restart needed — /v1/models reads Ollama live.
Changing agent behavior
| To change | Edit | Restart needed? |
|---|---|---|
| Agent identity, tool policy, guardrails | apps/agent-server/AGENT.md | No — read fresh each request |
| A skill (citation style, tone) | apps/agent-server/skills/*.md | Yes — cached at startup |
| Source ranking | knowledge-bank/source_authority.json | Yes |
| MCP servers | apps/agent-server/mcp_servers.json | Yes |
| Server code | apps/agent-server/*.py | Yes |
Restart = Restart-Agent-Server.command.
Knowledge Base & Maintenance Cadence
Adding documents to a knowledge bank
- Drop files into
knowledge-bank/DOD-FM-Knowledge-Bank/orknowledge-bank/K12-Knowledge-Bank/(or_inbox/if unsure where they belong yet). - Double-click
Sync-Knowledge-Base.command. - No restart needed — the index is read live. Files moved to
_archive/are automatically retired from search.
Naming matters for retrieval: FMR-Vol03-Ch08_Unliquidated-Obligations_2025.pdf retrieves far better than document (3).pdf. Pattern: Source_Topic_Date.ext.
Weekly / monthly / quarterly maintenance
Weekly (~5 min): Status-AI.command, Backup-AI.command, glance at free disk space (investigate below 200 GB free), check logs/agents/requests.jsonl size (archive, don't delete, past ~500 MB).
Monthly (~20 min):
cd /Volumes/AI_DATA/apps/agent-server
venv/bin/python3 run_test_questions.py # quality baseline
venv/bin/python3 build_eval_dashboard.py # regenerate Eval-Dashboard.html
venv/bin/python3 keys_admin.py list # revoke anything unused
Quarterly: rotate API keys, check ollama --version for updates (read release notes first — a serving-layer change affects every app at once), copy a backup to a different drive (backups currently live on the volume they protect).
Diagnostics, Troubleshooting & macOS Reference
Reading the numbers
| Reading | Meaning | Action |
|---|---|---|
| p50 latency under ~30s | Normal | None |
| p50 rising, output tokens also rising | Longer answers, not a regression | Cap max_tokens, ask for brevity |
| p50 rising, output tokens flat | Real regression | Check resident models, check for concurrent load |
| Latency exactly ~170,000 ms | Hit the upstream timeout | Model cold-loading, or generation ran away |
| "none loaded" | Next request pays a cold load | Normal after ~30 idle minutes |
| 0 completion tokens on many requests | Token logging broken | Investigate — quota enforcement may be silently off |
What NOT to do
- Don't delete
logs/agents/*.jsonl— it's the only latency/quality history that exists. - Don't delete
keys.dbormemory.db— both are irreplaceable (keys are hashed and unrecoverable; memory rebuilds only from weeks of real use). - Don't run
restart-ai-stack.commandexpecting it to restart agent-server — it manages Ollama, Open WebUI, and the legacy gateway only. - Don't edit files under
apps/agent-server/without backing up first.
macOS basics, if you're new to the Mac
| Want to… | Do |
|---|---|
| Open anything fast | ⌘ Space, type a few letters, Enter |
| See if the AI server is running | ollama ps in Terminal |
| Watch a log live | tail -f /Volumes/AI_DATA/logs/ollama.log (⌃C to stop) |
| Go straight to a folder in Finder | ⌘ ⇧ G, then type the path |
| Copy a file's full path | select it, ⌘ ⌥ C |
| Force-quit a frozen app | ⌥ ⌘ Esc |
| Prevent the Mac sleeping (one-off) | caffeinate -i in Terminal |
| Keep a server auto-starting on login | System Settings → General → Login Items |
⚠️ rm -rf foldername deletes instantly, no confirmation, no Trash. Triple-check the path before running it, and never run it with sudo on a path you didn't type carefully yourself.
Syncing the public site's code
cd /Volumes/AI_DATA/apps/llmpowerhouse-site
git pull
That's the only git command that should ever run on this Mac for that folder — all commits happen elsewhere and get pushed to GitHub; the Mac is a read-only mirror refreshed with git pull. Never git push, git add, or git commit here.
If you see "branch and origin/main have diverged":
git fetch origin
git reset --hard origin/main
This is always safe — nothing on the Mac side should ever be a local commit, and gitignored files (gateway.env, api_keys.json, gateway.log) are untouched by it either way.
Troubleshooting quick table
| Symptom | Cause | Fix |
|---|---|---|
{"detail":"missing bearer token"} | No Authorization header | Add it — required everywhere, including /health |
{"detail":"invalid API key"} | Wrong key, or hit the legacy server | Check the key; confirm :8443 is in the URL |
| Restart says "did NOT come up" | Health check ran before startup finished | Check logs/agent-server.log for "Application startup complete" |
| First request slow, rest fast | Cold model load | Normal — check residency in Status-AI.command |
| All requests slow under load | FIFO queuing | Confirm OLLAMA_NUM_PARALLEL=4 took effect |
| MCP warnings on restart | May be stale log lines from a previous run | Status-AI.command scopes to the current startup only |
Key takeaways
- Start with
Status-AI.commandfor any anomaly; it gives instant health, resident model status, and latency metrics. - Never delete logs, keys, or memory databases; they are irreplaceable and contain hashed state that cannot be rebuilt from scratch.
- Agent-server restarts are lightweight; they only require
Restart-Agent-Server.commandand do not touch Ollama or the gateway. - Naming conventions drive retrieval accuracy; use the
Source_Topic_Date.extpattern when dropshipping documents into the knowledge banks. - Separate the two servers mentally; port 8443 serves the current infrastructure, while 8787/443 hosts legacy passthrough apps with distinct key spaces.
Learning map
Staged Roadmap
Phase 1 — Awareness (day 0–2)
- Read the full cheat sheet front-to-back
- Keep
Status-AI.command watchopen in a Terminal tab while you read - Understand which services exist (agent-server :8443, legacy gateway :8437, Ollama) and how they differ
Phase 2 — Survival skills (day 3–5)
- Practice emergency recovery: run
Status-AI.command, thenRestart-Agent-Server.command - Learn API key management (
keys_admin.py list / create / rotate) - Test model lifecycle:
ollama list, pull a model, remove it
Phase 3 — Routine operations (week 2+)
- Run weekly checklist: status check, backup, disk monitoring
- Add documents to your knowledge bank and sync
- Set up monthly quality baseline runs (
run_test_questions.py)
Phase 4 — Maintenance maturity (month 1+)
- Quarterly key rotation and Ollama version review
- Cross-drive backup copying
- Log-size hygiene for
requests.jsonl
Get hands-on — step by step
- Open Terminal and run
/Volumes/AI_DATA/Status-AI.command watchto open the health-monitor dashboard — leave this tab open while you learn. - Run
/Volumes/AI_DATA/Restart-Agent-Server.commandonce as a warmup; then checklogs/agent-server.logfor "Application startup complete" to confirm it came up. - List your managed API keys with
cd /Volumes/AI_DATA/apps/agent-server && venv/bin/python3 keys_admin.py list. - Pull a test model and back it out: run
ollama pull qwen3.6:35b-a3b, verify withollama list, then runollama rm qwen3.6:35b-a3b. - Test talking to the server with a non-streaming curl request to
https://llmpowerhouses.taila4b91f.ts.net:8443/v1/chat/completionsusing your Bearer token. - Drop any sample PDF into
knowledge-bank/K12-Knowledge-Bank/, then double-clickSync-Knowledge-Base.commandto ingest it. - Run your first backup with
/Volumes/AI_DATA/Backup-AI.commandbefore trying anything else.
Top 3 sources
- 1Ollama Documentation
Official Ollama docs covering model management (pull, list, rm), local serving, and configuration — the authoritative reference for any LLM running on a single machine.
https://ollama.com/search?q=
- 2OpenAI API Reference
The canonical API spec that all OpenAI-compatible endpoints (like your agent-server) follow — curl examples, streaming behavior, and parameter reference.
https://platform.openai.com/docs/api-reference/chat
- 3Model Context Protocol (MCP) Specification
Official MCP docs explaining the protocol for connecting LLMs to external tools — the spec behind your `mcp_servers.json` configuration.
https://modelcontextprotocol.io/
Links are AI-suggested — worth a quick sanity check before diving in.