#!/usr/bin/env bash # opencode-qwen36-35b-a3b-strixhalo entrypoint. Runs inside the container; takes no arguments. # 127.0.0.1:9000 llama-server (llama.cpp 75d911f, Vulkan): Qwen3.6-35B-A3B UD-Q4_K_XL, q8_0 KV, CONTEXT ctx (default 262144) # 0.0.0.0:4096 opencode serve: [runtime.app], opencode's own web UI and API on a second front port # 0.0.0.0:$M64_PORT agent_gateway.py: the agent.session API set -eu export HOME=/scratch/home WORK_DIR=/scratch/work mkdir -p "$HOME" "$WORK_DIR/sessions" /scratch/cache export XDG_CACHE_HOME=/scratch/cache CTX=${CONTEXT:-262144} echo '{"phase":"loading","detail":"llama.cpp: loading Qwen3.6-35B-A3B into GPU memory (about 23 GB)"}' >> "$M64_STATUS" # The engine settings and sampling are pi17-qwen36-35b-a3b-strixhalo's, measured on a Radeon 8060S: -ub 2048, # q8_0 KV, weights offloaded whole, Qwen's general thinking sampling with presence penalty 1.5 against thinking loops. /opt/llama/bin/llama-server \ -m /weights/qwen36/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf \ --mmproj /weights/qwen36/mmproj-F16.gguf --image-min-tokens 1024 \ -c "$CTX" -np 1 -ngl 999 -fa on -ctk q8_0 -ctv q8_0 -b 2048 -ub 2048 -lm none --jinja \ --temp 1.0 --top-k 20 --top-p 0.95 --min-p 0 --presence-penalty 1.5 \ --no-ui --metrics --alias qwen3.6-35b-a3b-ud-q4_k_xl --host 127.0.0.1 --port 9000 & LLM_PID=$! export AGENT_PROVIDER=local-llamacpp AGENT_MODEL=qwen3.6-35b-a3b-ud-q4_k_xl # Packages opencode installs on first start, warmed at build time (no network at run time unless granted). cp -rn /opt/opencode-capsule/. "$HOME/" export OPENCODE_CONFIG=/capsule/opencode.json # The provider is llama-server on 127.0.0.1: nothing goes through the m64 gate unless the agent's own tools reach out. cd "$WORK_DIR" opencode serve --hostname 0.0.0.0 --port 4096 --pure & OPENCODE_PID=$! # If opencode or llama-server dies, take the container down so m64 reports the error. A dead child lingers as a # zombie (state Z): test the state, not just whether the pid exists. alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; } ( while alive "$OPENCODE_PID" && alive "$LLM_PID"; do sleep 5; done echo '{"phase":"error","detail":"opencode or llama-server exited"}' >> "$M64_STATUS" kill -TERM $$ ) & exec /opt/gateway/bin/python3 /capsule/agent_gateway.py