- Tools & AI
- Released
Protocol Failsafe
When the power, internet and phones are out, this kit still answers questions. A local AI replies only from an offline library and cites its sources, and printed first-aid cards cover the moments with no device at all. I designed it, directed the build with Claude Code, and chose every model by measuring it on the two machines it runs on.
- My role
- Designed and directed it; built it with Claude Code as an AI pair
- Built with
- Python (standard library only), Ollama, Kiwix, Windows and macOS launchers
- Runs on
- Windows desktop with a GPU (power on); Intel MacBook on battery (power out)
- Result
- Running on both machines, tested with no network; public repo with an agent setup guide
Jump to a section
The problem
When power, internet or cell service is out for days, a household loses every tool it normally uses to look things up. The goal: a kit that still answers practical questions, from stopping bleeding to keeping food and water safe, on hardware the household already owns.
Constraints that shaped it
- No internet or cell service: everything, including the AI, runs on the machine.
- Used under stress by people who are not technical, so one double-click starts it.
- A wrong first-aid answer is worse than no answer, so the AI may only repeat what the library says.
- The laptop has to last on battery, so model choice is measured in seconds and watt-hours.
- Nothing personal in the public version: addresses and plans stay in git-ignored files.
What's in the kit
Two machines cover two situations: a Windows desktop with a GPU while the power is on, and a MacBook on battery when it is not. Printed cards cover the case where no device is available.
Offline library
Kiwix with Wikipedia, WikiMed, iFixit, survival guides and Wikivoyage, readable in any browser. Each download is checked against its SHA-256.Local AI with sources
Ollama answers plain-language questions only from the library, lists its sources as [1] [2] [3], and says "Not found in the offline library" instead of guessing.First-aid cards
Eight short printable cards (choking, CPR, bleeding, burns, heart attack and stroke, food, water, carbon monoxide). The matching card appears before the AI answer and takes priority over it.First-aid videos
48 official videos from the Red Cross, American Heart Association, St John Ambulance and FEMA, about 900 MB.Offline games
Games that run without internet, many with controller support for two or more players.Checklists
Two weeks of supplies, a household communication plan and grid alerts, handed over at the end of setup.
How a question is answered
tools/ask.py uses only Python's standard library, so it runs on the Mac's built-in Python with no installs. tools/chat_server.py serves a chat page on 127.0.0.1:8090 that streams its output.
- Card first. Keywords match the question to a first-aid card, which is shown word for word before anything else.
- Topics. The model turns everyday wording into Wikipedia-style search topics.
- Search. kiwix-serve runs a full-text search, exact titles first.
- Read. The best articles are read and only their most relevant paragraphs are kept.
- Answer. The model answers from those sources only, at temperature 0, and cites them.
- Safety line. Code, not the model, adds a "call 911" line for life-threatening topics. The number is configurable.
Choosing models by measurement
Each machine got the model that was fastest while still faithful to its sources. I timed every candidate and, on the MacBook, measured battery cost per answer.
Desktop: gemma4:12b
RTX 5070 Ti, 16 GB VRAM. About 7–12 s per answer. The most faithful model tested: it cited everything and never invented a fact.MacBook: qwen3.5:4b
2019 MacBook Pro, Intel i9, CPU only. About 50 s and 0.42 Wh per answer, 0.5% of the battery.MacBook, low battery: qwen3.5:2b
About 25 s and 0.20 Wh per answer. Idle with the library and AI running, the MacBook draws 6.2 W: about 13 hours on a full battery. The screen costs more than the AI.
Answer-quality test: 8 models, 8 questions
The same eight questions went through each model one at a time, including a trap question the library cannot answer.
- Every model correctly refused the trap question, whose answer is not in the library.
- gpt-oss:20b was dropped. It invented facts even with sources in front of it, for example "fridge food is safe for 1–7 days" where the source says about 4 hours.
- "Uncensored" models were excluded. Abliterated variants added advice that no source supported.
- The best answers came from a 27B model, but it is only safe to run one at a time with someone at the PC (see the limits below), so it is not the default.
Search fixes and safety limits
Everyday words missed
Keyword search alone failed on normal phrasing: "bleeding" returned a song and "fridge" an article about a pork shortage. Letting the model pick encyclopedia topics first fixed it.Small models copied examples
The 2B model echoed the prompt's worked example for every question. Sending the examples as separate chat turns instead of one flat prompt stopped it.Answers drifted between runs
Temperature 0 made answers repeatable, and the cards give the critical steps a fixed wording that does not depend on the model.
Limits after a freeze
During testing, a 27B model filled the GPU's memory and froze Windows, because nothing was left to draw the screen. That set four rules:
- Ollama always keeps 2 GB of video memory free (OLLAMA_GPU_OVERHEAD), so the screen keeps working.
- Only one model is loaded at a time.
- A model that has not loaded within 2 minutes is abandoned instead of hanging.
- Large models are used only with the owner at the PC; the family chat page offers only the safe models.
Verifying it offline
- Tested with the network off. Both machines ran the full question flow in no-network sandboxes; on macOS,
sandbox-execdenied all outbound traffic except localhost. - Checked library files. Every library download is verified against the SHA-256 that Kiwix publishes.
- Scrubbed before going public. All files and the full git history were checked for personal details, and commit emails were rewritten to the GitHub no-reply address.
Setup by any AI agent
The public repo's AGENTS.md is a setup protocol. Anyone can tell their coding agent to clone the repo and follow it. The agent checks the system, memory, GPU and free disk space, recommends a library size and model, asks before big downloads or system changes, installs, tests with the internet off, and walks through the checklists.
The repo is free for non-commercial use under CC BY-NC 4.0 and states clearly that it is not medical advice and does not replace emergency services or a first-aid class.
What the agent does, step by step
- Checks the computer: operating system, memory, graphics card, free space and battery.
- Asks about the household and its phones.
- Recommends a library tier, an AI model and optional extras for that hardware.
- Installs only after the owner agrees. Purchases, passwords and sign-ups stay with the owner.
- Tests the kit with the internet off.
- Hands over the supplies, communication-plan and grid-alert checklists.
Outcome
The kit runs on a Windows desktop and an Intel MacBook with no network: about 7–12 s per answer on the GPU, about 50 s on the laptop CPU, and a plain refusal when the library has no answer. A generalised version is public, with a setup guide any AI agent can follow.
My part: the requirements, the answer pipeline design, the safety rules, model selection, the tests on both machines and the privacy review. I built it with Claude Code as an AI pair programmer, working under my direction.