Models that play Garry's Mod's Trouble in Terrorist Town like a person: they watch the screen, listen, talk in voice chat, walk the map and play by the rules.
Two models share the work. A small vision model on your GPU (the actor) looks at the screen several times a second and decides what the body does right now: where to walk, whom to look at, whom to shoot, which key to press. Claude (the planner, through Claude Code) follows the round, gives the actor its goal in plain words and does all the talking. Code carries the actor's decisions out 30 times a second: aim that follows a person, routes on the map, a trigger that only fires while that very person is under the crosshair. It only uses what a player sees and hears. Speech, hearing and vision run on your own machine.
Runs on Windows and Linux.
Bots are not welcome everywhere. Only play where the server allows it, and put that server's rules in
gmod_agent/knowledge/server_rules.md: the planner reads them and follows them.
| See | The game window, live. A person detector marks everyone on the very frame the actor gets, each with a number they keep, in sight or out of it, and the actor reads the scene itself: weapons, fights, bodies, doors, menus. Names are read under the crosshair, again with every look, and dropped after half a minute: players change them. HP and ammo come from the HUD. |
| Hear | Game sounds with direction, named from the game's own sound files ("gunshot: Deagle, 30° left"), and voice chat as text, transcribed locally, with who said it. |
| Talk | It speaks in voice chat through a virtual microphone (Voicemod, VB-CABLE, ...) with Pocket TTS, optionally in a custom voice (Applio RVC models). It waits for a pause before speaking and stops if someone talks over it. |
| Know the map | Its exact position (from the game's console) and the map's walls, floors, lava, water, doors and ladders, read from the map file the game already has. Hidden things a player can't see (traps that are off, traitor-only doors) are left out. |
| Move | The actor says where; routes go around walls, lava and deadly drops, through doors, up ladders and onto ledges. Walking by itself it is told what it needs to judge its steps (legs that push without moving, a walk that gets nowhere, where the floor ends ahead and what the fall costs) and decides. |
| Fight | Shot at, the actor shoots back at once (and a reflex turns to the shooter and fires back when exactly one player is there). Anyone else it shoots only when the planner has put their name on its kill-on-sight list and the game shows that name under the crosshair: the small model's own reading of who is dangerous is not trusted with a life. The planner calls a KOS in voice the moment it makes one (a killer whose victim's body turned out innocent, someone shooting a Detective, a KOS another player called and has not taken back). The aim follows the target like a decent human would, and the trigger holds whenever someone else is under the crosshair. |
| Follow the round | Its role, the round state, every chat line, bodies found and their roles, and last words, from the console; the planner keeps its own notes on who did what. |
| Stay safe | Input stops the moment you switch away from the game or open the Steam overlay; frames of the overlay are never sent anywhere. A web page lets you pause it at any time. |
Claude (planner, via Claude Code) when something happens: the round, the GOAL, voice lines
│ GOAL
▼
small vision model (actor, llama.cpp) three times a second: go / look / shoot / key
│ answer
▼
executor + brain (30 Hz) aim, routes, trigger guard, keys and mouse
▲
senses: capture, person detector, HUD, console.log (position, map, role, chat), sounds,
voice chat transcripts, the map file
reflex: shot at → turn to the shooter and fire back (no model involved)
- Actor: the newest frame with a number on every person (a person keeps theirs) and the
name of each one it has looked at, a letter on every way it can walk from where it stands
(the rooms and halls next door, "new" until it has been there this round), the GOAL, its
state (health, being hurt or not, sounds, blocked legs, where the floor ends ahead) and
what was just said in voice and chat. Every look decides anew. It picks; the body walks the
way it picked, around furniture and through doors. Everything that happens in the moment
is its call; it never waits for the planner, except for shooting someone who is not
shooting it (see Fight). Default model: Qwen3.5-4B (Q4 with its draft
heads, just under 5 GB of VRAM), started by the daemon through llama.cpp and downloaded on first
use;
--actor-modelpicks another. - Planner: Claude through Claude Code (
claude -p), so it runs on your Claude subscription, not per-token API billing. It takes a turn when something happens (someone talks, a body is found, a hit, a shot of ours) and every 12 seconds otherwise: it writes the actor's GOAL in short literal sentences, decides what to say, and keeps notes on the round. The game's own windows (the round report, the shop, a body's search window) are its to work, a click a turn: the small model cannot point at a button. - Watching:
gmod-agent --watchsends no input: both models decide while you play, and their answers are logged with your position (see Data below).
Both systems also need:
- llama.cpp (
llama serveorllama-serveron the PATH) and a GPU with about 4 GB of free VRAM next to the game, for the actor; - Claude Code (
claudeon the PATH), logged in, for the planner.
Python 3.11 or newer. ffmpeg comes with the dependencies.
git clone https://github.com/360900/gmod-agent
cd gmod-agent
python -m venv .venv
.venv\Scripts\pip install -e .You need:
- PipeWire and xdg-desktop-portal (screen and audio capture);
- KDE Plasma 6 or an X11 session for the focus guard (elsewhere:
--no-focus-guard); - write access to
/dev/uinput(virtual keyboard and mouse); - Python 3.11+, PyGObject, GStreamer with the PipeWire plugin, and ffmpeg.
git clone https://github.com/360900/gmod-agent
cd gmod-agent
python -m venv --system-site-packages .venv
.venv/bin/pip install -e .The first start downloads about 700 MB of speech, sound and text models.
- Windowed or borderless, so the window can be captured.
- Add
-condebugto the launch options (Steam → Garry's Mod → Properties → Launch Options). The game then writes its console togarrysmod/console.log. That gives the bot its exact position, the map, its role, the round state and every chat line. On first start the daemon binds Scroll Lock togetpos(incfg/gmod-agent.cfg, run fromautoexec.cfg) and presses it a few times a second while it plays, so restart the game once afterwards (or typeexec gmod-agentin its console). Scroll Lock because it types nothing and no desktop combines it with a key you may be holding. Also typecl_showpos 1in the console once (it's saved): without-condebugthe bot reads its position from those numbers and recognizes the map by where it walks. Without either it still plays, steering by sight alone. - Push-to-talk on X (TTT's default,
+voicerecord);--ptt-keyif yours differs. - For routes, the map file (
.bsp) must be on your PC. It is for any map you've played or downloaded: loose ingarrysmod/mapsor inside a workshop.gmain the cache. The first visit to a map takes a few seconds to learn it; after that it's cached.
The bot speaks into a virtual playback device that feeds a microphone the game uses:
- Voicemod: it picks "Dummy Output (Voicemod)", so you and the bot share the Voicemod mic.
- VB-CABLE / Virtual Audio Cable: it picks the first one it finds.
--voice-device <name>to choose another device.--voice pocket(default: Pocket TTS speaking as MrHat, a CC0 voice from Kyutai's voice donations),pocket:Greggy,pocket:STONE,pocket:developer-1,pocket:<file.wav>(any clean recording of a few seconds),kokoro:am_michael(the fallback),piper:0, ...: the text-to-speech voice. Remembered. Pocket TTS is by Kyutai (CC-BY-4.0); the sherpa-onnx export is pinned and checked by SHA-256.--rvc-model <name>converts the voice with an Applio model (a folder name under Applio'slogs, or a.pth), with--rvc-pitchin semitones. It runs in Applio's own Python on the GPU: about a minute to warm up, then under a second per line. SetAPPLIO_DIRif Applio isn't in%LOCALAPPDATA%\Applio.--rvc-model noneturns it off. Remembered.--gpu-voiceruns speech on the GPU. It's faster, but off by default: a second GPU program next to the game once coincided with a driver error that froze it.
Sound is captured from your default output device, so anything else playing there is heard too.
Start the game and join a server, then start the daemon:
.venv\Scripts\gmod-agent --name "<your in-game name>"On Windows, Start gmod-agent.bat in the repository folder does the same with a double click
and opens the web UI, where Settings changes the name and everything else (options after it
are passed on: "Start gmod-agent.bat" --watch).
The name lets the planner recognize itself in chat and when people talk to it, and is remembered. On Linux you pick the game window once. The first start downloads the actor's model (about 4 GB). From then on it plays: the actor drives the body, the planner sets goals and talks. Switch to another window or pause it in the web UI to take the controls back.
Watch first: gmod-agent --watch plays nothing. Both models decide while you play and their
answers are logged, so you can see what it would have done before letting it play. It still
presses Scroll Lock for your position while the game is focused, never while you hold Shift,
Ctrl, Alt or Meta (on Linux that needs read access to /dev/input).
http://127.0.0.1:8765/ shows the game, what the actor saw with its marks, its last answer,
the planner's goal, the events and a pause button. --lan serves it to your phone on the
local network, protected by a token.
Settings opens a panel with every option. The ones marked live (watch only, shooting, instincts, speaking, listening, the voice, push-to-talk, the planner's model) change the bot at once; the others are saved and apply the next time it starts. From another device the panel can change settings only behind the access token.
If aiming is off by a few degrees (unusual mouse settings), stand still in the game facing a detailed wall and run:
.venv\Scripts\gmod-agent calibrateThe view spins twice and the measured correction is saved.
Every actor answer (with what it was told, how long it took and your position) goes to
~/.local/share/gmod-agent/actor/ (%LOCALAPPDATA%\gmod-agent\actor on Windows) together with
the frame it saw (an hour per run, the last three runs, about 2 GB at most), the frame of every
answer that wanted someone shot to actor/shots/, llama.cpp's own output to actor/llama.log,
and every planner turn with its cost to .../planner/ (on a subscription the cost is what the
API would have charged; with --planner-api-key every $10 spent is reported).
python tools/replay.py actor <run>.jsonl asks the model again about every recorded frame and
prints what it decides and how fast, so a changed prompt (--system) or server setting
(--flags) is tried on what really happened first (--port 9932 borrows the running daemon's
model); tools/replay.py planner does the same for the planner's turns. The planner's guide is gmod_agent/knowledge/:
TTT's rules, roles, weapons and menus, this server's rules, and its voice personality
(persona.md), in plain Markdown, so edit them freely.
gmod-agent --help lists everything. The ones you're most likely to need:
| Option | |
|---|---|
--name |
Your in-game name (remembered). |
--voice, --voice-device, --rvc-model, --rvc-pitch, --gpu-voice |
Voice, see above. |
--actor, --actor-model |
The actor: auto (llama.cpp, started by the daemon), off, or an OpenAI-compatible chat URL; the GGUF it runs (remembered). |
--planner-model |
The planner's Claude model, e.g. sonnet (default) or opus (remembered). |
--planner-api-key |
Let the planner use ANTHROPIC_API_KEY (per-token billing) instead of the Claude Code login. |
--watch |
Send no input: the models only decide and log. |
--no-shoot |
Never pull the trigger (the actor's shooting and shooting back are off): it only walks and looks. |
--ptt-key |
Push-to-talk key (default x). |
--fov, --sensitivity |
Override what's read from the game's config. |
--keyboard-layout |
Linux: your keyboard's layout, e.g. de (default: detected). |
--no-listen, --no-speak, --no-instincts, --no-focus-guard |
Turn parts off (--no-instincts: no shoot-back reflex). |
--lan, --auth, --host, --port |
Web UI access. |
--open |
Open the web UI in the browser once it is up. |
Every option is also kept in settings.json (%LOCALAPPDATA%\gmod-agent\ on Windows,
~/.local/state/gmod-agent/ on Linux), which the web UI's Settings panel writes; a flag given on
the command line wins for that run.
gmod-agent train-sounds retrains the sound recognizer on the game's and the server's own
sound files, which helps on servers with custom weapons.
- "position unknown: no live console.log": add
-condebugto the launch options and restart the game. - "Scroll Lock doesn't print getpos": restart the game once, so
autoexec.cfgrunsexec gmod-agent, or typeexec gmod-agentin its console. - "The actor (small vision model) is unavailable": install llama.cpp so
llama serve(orllama-server) is on the PATH, or point--actorat a running OpenAI-compatible server. - "planner off": install Claude Code and log in (
claude), soclaude -pworks. - "The planner is failing": the message says why (not logged in, the plan's usage limit). The actor plays on; a GOAL the planner hasn't renewed for 45 seconds is dropped.
- "no way there on the map": that area is only reached by a lift, a button-opened door or a traitor door. Pick another target.
- "position unknown" without
-condebug: typecl_showpos 1in the game's console. - It stops doing anything: input pauses while the game isn't the active window, the Steam overlay is open or the web UI's pause is on. Click back into the game.
- Nobody hears it: check that the game's microphone is the device the voice plays into (Voicemod mic, or the cable's input), and that push-to-talk is X.
- Aim is off by a few degrees: run
gmod-agent calibrate.
gmod_agent/server.py |
the daemon: command line, web UI |
gmod_agent/settings.py |
every option: which change while playing, checking values, settings.json |
gmod_agent/game.py |
the game session: senses, guards, events, the state lines the models read |
gmod_agent/actor.py |
the actor: the small vision model's loop, its marks and its prompt |
gmod_agent/planner.py |
the planner: Claude through Claude Code, goals and voice lines |
gmod_agent/executor.py, brain.py |
the actor's answers as intents; the 30 Hz executive (aim, trigger guard, keys) |
gmod_agent/navigator.py, reflex.py |
routes on the map; the shoot-back reflex |
gmod_agent/ways.py |
the rooms and halls next to the body, offered to the actor as lettered ways to walk |
gmod_agent/worldmodel.py, perceive.py, track.py, follow.py, ocr.py |
the players around us; the person detector (D-FINE-N), the follower that keeps a watched player's box between its looks, and name reading |
gmod_agent/world/ |
map files: geometry, walkable grid, route planner, map identification |
gmod_agent/pose.py, showpos.py, maps.py, conlog.py |
exact position, the current map, the console log (role, round, chat) |
gmod_agent/body.py, depth.py, view.py |
HUD, hits and deaths, blocked legs; depth in metres for walks without the map; projection |
tools/replay.py |
recorded looks and planner turns again through the models: prompts and settings tried on real play |
gmod_agent/audio*.py, speech.py, rvc*.py |
hearing, speech in and out, voice conversion |
gmod_agent/capture*, inputdev*, focus* |
screen capture, virtual input, focus guard per platform |
gmod_agent/knowledge/ |
what the planner knows: TTT, the server's rules, and voice personality |
GPL-3.0-or-later