explaingit

libardo667/kenshi-agent-env

Analysis updated 2026-07-25

0PythonAudience · researcherComplexity · 4/5Setup · hard

TLDR

A sandbox environment for running AI agents inside the Kenshi game. It separates perception, planning, and input so researchers can test if language models can play complex games.

Mindmap

mindmap
  root((repo))
    What it does
      Runs AI agents in Kenshi
      Separates perception and planning
      Logs every action for replay
    Safety
      Two gates before input
      Safety supervisor watches
      Default mimics human input
    Testing
      Mock environment no game needed
      Heuristic survival baseline
      Tests transfer to live mode
    Planning
      Strict schemas bound actions
      Continuous multi-step plans
      Retries and cancellation built in
    Telemetry
      Screenshots and game data
      Plugin emits two snapshots per sec
      Tracks position and money

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Test whether a language model can survive a day in the Kenshi game world.

USE CASE 2

Run the full agent pipeline without owning the game using the bundled mock environment.

USE CASE 3

Replay logged sessions to debug why an agent made a specific decision.

USE CASE 4

Experiment with bounded multi-step planning where a single call authorizes a sequence of actions.

What is it built with?

PythonWindowsSQLite

How does it compare?

libardo667/kenshi-agent-env0xallam/my-recipe0xhassaan/nn-from-scratch
Stars00
LanguagePythonPythonPython
Last pushed2022-11-22
MaintenanceDormant
Setup difficultyhardmoderatemoderate
Complexity4/52/54/5
Audienceresearchergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires the Kenshi game on Windows for live mode and a native telemetry plugin for in-game data, though a mock environment allows testing without the game.

In plain English

Kenshi is a sandbox role-playing game set in a harsh desert world. This project builds a structured environment for running an AI agent inside that game. The goal is to let researchers experiment with whether a language model can play Kenshi, while keeping perception, planning, input, and game-integration failures clearly separated so they can be debugged on their own terms. The repository centers on a versioned observation protocol. The agent sees the game through screenshots and structured telemetry data, then decides what to do next. Every action, observation, and decision gets logged in a structured format that can be replayed later. Memory is stored in a local database, and plans follow strict schemas that bound what the agent can attempt at each step. Safety is a recurring theme. The default mode only uses ordinary Windows keyboard and mouse input, mimicking a human player. An optional native-assisted mode can also use a narrow internal command bridge, but it requires explicit acknowledgement and is never mixed silently with the interface-only path. Two independent gates must pass before real input is sent. A dedicated safety supervisor watches the stream and can cancel stalled actions, pause uncertain states, and report success only after confirming the result through a later telemetry update. The mock environment lets you run the full pipeline without owning the game. It shares the same reset, observe, step, and close interface as live mode, so tests written against the mock transfer directly. A heuristic baseline can complete a bundled one-day survival benchmark. The project also includes a continuous planning mode where one strategic call can authorize a bounded, multi-action plan with revision checks, retries, budgets, and cancellation handled by the executor. The native telemetry plugin has passed an initial in-game smoke test, emitting valid snapshots at two hertz and tracking character position, movement, pause, speed, and money. Broader field and input validation remains incomplete. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Write a Python script that uses the Kenshi agent environment's mock mode to run the heuristic baseline and print the survival benchmark results.
Prompt 2
Using the reset, observe, step, and close interface from the Kenshi agent environment, create a simple agent loop that takes a screenshot, asks GPT-4o what to do next, and sends the keyboard input.
Prompt 3
Configure the Kenshi agent environment to use native-assisted mode with explicit acknowledgement, and explain how to enable the two independent safety gates before real input is sent.
Prompt 4
Set up the continuous planning mode so one strategic LLM call authorizes a bounded multi-action plan, and show how the executor handles retries and cancellation.

Frequently asked questions

What is kenshi-agent-env?

A sandbox environment for running AI agents inside the Kenshi game. It separates perception, planning, and input so researchers can test if language models can play complex games.

What language is kenshi-agent-env written in?

Mainly Python. The stack also includes Python, Windows, SQLite.

How hard is kenshi-agent-env to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is kenshi-agent-env for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.