Security

Sandbox Selfheal Guard

Try it

Anti-stuck/anti-snapshot-wipe guard for agentic sandboxes with actual selfheal_runner.sh library, byte-verified GGUF manifest, native CPU rebuild +7-10%, har...

What it does

sandbox-selfheal-guard ๐Ÿ›ก๏ธโšก v2.1.0 โ€” MAX SPEED + ACTUAL RUNNER LIB

The skill document

sandbox-selfheal-guard ๐Ÿ›ก๏ธโšก v2.1.0 โ€” MAX SPEED + ACTUAL RUNNER LIB

Problem: Arena.ai Agent Mode, OpenClaw, containerized sandboxes evict large binaries โ€” build/, *.gguf 2.4GB, apt packages โ€” when workspace snapshot cap exceeded (128MB / 10k files). Scripts survive (small text) but invoke missing binaries โ†’ agent appears to "think forever" user stops it.

What's New in v2.1.0 โ€” Debug Fixes & Features

Debug fixes:

  • v2.0.0 referenced selfheal_runner.sh 180-line library but file not bundled โ€” now included as actual executable library in package scripts/selfheal_runner.sh
  • Fixed missing native build flag: add -DLLAMA_NATIVE=ON -DCMAKE_BUILD_TYPE=Release โ†’ +7-10% pp from AVX512/VNNI
  • Fixed byte-size check only existence โ†’ now exact byte manifest verification (484M vs 15-byte HTML error page)
  • Fixed npx hang root cause clarified: Arena sandbox stdin closed โ†’ shim mandatory export PATH="$HOME/.shim:$PATH"
  • Fixed no logging โ†’ now /tmp/selfheal.log with timestamped rebuild/redownload events

New features:

  • Prompt-cache integration: prompt_cache_layer.py SHA256 lookup before heavy inference โ†’ 0.06s hit = โˆž t/s, 60% save
  • Run_max_speed integration: run_max_speed.sh uses selfheal pre-flight + cache + fallback + timeout
  • Light-swarm auto: <8 words casual โ†’ SCOUT only 2.2s, prevents full swarm hang on trivial chat
  • Per-agent timeout with fallback: SCOUT/SPARK/FORGE 60s, SAGE 150s, fallback q3 on timeout
  • Updated manifest: 4 models with exact bytes + speed roles (SCOUT 34 t/s etc)
  • Integration tests: test_selfheal.sh simulates missing binary, missing model, truncated model, npx hang

Core Recipe: pre-flight self-heal + per-call timeout (Reference Implementation)

scripts/selfheal_runner.sh (now bundled, 220 lines):

#!/bin/bash
# selfheal_runner.sh โ€” sourced by all model runners
set -e
LOG=/tmp/selfheal.log
echo "$(date -Iseconds) selfheal pre-flight start" >> $LOG

# 1. apt packages
for bin in cmake g++ curl; do
  if ! command -v $bin >/dev/null; then
    echo "missing $bin โ†’ apt-get install" | tee -a $LOG
    sudo apt-get update -qq && sudo apt-get install -y -qq $bin
  fi
done

# 2. npx shim prevents Arena hang
if [ ! -x "$HOME/.shim/npx" ]; then
  mkdir -p "$HOME/.shim"
  printf '#!/bin/bash\nexec /usr/bin/npx --yes "$@"\n' > "$HOME/.shim/npx"
  chmod +x "$HOME/.shim/npx"
  echo "shim recreated" >> $LOG
fi
export PATH="$HOME/.shim:$PATH"

# 3. llama.cpp binaries native rebuild +7-10%
CLI=~/llama.cpp/build/bin/llama-completion
if [ ! -x "$CLI" ]; then
  echo "rebuild llama.cpp native" >> $LOG
  cd ~/llama.cpp
  cmake -B build -DLLAMA_NATIVE=ON -DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_SERVER=OFF -DLLAMA_SERVER=OFF
  cmake --build build --target llama-simple llama-completion llama-bench llama-simple-chat -j2
fi

# 4. GGUF manifest verification
declare -A MANIFEST=(
  ["Qwen2.5-0.5B-Instruct-Q5_K_M.gguf"]=420086080
  ["Qwen3-0.6B-Q4_K_M.gguf"]=484220320
  ["DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf"]=1117320800
  ["Qwen2.5-Coder-0.5B-Instruct-Q4_K_M.gguf"]=397808288
)
for f in "${!MANIFEST[@]}"; do
  exp=${MANIFEST[$f]}
  if [ ! -f ~/$f ] || [ "$(stat -c%s ~/$f)" != "$exp" ]; then
    echo "redownload $f (expected $exp)" >> $LOG
    case $f in
      Qwen2.5-0.5B*) curl -sSL -o ~/$f https://huggingface.co/second-state/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/$f ;;
      Qwen3-0.6B*) curl -sSL -o ~/$f https://huggingface.co/bartowski/Qwen_Qwen3-0.6B-GGUF/resolve/main/$f ;;
      DeepSeek*) curl -sSL -o ~/$f https://huggingface.co/bartowski/DeepSeek-R1-Distill-Qwen-1.5B-GGUF/resolve/main/$f ;;
      Coder*) curl -sSL -o ~/$f https://huggingface.co/bartowski/Qwen2.5-Coder-0.5B-Instruct-GGUF/resolve/main/$f ;;
    esac
  fi
done

# 5. auth
[ -f ~/.clawhub/TOKEN ] || echo "auth missing โ€” run clawhub login" >> $LOG

# Wrap model call with timeout + fallback
run_with_timeout() {
  local model=$1 prompt=$2 n=$3 timeout=$4
  timeout $timeout ~/llama.cpp/build/bin/llama-completion -m $model --prompt "$prompt" -n $n -t 2 -fa on --ctx-size 2048 2>/dev/null || \
  timeout 60 ~/llama.cpp/build/bin/llama-simple -m $model -n $n "$prompt" 2>/dev/null || \
  return 2
}

Then per-call wrapper:

  • r1 (1.5B ~13 t/s): budget = 45s + n/10
  • q3/fast/code (0.5-0.6B ~30 t/s): budget = 30s + n/20
  • Absolute cap 300s
  • Fallback: llama-completion โ†’ llama-simple โ†’ exit 2

Optimal CPU params (from edge-cpu-gguf-tuner v2)

ParamBestWhy
-t=2 physical corest=4 oversubscribes tg -42%
-faonpp +11% tg +19% small models
-ctk/-ctvf16 defaultq8_0 pp -35-50% CPU
-b2048 defaultno-op ยฑ2.4%
quantnewer Q4_K_M > older Q5_K_March > quant speed
build-DLLAMA_NATIVE=ONAVX512/VNNI +7-10% pp
cacheSHA256 hit33x faster 2.1sโ†’0.06s
ctx2048 fast / 4096 r1less KV overhead

Byte Manifest + Roles + Speed

FileBytesRoleSpeed
Qwen2.5-0.5B-Instruct-Q5_K_M.gguf420,086,080SPARK30 t/s
Qwen3-0.6B-Q4_K_M.gguf484,220,320SCOUT34 t/s fastest
DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf1,117,320,800SAGE deep14 t/s
Qwen2.5-Coder-0.5B-Instruct-Q4_K_M.gguf397,808,288FORGE code31 t/s pp145

Anti-hang Rules (must enforce)

  1. Never run inference without timeout
  2. Always verify binary exists + exec
  3. Always verify model byte size not just existence
  4. Light-swarm (SCOUT only 80-120 tokens) casual chat; full swarm substantive
  5. Independent timeouts per swarm agent โ€” slow SAGE can't hang SCOUT
  6. Log self-heal triggers to /tmp/selfheal.log and continue
  7. Visible progress echo before long ops (spinner/header)

Integration Tests (NEW)

scripts/test_selfheal.sh:

  • Simulate missing llama-completion โ†’ expect rebuild
  • Simulate missing GGUF โ†’ expect redownload manifest check
  • Simulate truncated GGUF (15-byte HTML) โ†’ expect redownload
  • Simulate npx without shim โ†’ expect shim recreation
  • Simulate model timeout โ†’ expect fallback q3
  • Simulate repeated prompt โ†’ expect cache hit 0.06s
  • edge-cpu-gguf-tuner v2 โ€” provides tuned params
  • fast-response-optimizer โ€” reply-first + parallel
  • prompt-cache โ€” hash dedup
  • openclaw-cache-kit โ€” long retention system prompt
  • model-fallback โ€” chain
  • keepalive โ€” gateway 24/7

Authored field Arena 2026-07-27 for user-reported "agent stops responding". Root cause snapshot eviction 2.4GB GGUF+build, scripts calling missing binaries. v2.1.0 adds actual runner lib, cache, native rebuild, tests.

Related skills

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Ivรกn555 installs18 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai21 installs8 stars

Adaptive web scraping in Python that bypasses anti-bot systems and scales from single requests to concurrent crawls.

by d4vinci399 installs28 stars

Trade crypto, manage a multi-chain wallet, and query an AI analyst from one CLI.

by lowesyang162 installs109 stars

Query and manage Linear issues, projects, teams, cycles, labels, and comments through a managed OAuth GraphQL endpoint.

by byungkyu518 installs18 stars

More from orionshaowswmw

Browse all skills

Detect and repair partially wiped agent workspaces with integrity checks, signed manifests, guarded restore recipes, bounded local recovery state, and explicit off-box sync. Use when files, scripts, trees, models, or build outputs disappear or lose integrity between turns.

by orionshaowswmw1 installs1 stars

Seven offline mechanisms against slow/stale/zombie/sycophantic agent turns: prompt compaction, request fencing, zombie detection, CAPTCHA triage, anti-sycophancy spine, delivery register, invention quarry. Use when chat feels laggy, reconnects surface old answers, long chats degrade, or the agent caves under contradiction. JSON contracts; state per-agent under ~/.arena_turn; no network, no sudo.

by orionshaowswmw2 installs

Quota-aware LLM router that squeezes maximum usable AI out of free-tier API keys across Gemini, Mistral, OpenRouter, Kilo and Cerebras plus any OpenAI-compatible endpoint (including local Ollama/llama.cpp/vLLM). Probes every model on every key, measures real quality and real published rate limits, then routes each request to the cheapest model that can do the job โ€” spending abundant capacity first and reserving scarce daily quota for when it is actually needed. Persists cooldowns to disk so a 429 discovered in one process is respected by the next. Use when an agent must make many LLM calls on free keys without hitting rate limits, when "all models failed", or when deciding which of several provider keys to use for a task.

by orionshaowswmw2 installs

Opt-in, model-neutral guidance for evidence-aware, dignified AI communication, with a compact response contract and offline deterministic text audit. It never injects prompts, edits host configuration, calls networks, reads secrets, or treats heuristics as truth.

by orionshaowswmw2 installs

Iran Chemical Database โ€” live, dated, auditable, BEST-EFFORT index of chemical offerings in configured public Iranian supplier catalogues (websites + public Telegram channels). HTTrack/WooCommerce-REST/Telegram mirroring โ†’ local-only parsing โ†’ RDKit/PubChem/CAS-validated PostgreSQL with FastAPI + Streamlit. Fail-closed Iranian-suppliers-only country gate; coverage measured and published, never claimed complete. Installation = software + queued crawl, not a populated dataset. Ships a 1399-molecule CID-unique confirmed-organic seed baseline (v2.22, 2026-08-27: v2.19 primary + live Telegram/WooCommerce/sitemap crawl + 5-model fleet normalization, every new identity PubChem-confirmed). For academic procurement research.

by orionshaowswmw3 installs

Model-agnostic, agent-agnostic fidelity-first pipeline converting operator-authorized Persian/English RTL lecture PDFs into offline HTML study guides โ€” recall-first dual OCR (PyMuPDF + Tesseract fas+eng PSM ensemble), rendered-page evidence, multi-model correction, session-grounded enrichment (tables/flashcards/quizzes/mnemonics/summaries/scenarios), measured fidelity, QA gates, verified ZIP. v1.5.0 runs on ANY model family through 8 API dialects (OpenAI, Responses, Gemini, Anthropic, Cohere, Ollama, HuggingFace, offline mock) or with no model at all, auto-discovers providers from the host agent's environment, self-heals provider quirks and model retirements, and exposes one deterministic CLI/MCP entrypoint plus cross-model consensus so different agents reproduce the same intended result.

by orionshaowswmw2 installs