A reusable Python engine for games controlled through an API. It separates the generic observe–plan–act–reconcile loop from game rules, provides typed outcomes, persists in-flight intent before mutations, and includes bounded operational tooling.
The default configuration runs a bundled loopback demonstration. The canonical contract scenario goes further: it runs entirely in memory, with no socket, account, token, language model, container, or real sleep.
Quick start
./install.sh --no-service
./manage.sh start
./manage.sh status
Run the sale-contract smoke test:
./smoke_test.sh
python3 agent.py canonical
Validate an adapter before connecting it to a real game:
from sdk.testkit import run_conformance
report = run_conformance(your_adapter_factory)
print(report.summary())
What is included
core/: deterministic loop, typed outcomes, persistence, pacing, guards, journal, health and storage protection.sdk/: five-method adapter contract and offline conformance kit.sim/andadapters/demo/: seed-derived reference world and complete adapter.ops/: configuration, runtime, diagnostics, backup and bounded watchdog.agent.py: offline benchmark hook plus optional post-run briefing.
The language-model adapter is not imported by core/, sdk/, ops/ or
run_engine.py. It can only summarize an already completed report.
Safety boundary
The engine never purchases, transfers, trades, messages, or authenticates on its own. A game adapter defines the authorized API and credentials. Start with the simulator, pass the conformance suite, inspect the configuration, and only then point an adapter at an endpoint you control.
See SPEC.md for the contract, CUSTOMIZE.md for adapter wiring, and
CHECKLIST.md for deployment gates.
Use a local model (Ollama)
The optional LLM step can also run on your own machine through Ollama, so no text leaves your server. No account and no API key.
ollama pull <model> # any chat model you like
export PACK_LLM=ollama # prefer Ollama even if a coding-agent CLI is installed
export PACK_OLLAMA_MODEL=<model> # optional: default is the first chat model the server lists
python3 -c "import llm_adapter; print(llm_adapter.detect())" # prints: ollama
PACK_OLLAMA_HOSTpoints to another server (defaulthttp://127.0.0.1:11434);OLLAMA_HOSTis also read whenPACK_LLM=ollama.PACK_OLLAMA_NUM_CTXsets the context size if your reports or prompts are long.- Without
PACK_LLM, a local Ollama server is used only when no Claude Code, Kimi Code or Codex CLI is found. - If the server is down or the model is missing, the pack keeps working in its deterministic mode.
Learning memory (local and private)
Every LLM call this pack makes is journaled in ./.pack_memory/ next to the code, so the pack can improve for you. Nothing is ever sent anywhere.
- What is kept: the task name, the masked input, the masked answer, status and latency. Keys, tokens, e-mails, phone numbers, IP addresses, card and IBAN numbers and personal paths are masked before writing; the system prompt is never stored.
- Teach it:
python3 pack_memory.py feedback last okconfirms a result,python3 pack_memory.py feedback last bad --fix "the right answer"corrects it. Confirmed and corrected runs are reused as validated examples when a similar input comes in. Unrated runs are never injected into a prompt. - Find similar cases:
python3 pack_memory.py similar "some text"andpython3 pack_memory.py clusters(groups of near-identical failures) work in plain Python, no model needed. Optional meaning-based matching uses an embedding model you already run locally:python3 pack_memory.py enable-semantic(Ollama on this machine only). - Share, only if you want:
python3 pack_memory.py exportwrites an anonymised summary (counts, statuses, size buckets, no text) for you to review. - Control:
PACK_MEMORY=0turns it off,PACK_MEMORY_STORE_TEXT=0keeps fingerprints only,python3 pack_memory.py purge --yeswipes it.
