Skip to article
11 min read

how do you give a coding agent a controller?

six browser games, one very unfinished Minecraft agent, and a lesson in why the environment matters more than the game.

  • draft
  • agents
  • games
  • MCP
draft: the browser harness I built works across six example games. the Minecraft side is still an experiment, and its recordings mostly show failure. that failure is doing useful work.

the game is not the hard part

A coding agent already knows the basic loop: inspect some state, choose a tool, see what changed, and try again. Give it a screenshot instead of a repository and keyboard controls instead of a shell, and it can technically play a game.

Technically is carrying a lot of weight there.

Games keep moving while models think. A half-second keypress means something different at 20 FPS and 200 FPS. A screenshot can arrive after the player has already fallen off the platform. "The command ran" does not mean "the action worked." Once an agent is allowed to remember things, one bad observation can turn into a permanent fake fact.

I have been exploring this through two setups. The first is a reusable MCP harness wrapped around six small browser games. The second is an early Minecraft agent built around persistent learning. One is a fairly strict test environment. The other is still a pile of sharp edges around an idea I like.

The useful comparison is not which game is harder. It is what each environment lets the agent claim, and how much evidence it requires before believing that claim.

pausing the world while the model thinks

I wrapped local WebGL games in a small MCP server. The game can be Unity, Godot, Three.js, or another browser runtime. The harness does not read engine state. It needs an entrypoint, a canvas selector, a ready signal, and a manifest describing the public controls.

An episode looks like this:

  1. game_start launches Chromium and returns the first screenshot.
  2. The complete Chromium process tree is paused with SIGSTOP.
  3. The agent studies the frozen image and chooses an action.
  4. game_act or game_pointer resumes Chromium, applies input for a bounded window, captures the result, and pauses it again.
  5. The next model turn starts from that frozen result.

The pause is the important bit. Model-thinking time can take seconds or minutes, but no game time passes during it. An action duration is quantized onto a 50 ms simulation clock, and the harness tracks gameplay time separately from browser-active time, model-thinking time, and total wall time.

This is much closer to a turn-based API than normal computer use, even when the game itself is real-time. The agent still has to understand pixels and control movement, but API latency cannot quietly change the task.

The MCP surface includes named controls such as forward, jump, or fire. Key controls also get persistent _down and _up forms, so the agent can hold one input while applying another. For games that need free mouse control, game_pointer accepts a bounded batch of relative moves, clicks, button-down events, and button-up events.

Every call returns the next image as MCP image content. The agent never gets a browser handle or a path into the game files. In the actual tasks, shell and exec tools are disabled.

testing the harness on six games

To check that this was not tied to one game, I tested the same harness on six free browser games sourced from itch.io. The browser build and webgame.json manifest changed for each game. The harness did not.

I ran the experiment through Codex with gpt-5.6-sol at xhigh reasoning effort. Across the six games, the agent worked for more than an hour of wall-clock time, including the time it spent reasoning. The replays leave those pauses out and contain only the intervals when the browser was active.

Two samples from that experiment are below. Unstable Ship is a complete run. Q1K3 is one continuous spawn-to-death sequence cut from a longer run.

recording 01 · 01:02 · complete agent run Unstable Ship. The agent locates the extinguisher and sprays at the fires, but the recording ends with several fires still burning. The replay contains only browser-active game time; model-thinking pauses are omitted.
recording 02 · 00:26 · continuous excerpt Q1K3, 00:20 to 00:46 of the longer agent trace. One life is preserved without stitching: the agent starts at 100 health, approaches an enemy, falls to 16, and reaches the next respawn.

what these tasks actually measure

The six games are examples for a screenshot-matching task. The agent receives four public target frames and has to reach similar states in chronological order.

The rest of the MCP surface exists around that contract:

  • game_reference shows one target;
  • game_similarity compares the latest frozen frame with it without advancing time;
  • game_capture commits the current frame to one of four slots;
  • game_finish closes the episode and writes the replay and metadata.

The graded similarity is an equal mix of perceptual hash and spatial edge layout. RGB similarity, SSIM, and SIFT geometry are reported as diagnostics, although SIFT currently has zero weight in the score. The agent can query this feedback repeatedly before committing a frame.

That makes the task measurable, but narrower than "beat the game." The harness does not infer victory or death from pixels. Its own terminal states are runtime states such as timeout or fault. A good run is one that navigates the visual world well enough to reproduce four moments.

This is why I think of the games as test fixtures for the interface. They cover different camera models and control problems, but the environment is the thing being built.

then there is Minecraft

Minecraft changes the shape of the problem. There is no short path to one target frame. A useful agent has to preserve a goal across hundreds of actions, notice causal changes, survive mistakes, and retain knowledge between sessions.

I tried two separate approaches. For the Minecraft tests, I used Inkling by Thinking Machines through OpenRouter.

The screen agent runs Minecraft Java inside Docker on a 1280×720 Xvfb display. Each turn it captures the desktop with scrot, shrinks the frame to a 640×360 JPEG, sends it to a vision model through OpenRouter, and executes the returned keyboard or mouse actions with xdotool. It has tools for walking, looking, aiming at image coordinates, mining, clicking inventory slots, selecting the hotbar, placing blocks, and writing discoveries to memory.

I gave the screen agent a finite mission: collect logs, craft a table, gather materials, build a shelter, go inside, and call complete_mission. The prompt supplies the two recipes needed to make planks and a crafting table. I originally wanted it to learn Minecraft from first principles, but the narrower mission gives the prototype an actual stopping condition.

For the other route, I used Mineflayer. It reads structured state from the Minecraft protocol: health, hunger, coordinates, inventory, nearby entities, and notable blocks. Its actions are also semantic. Pathfinder moves to coordinates, the recipe API crafts items, and block operations use exact positions.

I use that version to explore planning and memory, but it is not the same perception problem. It already knows much more than a player looking at the screen. I have not turned the Minecraft side into an MCP server yet; both implementations are standalone agent loops that call OpenRouter directly.

the idea I want to keep

The solid part is the learning loop:

  1. observe the current world and memory;
  2. form one hypothesis;
  3. take an action;
  4. measure what changed;
  5. record a rule only when the result supports it.

I split memory into three layers. action_history.json is short-term context, journal.jsonl is an append-only episode record, and notes.json is meant to hold durable world knowledge. I also use a separate recipe store for the Mineflayer path.

If that loop works, the agent does not need a giant walkthrough in its prompt. It can learn local rules, survive a restart, and stop retrying experiments that already have an answer.

I do not protect the fourth step well enough yet, so the fifth one falls apart.

a keypress is not an outcome

Most tools I gave the screen agent report that input was executed. mine_block, for example, holds the mouse button, steps forward, and returns collected: true. It does not inspect the next frame or inventory before making that claim. write_discovery accepts whatever lesson the model sends and saves it without attaching evidence.

The result is memory that sounds much more successful than the run.

The current journal from my testing has 1,724 entries. Many describe a frozen Ubuntu screen while the model continues to announce that wood was collected, recipes were confirmed, and stone was mined. notes.json contains 52 entries under survival_loop_completion, with repeated claims that the full loop was "permanently verified." The corresponding journal often says there was no Minecraft render.

The finite mission has the same trust problem. I intended complete_mission to be valid only after the shelter was visibly verified, but I did not add a verifier to the tool handler. In my latest saved run, the model calls it at step 64 while the state detector says MENU_SCREEN. The chat attempt is blocked because the agent is on a menu, yet the loop still records mission_complete and exits.

My recordings are less flattering and more useful:

  • In the 30-second clip, the agent walks along a coastline, approaches a dirt slope, and spends the final seconds pressed against the block in front of it.
  • In the 421-second clip, it starts by looking at grass, opens an almost empty inventory, acquires three dirt blocks, and ends boxed into a dirt hole. The view is effectively unchanged from about the four-minute mark through the end.

Neither recording shows the shelter mission completing. They do show that screen capture, movement, inventory interaction, and recording are connected. That is where the evidence stops.

recording 03 · 00:30 · complete run The screen agent moves from the coast to a dirt slope, then keeps walking into the block. There is no successful recovery or task completion hidden after the cut.
recording 04 · 07:01 · complete run The unabridged failed run. Inventory checks happen early; three dirt blocks are acquired; by roughly 04:00 the agent is in a dirt hole, where the view remains almost unchanged through the end.

the environments are answering different questions

browser MCP harnessMinecraft screen agentMinecraft protocol agent
observationfrozen canvas screenshotlive desktop screenshotstructured protocol state
actionbounded keys and relative pointer eventskeyboard and mouse through X11semantic Mineflayer operations
timeadvances only inside tool callskeeps moving while the model thinksnormal server time
resetfresh bounded episodepersistent world and memorypersistent server and memory
evaluationfour externally scored framesmodel declares mission completeno task-level verifier yet
maturityreusable runtime across six tasksworking prototype with visible failure modesarchitectural prototype

I use the browser harness as an instrument for short-horizon visual control. With Minecraft, I am trying to build a place where an agent can accumulate competence. That requires a stricter evidence model, not just more tools or a larger context window.

what I would change next

The visual agent needs to separate four facts that are currently collapsed:

  1. the harness sent an input;
  2. Minecraft received the input;
  3. the world changed;
  4. the change satisfied the agent's intention.

Only the last two should create durable knowledge.

In the next version, I want to compute an observation delta after every action, attach that evidence to the journal, and make memory writes cite those observations. Inventory changes need visual verification. Mission completion needs an external check instead of a self-report. Each run needs an episode contract with a seed, task, budget, stop reason, and replay, similar to the browser harness.

I can use the protocol agent without making it the policy. Mineflayer can act as a private verifier for position, inventory, and placed blocks while the agent itself continues to see only screenshots. That would preserve the visual-control problem and give the evaluation a source of truth.

The small games taught me how to freeze time, constrain input, and produce an inspectable trajectory. Minecraft exposed the next problem: an autonomous agent needs an environment that is skeptical of it. Otherwise its memory accumulates confidence instead of knowledge.