Kalix: One Way In, for Me, My Scripts and an AI Agent
I started Kalix on March 14, 2026. By the end of November it had 1,984 commits. It is a 3D game engine written in Rust, and almost none of it was typed by me. Claude, working as a coding agent, wrote the code. My job was deciding what to build, reading what came back, and looking at the result.
That arrangement shaped the engine more than any single feature. If an agent is going to build and test games alongside me, it needs the same access I have, through the same door, with nothing hidden from it. Kalix is built around that door.
One queue for every change
A running game is a world full of things: a floor, a camera, a fighter, a light. In Kalix, nothing changes any of them directly. Every change is a command placed on one queue: spawn this, move that, play this animation, apply this damage. The engine works through the queue each frame. There are 190 kinds of command.
It does not matter who sends the command. A click in the editor sends one. A script in a game sends one. An AI agent connected to the engine sends one. They all wait in the same line and get the same answer.
Three things follow from that.
- The agent has no back door. It can do what I can do in the editor, and nothing more. When it is refused, it is refused for the same reason I would be.
- Every change can be seen. Because changes are commands, they can be logged, counted and replayed. The engine keeps an audit file of what AI tools changed in a project.
- The editor and the shipped game agree. A packed game runs the same commands as the editor, minus the ones that only make sense while authoring, such as saving a scene.
The editor’s API is the agent’s API
The agent talks to the engine through MCP, the Model Context Protocol, a standard way for AI tools to call into a program. Kalix does not have a separate editor API with an AI layer on top. The MCP server is the editor’s API. Its 61 tools cover reading the scene, changing components, importing assets, laying out a level and profiling a frame, and one of them can send any of the 190 commands by name.
A packed game, a single file with no editor, can host the same connection when started with a flag, on the local machine only. On July 20 an agent connected to a packed game running with no window, read its scene, dealt damage to a target until its health went from 100 to 75 to 0, confirmed each step by reading the target back, and was refused when it tried a command that only the editor allows. That was the goal of a whole run of work, and it was confirmed by running it, not by a test.
Replays that match bit for bit, and what broke them
A game engine that an agent tests needs to be predictable. If a fight plays out differently every time, a test of that fight proves nothing, and neither does an agent’s report about it.
So Kalix can run without a window, take a seed for all of its randomness, record every input, and replay the inputs later. Every few frames it writes a fingerprint of the whole game state. Two runs with the same seed and the same inputs must produce the same fingerprints, bit for bit. A test compares them.
That test passed for months. Then a game broke something, and it turned out the test had never broken anything.
- Fracture. When an object shatters, its pieces were given random IDs, they appeared on whichever frame a background worker happened to finish, and their physics bodies were never removed when they disappeared. Any of those makes two runs differ. The original test scene had nothing in it that could break, so it never saw this. The fix in September gives pieces IDs derived from the seed, computes them on the frame itself when a seed is set, and removes their bodies. A new test shatters an object and compares the fingerprints.
- Clocks. Many action games freeze for a few frames when a hit lands, so the hit feels heavy. Kalix had two clocks: one that counts displayed frames and one that counts simulation steps, which stops during that freeze. Combat timers that read the wrong one kept running through the freeze, and debris kept aging through it. A combat state forced by a script recorded its start on one clock while its timers read the other, so its timers never fired at all. None of this showed up as an error. It showed up as moves that felt slightly wrong, until someone building a game noticed.
- The monitor. The simulation used to step once per displayed frame. On a 144 Hz monitor that measured 144 steps a second, so moves tuned in frames at 60 a second played 2.4 times too fast, and differently on every screen. Since August a project can set a fixed simulation rate, independent of the display, and then measured exactly 60 steps a second.
- The processor. In November a build for 64-bit ARM Linux replayed animation identically to the PC. Fracture did not: the runs split on the frame the pieces landed. The cause is either the physics library or the shattering code, and it has not been separated yet.
The lesson I took from these: a determinism test only covers the things its scene actually does.
What it draws
The renderer is built on wgpu, a Rust graphics library that runs on Vulkan, DirectX 12 and Metal. Over the summer it grew from flat-shaded shapes into a modern forward renderer: physically based materials, where metal and roughness are separate settings; sun shadows split into three distance bands so near shadows stay sharp; shadows from spotlights; many coloured point lights; lighting taken from a sky image; ambient occlusion, which darkens the places where surfaces meet; bloom, which makes bright things glow; height fog; and colour grading.
The three pictures below were rendered for this article on November 28, by the engine’s own game runtime, from the engine’s built-in shapes. The sky is a gradient image I generated, so nothing in them is bought or borrowed.
Two honest notes about the renderer. Point lights do not cast shadows yet; that was put off. And not every part of it was signed off by a person. The work that added the sun’s shadow bands, bloom, materials, ambient occlusion and colour grading was each confirmed by me looking at a staged scene. The work that added point lights and spotlights, and the one that added fog, were closed without that check being run. Their tests pass. The pictures above were checked by eye when they were taken, which is more than those two parts had before.
Where it stands
Kalix is not released, and I am taking a break from it. The rest of this series covers what was most worth learning:
- part 2, dropping the engine’s scripting language because agents now write the game code;
- part 3, giving the agent a way to see;
- part 4, the defects that only looking caught;
- part 5, an animation error that every check passed;
- part 6, a game where you type what your hero does, and why its next version is being built in Unity.