--- name: local-model-resource-guard description: "Use when launching Ollama work. Gate local jobs on RAM." version: 1.0.0 author: HamaratLabs license: MIT --- # Local model resource guard - Check `memory_pressure -Q` and `sysctl vm.swapusage` before starting local Ollama work. - Treat any non-zero swap usage or system-wide free memory below 25% as a block for non-urgent local work. - Wait for free memory to recover to at least 35% and swap usage to return to zero before launching the local model. - Serialize local model jobs; keep `OLLAMA_MAX_LOADED_MODELS=1` and never deliberately load all local models together. - Cloud-agent work may continue while the local worker waits, but do not start additional heavy cloud agents when memory is already pressured. - Optional owner setting: if the machine's owner has paused local models or excluded them as provider fallbacks, respect that setting and do not restart them until the owner resumes them. Do not create such a pause yourself; it is the owner's decision. - If the guard blocks a job, report `RAM guard: bekliyor` rather than forcing the model to load. - On some systems swap does not return to zero at idle: it can stay at several GB even with free memory above the 35% floor and may only clear on reboot. Do not treat a blocked guard as something a short poll loop will resolve — a dispatched worker that retries every 30s for 15+ minutes and sees no change should stop polling, report the block with the actual numbers, and surface it as a decision point (scoped exception for a specific lightweight model, or accept the wait until next reboot) rather than looping indefinitely or quietly forcing the load. - A scoped exception (e.g. only a named small model, only if free memory holds and swap doesn't climb further during the run) is a policy change to a safety gate and needs the user's explicit sign-off before a worker uses it, even when the worker's own proposal sounds reasonable. For command launches that need an enforceable wait gate, wrap them in a small guard script you write yourself (not shipped with this skill) that runs the checks above and refuses to start the job.