Giving the Agent Eyes
By July the agent working on Kalix could do almost anything in the engine through its connection to the editor (see part 1). It could spawn things, move them, play animations, change materials and save scenes. It could not see any of it.
That gap had a cost I kept paying. A character’s run animation was wrong, and the agent was diagnosing it from numbers alone: joint angles, clip names, positions. It was the wrong way round. A person would have looked once.
Four tools, all read-only
On July 25 the engine gained four tools the agent can call, in the editor or in a running game:
- A screenshot of exactly what the game draws: the 3D scene with its lighting and post-processing, and none of the editor’s panels.
- A strip of frames taken a set time apart and laid out on one image, so the agent can see motion without being sent a video.
- A labelled screenshot: the same picture plus a list of which object occupies which box on screen.
- A read of the game’s input, meaning the keys and buttons the game itself saw this frame, not a log of the whole keyboard.
None of them changes anything, so none of them needs to be logged as a change. They added no new libraries: the image encoder was already in the project, and MCP already supports sending images.
The first real use was the run animation. The strip of frames showed the character rolling about 39 degrees to one side as it ran, and a script that levels a clip back out came out of that diagnosis. One look, after two working sessions of reading numbers.
There was a smaller lesson in building them. The engine’s rules had described a “capture snapshot” command since the start. It had never been written. The rule was a description of something we meant to do, sitting next to rules that described things the engine actually did.
The screenshots could not see the game’s interface
In August the agent was checking interface work, the health bars and menus drawn on top of the 3D scene. Its screenshots had no interface in them at all.
The capture copied the image at the end of the 3D pipeline. The interface is drawn after that step. So all four tools had been leaving it out since July, and on a running game whose scene happened to be empty, the agent got back a black frame and could not tell that from a broken game. Adding one draw call to the capture fixed all four tools at once.
Measuring from pixels instead of judging by eye
Once the agent could see, it could measure. The interface gained a way to fade a whole group of shapes and text together. Shapes and text are drawn by different code with different colour rules, so the risk was that a half-faded group would show half-faded panels with full-strength text on them.
The agent compared a half-faded group with a full-strength copy of it. The panel came out at 0.737 of its full brightness and the text at 0.739. The two rules agree within 0.002. They read 0.74 and not 0.5 because the picture passes through the engine’s tone mapping on the way to the screen, so the useful number is the comparison between the two, not either value alone.
The instrument can be wrong too
Seeing introduced its own mistakes, and the first ones were in how the pictures were read, not in the engine.
- Resized pictures. Captures are scaled down before they are sent, from 1280 by 720 to 1024 by 576 in one test. A check that read pixels at fixed positions reported that two identical panels had different edges, 0 against 47. Scaling had simply landed the two edges on different pixels. The fix is to compare the width of an edge, which survives scaling, and never raw pixels at fixed places.
- Stale pictures. Testing buttons, the agent took thirteen captures in a row that were identical to the byte. That is what a picture of a frozen game looks like, and also what a picture looks like when the input never arrived. It was the input: moving the real mouse does not reach a window in the background, and sending the window its messages directly does.
A cross-fade, and the one case nobody tested
In August the interface gained transitions, including fading from one screen to another. The agent watched it in a test with two screens side by side, switching back and forth between them. One is set to cross-fade when it arrives and one is set to appear instantly. At the same capture rate, switching to the first showed 11 in-between frames, and switching to the second showed none. The screen that does not fade is what makes the other result mean something: without it, an engine that faded everything would have passed too.
The same session found a real bug. A script could ask any value to animate smoothly to a new one. For position that worked. For a group’s fade, it jumped: brightness went from 73.9 to 179.0 between two captures 150 milliseconds apart. Fading a group was the main reason the feature existed, and every automated test of it had used position instead.
It was fixed the same day and the fix has its own test now. I have to add that nobody has watched the fixed fade on screen since.
What the agent still cannot see
The captures show what the game draws. The editor’s own panels are a separate picture, and the agent’s tools do not include it. When the agent has needed to check the editor, it has used scripts that send the editor window clicks and copy what Windows shows. That works, but it is slower, and some panels still need a person.
The bigger limit is judgement. The agent can tell me two numbers agree to three decimal places. It cannot tell me whether a punch feels heavy. That part is still mine, and part 4 is about what happened when I skipped it.