BrainBank

04 - Operations Cheat Sheet

7/30/2026, 9:14:46 PM · updated 7/30/2026, 11:41:45 PM

#best-practices#agent-server#llm-infrastructure#system-administration#operational-procedures#ollama-management#health-monitoring#backup-and-maintenance#troubleshooting

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)

ButtonDoesUse it when
Status-AI.commandHealth check — services, resident models, latencySomething feels off, or weekly review
Restart-Agent-Server.commandRestarts only the agent-server (port 8788)After changing agent-server code or config
Sync-Knowledge-Base.commandIngests new/changed documentsAfter adding files to a knowledge bank
Backup-AI.commandBacks up irreplaceable stateWeekly, and before any risky change
Setup-MCP-Fetch.command / Setup-MCP-WebSearch.commandEnable web-reading / web-search toolsOnce 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

  1. Run Status-AI.command — find which service is down.
  2. Agent-server down → Restart-Agent-Server.command.
  3. Ollama down → stop-ai-stack.command, then start-ai-stack.command.
  4. Both look up but requests fail → Status-AI.command logs, read the error.
  5. Nothing works at all → check whether the AI_DATA volume is even mounted.

Server Management & Configuration

The two servers — don't confuse them

PortPublic portServes
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 changeEditRestart needed?
Agent identity, tool policy, guardrailsapps/agent-server/AGENT.mdNo — read fresh each request
A skill (citation style, tone)apps/agent-server/skills/*.mdYes — cached at startup
Source rankingknowledge-bank/source_authority.jsonYes
MCP serversapps/agent-server/mcp_servers.jsonYes
Server codeapps/agent-server/*.pyYes

Restart = Restart-Agent-Server.command.


Knowledge Base & Maintenance Cadence

Adding documents to a knowledge bank

  1. Drop files into knowledge-bank/DOD-FM-Knowledge-Bank/ or knowledge-bank/K12-Knowledge-Bank/ (or _inbox/ if unsure where they belong yet).
  2. Double-click Sync-Knowledge-Base.command.
  3. 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

ReadingMeaningAction
p50 latency under ~30sNormalNone
p50 rising, output tokens also risingLonger answers, not a regressionCap max_tokens, ask for brevity
p50 rising, output tokens flatReal regressionCheck resident models, check for concurrent load
Latency exactly ~170,000 msHit the upstream timeoutModel cold-loading, or generation ran away
"none loaded"Next request pays a cold loadNormal after ~30 idle minutes
0 completion tokens on many requestsToken logging brokenInvestigate — 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.db or memory.db — both are irreplaceable (keys are hashed and unrecoverable; memory rebuilds only from weeks of real use).
  • Don't run restart-ai-stack.command expecting 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 runningollama ps in Terminal
Watch a log livetail -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 pathselect it, ⌘ ⌥ C
Force-quit a frozen app⌥ ⌘ Esc
Prevent the Mac sleeping (one-off)caffeinate -i in Terminal
Keep a server auto-starting on loginSystem 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

SymptomCauseFix
{"detail":"missing bearer token"}No Authorization headerAdd it — required everywhere, including /health
{"detail":"invalid API key"}Wrong key, or hit the legacy serverCheck the key; confirm :8443 is in the URL
Restart says "did NOT come up"Health check ran before startup finishedCheck logs/agent-server.log for "Application startup complete"
First request slow, rest fastCold model loadNormal — check residency in Status-AI.command
All requests slow under loadFIFO queuingConfirm OLLAMA_NUM_PARALLEL=4 took effect
MCP warnings on restartMay be stale log lines from a previous runStatus-AI.command scopes to the current startup only

Key takeaways

  • Start with Status-AI.command for 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.command and do not touch Ollama or the gateway.
  • Naming conventions drive retrieval accuracy; use the Source_Topic_Date.ext pattern 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 watch open 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, then Restart-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

  1. Open Terminal and run /Volumes/AI_DATA/Status-AI.command watch to open the health-monitor dashboard — leave this tab open while you learn.
  2. Run /Volumes/AI_DATA/Restart-Agent-Server.command once as a warmup; then check logs/agent-server.log for "Application startup complete" to confirm it came up.
  3. List your managed API keys with cd /Volumes/AI_DATA/apps/agent-server && venv/bin/python3 keys_admin.py list.
  4. Pull a test model and back it out: run ollama pull qwen3.6:35b-a3b, verify with ollama list, then run ollama rm qwen3.6:35b-a3b.
  5. Test talking to the server with a non-streaming curl request to https://llmpowerhouses.taila4b91f.ts.net:8443/v1/chat/completions using your Bearer token.
  6. Drop any sample PDF into knowledge-bank/K12-Knowledge-Bank/, then double-click Sync-Knowledge-Base.command to ingest it.
  7. Run your first backup with /Volumes/AI_DATA/Backup-AI.command before trying anything else.

Top 3 sources

  1. 1
    Ollama 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=

  2. 2
    OpenAI 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

  3. 3
    Model 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.