Building UEFI Games with LLM Coding Agents: From Scratch to a Working Build

    A UEFI game makes for a demanding test of an AI coding agent: a successful build tells you little about what will happen at runtime, and serial logs may be your only useful feedback. This case study follows an agent that built a Chinese-language Breakout game in about two and a half hours, then took on a second challenge: getting another model’s unfinished Tetris game to run. The repair shows how code review, targeted logging, and measurable milestones can turn an AI-generated codebase into a working application.

    1. Why Test AI Coding Agents in UEFI?

    In the past year or two, large language models have gone from completing individual functions to building small projects. Most benchmarks and demos still focus on web applications and scripts, where mature tools, informative error messages, and abundant public examples make it easier to recover from mistakes. Good results in those settings tell only part of the story.

    I wanted a task with tighter runtime constraints, less diagnostic feedback, and fewer examples to draw on: building a Chinese-language Breakout game that runs directly in the Unified Extensible Firmware Interface (UEFI) environment, without booting an operating system.

    That choice introduced three challenges:

    1. No operating system to fall back on. The application has to manage memory and handle display and input through firmware services and protocols, such as the Graphics Output Protocol (GOP). A mistake can cause the program to hang or the machine to restart.
    2. Limited debugging tools. Instead of setting breakpoints in an IDE, I relied on serial logs to trace execution.
    3. Ambiguous failures. A successful build does not guarantee a successful launch. Even if the program starts, the point where it fails may be several steps removed from the underlying bug.

    This made UEFI a useful test of whether an agent could do more than write code. It also had to reason about runtime behavior and use incomplete evidence to narrow down a failure.

    2. The Experiment: Build One Game, Rescue Another

    In the first phase, I paired a coding model with a command-line coding assistant. In about two and a half hours, it took the Breakout game from environment setup and code generation to a successful build and run on the first attempt. I mostly defined the requirements and checked the result; the agent handled nearly all the implementation.

    The second phase started with a different outcome. Another model had spent almost six hours trying to build Tetris in the same environment without producing a runnable program. It did, however, leave behind seven source files with clear module boundaries and reasonably well-defined interfaces. That raised a more interesting question: Could one AI agent salvage another model’s code when it looked sound but would not run?

    I split the repair into two rounds:

    • Round 1: Make it run. Find and fix the faults that prevented the game from launching and displaying graphics.
    • Round 2: Make it play well. Improve the frame rate, input handling, text rendering, and exit behavior.

    The idea was to give the agent small, verifiable goals rather than ask it to deliver a polished game in one pass.

    3. Round 1: Getting from a Successful Build to a Working Game

    Review the Whole Codebase Before Editing

    My first instruction was deliberately narrow: read every module, list the problems, and do not change any code. Asking the agent to “fix it” immediately could have led it to patch the first issue it found without understanding how the rest of the application worked.

    The model spent a few minutes reviewing the entry point, main loop, game logic, rendering, and input handling. It returned an organized list of issues and predicted that fixing them would get the game running. The prediction turned out to be premature, but the review gave us a useful map of the code before we started making changes.

    Problem 1: The Game Exited Just After Launch

    After the initial fixes, the program built and started. It printed Starting Game Loop and then exited. That was progress, but the message alone did not tell us where execution had gone wrong.

    I asked the agent to add more granular serial logging around the startup sequence. The new trace narrowed the failure to the code that handled the GOP display mode. The agent identified a pointer-lifetime problem: the code retained a reference to mode data obtained before a display-mode switch, then used that reference after the switch, when it was no longer valid.

    The fix was to refresh the display and framebuffer information after switching modes. The following pseudocode shows the ordering change, not literal UEFI API signatures:

    1. // Before: keep a reference to mode data across a mode switch.
    2. QueryMode(..., &info);
    3. SetMode(...);
    4. // Rendering uses the stale reference.
    5. // After: refresh the mode information after the switch.
    6. SetMode(...);
    7. QueryMode(..., &info);
    8. // Rendering uses the refreshed information.

    The early exit disappeared after the change. The key was not that the agent spotted a bug by reading the code alone. It used the serial trace to narrow the search, then examined how the order of the firmware calls affected the data the renderer relied on.

    Problem 2: The Game Ran, but Nothing Appeared on Screen

    Once the program ran without exiting, a second problem became apparent: the serial logs looked normal, but the graphics never appeared.

    The agent traced the blank screen to an incorrect protocol GUID. In UEFI, a GUID is a 128-bit identifier used to locate a protocol. The identifier in the code did not match the Graphics Output Protocol it was trying to retrieve. That mismatch did not cause a compile-time error or an obvious exception; the application simply failed to obtain the interface it needed.

    Correcting the GUID brought up the game interface and completed the first round. Like the pointer issue, this was a failure a clean build could not reveal. Unlike the crash, it gave us almost no visible indication of what had gone wrong.

    4. Round 2: Improving the Play Experience

    With the game running, I set four goals for the second round: stabilize the frame rate, debounce input, improve rendering for the Chinese bitmap font, and make the exit sequence more orderly. Three practices helped keep the work manageable:

    1. Ask for one kind of change at a time. Combining performance tuning, UI changes, and refactoring in a single prompt makes it harder to tell which requirement was met or which edit introduced a regression. I reviewed each batch before moving on.
    2. Make acceptance criteria observable. For frame pacing, I asked the agent to log timing measurements rather than rely on whether the game felt smoother.
    3. Keep a human in charge of reviewing changes. I checked the scope of proposed edits, especially when they affected hardware interactions or memory lifetimes.

    5. What the Experiment Revealed About AI Coding

    The most useful capability was iteration, not one-shot generation. Getting Breakout running on the first attempt was impressive, but the Tetris repair was more revealing. The agent made progress by turning a symptom into a hypothesis, testing it against runtime evidence, and revising the code. That loop mattered more than the quality of any single generation.

    A failed build can still leave behind useful context. The original Tetris code did not run, but its module boundaries and interfaces made it easier for another agent to understand and repair. Good structure was worth preserving even though the first implementation had failed.

    A useful benchmark should expose the failures you care about. A mature web toolchain can absorb mistakes and give agents enough feedback to recover, masking differences in how they reason through sparse evidence. Teams evaluating coding agents should include a few difficult tasks from their own work. As cloud providers, including Baidu AI Cloud, emphasize coding-agent capabilities, a test drawn from a team’s hardest real workflows can tell it more than a feature list.

    I came away thinking less of the coding agent as a code generator and more as a junior engineer with broad technical knowledge. It could make progress even in a firmware environment, but it did its best work when I set clear goals, made runtime behavior observable, and reviewed changes in small steps.