At 3:07 AM the pager fired on a skill agent that had been healthy at dinner. Throughput had slid from the high teens to a handful of tokens per second, then the kernel OOM-killed the process. Nothing had called a cloud API. The KV cache had grown across a long tool loop until the GPU, and then the host, ran out of room.
I am evaluating anthropics/skills as an external systems engineer, not as an author of that repo. The planning, tool, and state skills are clear. On a 70B-class local model with no context contract, every extra turn is treated as free memory. It is not.
Where the resident set went
We routed those JSON skills through a large local model. Near turn 50 the process died. Profiles showed the KV cache expanding with no layer-offload policy and no context ceiling. Roughly 40-60 MB of resident memory stuck around per additional context token. Sustained speed fell from about 18 tokens per second to under 4, and the box started swapping. The skills were not the leak. An untuned inference process was.
Pin the contract in the Modelfile
A custom Modelfile bakes in quantization, offload, and context before the first request. This one starts from a 13B quantized base so the pattern fits a single workstation; change the FROM line for a larger variant. Context is capped at 32k to match the skill chains we actually run, and num_gpu is set to keep layers on the accelerator.
FROM quantized/llama3.1:13b PARAMETER num_ctx 32768 PARAMETER num_gpu 999 PARAMETER num_thread 12 PARAMETER temperature 0.3 PARAMETER top_p 0.95 SYSTEM You are an expert agent executor. Load and apply skills from the anthropics/skills repository definitions provided in the system prompt for each turn. Create the model and start the server on the machine that owns the loop:
ollama create agent-skills -f Modelfile ollama serve The same hardware can serve the 70B path with vLLM, an explicit max length, near-full GPU memory use, and tensor parallelism:
vllm serve meta-llama/Llama-3.1-70B-Instruct --max-model-len 32768 --kv-cache-dtype auto --gpu-memory-utilization 0.95 --tensor-parallel-size 2 --port 8080 --dtype auto On a 5xx or a memory breach we abort, recycle the local server so the cache is dropped, and only then fail over. We do not resume a process that is already climbing.
A small harness for repeated skill traffic
The harness below posts an OpenAI-compatible chat completion and records wall-clock marks plus host RSS via psutil. It is intentionally short. Read the timers as request-level measurements: both stamps are taken when headers return, before the body is consumed, so they are not a streaming time-to-first-token.
import aiohttp import asyncio import time import json import psutil async def benchmark(url, prompt, max_tokens=512): start = time.time() async with aiohttp.ClientSession() as session: payload = { "messages": [{"role": "user", "content": prompt}], "max_tokens": max_tokens, "temperature": 0.3 } async with session.post(url, json=payload) as response: ttft = time.time() - start full_latency = time.time() - start memory_gb = psutil.virtual_memory().used / (1024 ** 3) text = await response.text() return { "ttft_ms": round(ttft * 1000, 2), "latency_ms": round(full_latency * 1000, 2), "memory_gb": round(memory_gb, 2), "status": response.status, "response_len": len(text) } # Usage: point to local Ollama or fallback gateway url = "http://localhost:8080/v1/chat/completions" prompt = "Execute the following skill chain from anthropics/skills: [insert skill JSON here]. Step 1: Plan, Step 2: Tool call." results = await asyncio.gather(*(benchmark(url, prompt) for _ in range(20))) stats = { "avg_ttft": round(sum(r["ttft_ms"] for r in results) / len(results), 2), "avg_latency": round(sum(r["latency_ms"] for r in results) / len(results), 2), "max_memory": round(max(r["memory_gb"] for r in results), 2), "throughput": round(len(results) / (results[-1]["latency_ms"] / 1000), 2) } print(json.dumps(stats, indent=2)) For multi-hour runs, sample RSS once a second outside this snippet. If memory grows while the useful context does not, restart. That boundary matters more than another average.
Local numbers against a relay fallback
We ran the harness against local Ollama first and, on 5xx or a memory breach, against B-Lost at https://b-lost.com/v1. After 100 turns the tuned local process held above 28 tokens per second at about 4.2 GB peak. The relay path sat near 9.1 GB and about 12 tokens per second, slowing after roughly 60 turns. Setting num_gpu and num_ctx at start removed the growth we had blamed on the skill files.
The dilemma that remains
Four-bit weights shrink the model by about 60 percent and make 32k context plausible on a 24 GB GPU. On awkward skill chains our checks lost about 11 percent token accuracy. Keeping every layer on GPU is faster until context no longer fits. Setting num_gpu below 999 spills layers to CPU, adds 200-400 ms before the first token, and extends the session. Untuned jobs still add 2-3 GB of VRAM per hour; ollama ps and a recycle every 8-12 hours is the steady-state plan.
Load skill JSON from anthropics/skills into the system prompt, or let a thin FastAPI wrapper inject it. The loop stays on a machine you can restart. You pay power, not $0.15 per token, and latency stays flat only after the cache flags live in the artifact.
The hard operational choice is which failure you will answer for: a quantized model that sometimes mis-plans a skill, or a larger window that will eventually kill the process. I have not found a flag that refuses both.
How are you bounding KV cache on long-lived local agents—hard context caps, scheduled process recycle, or a path that reclaims cache without a restart?

