Evaluating LLMs on a Hard Benchmark: Building a UEFI Shell Game

    This article presents a benchmark practice for evaluating the coding ability of large language models by asking them to implement a complete classic mini-game inside a UEFI Shell environment. It explains why a resource-constrained, unfamiliar runtime exposes engineering gaps that generic Q&A and algorithm tasks hide, then breaks the evaluation into five task layers (L1 environment probing, L2 single capability, L3 interaction loop, L4 engineering quality, L5 iterative repair) and five scoring dimensions, including first-pass rate, API accuracy, structural clarity, repair efficiency, and rework cost. It also covers prompt strategies that trade constraints for stability, the three review gates any model output must pass, and practical guidance for building internal benchmark sets. The key takeaway is that the goal is not ranking models but measuring how much manual rework is required before generated code can actually ship.

    1. Why Code Evaluation Needs a Hard Benchmark

    Generic Q&A and algorithm problems can no longer separate models by their real engineering capability. The reason is simple: these tasks lack strong environmental constraints, so a model can produce an answer that “looks correct” by reusing common patterns from its training data. Only when a task is placed in a real environment with limited resources, no high-level language runtime, and few debugging options does a model’s engineering maturity become visible.

    The benchmark task used here is to implement a structurally complete classic mini-game inside the UEFI (Unified Extensible Firmware Interface) Shell environment. Its discriminative power comes from four layers of constraints:

    1. Unfamiliar runtime: The target is not a conventional operating system. There is no mature graphics library or high-level runtime, so the model must infer what capabilities are actually available.
    2. Limited resources and interfaces: Display output, key input, and timing control can only be done through a small set of low-level interfaces, and the model must understand their semantics precisely.
    3. Strong verifiability: Whether the program compiles, runs, and responds correctly is fully decidable and does not depend on subjective judgment.
    4. High engineering completeness requirement: The task needs a state machine, a rendering loop, collision detection, input debouncing, and other cooperating modules, which tests the model’s ability to design in layers.

    The purpose is not to rank models but to answer an engineering question: in a strongly constrained environment, how much manual rework does a model’s output need before it can be put into production.

    2. Evaluation Design: Turning “Can It Write It” into Measurable Items

    Many evaluations reach contradictory conclusions because they mix different dimensions into a single score. A more rigorous approach is to layer the tasks and score them by dimension.

    2.1 Task Layers

    • L1 Environment probing: Have the model output a minimal runnable program to validate whether its assumptions about the target environment hold.
    • L2 Single capability point: Implement only screen clearing and character drawing to check how accurately the interfaces are used.
    • L3 Interaction loop: Add key scanning and debouncing to complete a “move–collide–score” loop.
    • L4 Engineering quality: Require modular decomposition, centralized constant management, frame rate control, and fallback handling for exceptions.
    • L5 Iterative repair: Provide compiler errors and runtime exception logs to test the model’s ability to locate and fix problems.

    L5 is often the most overlooked layer, yet it is the closest to real development: what developers need is not a perfect answer produced in one shot, but a collaboration ability that converges based on feedback.

    2.2 Scoring Dimensions

    Dimension Focus How It Is Judged
    First-pass rate Whether the first output compiles and runs Binary judgment
    API accuracy Whether nonexistent functions are invented Call-by-call verification
    Structural clarity Module boundaries and naming Manual review
    Repair efficiency How many rounds of feedback until convergence Round counting
    Rework cost Share of lines manually modified Quantitative measurement

    Among these, “API accuracy” is the most critical negative indicator. Model hallucination is extremely costly in a strongly constrained environment: a single invented drawing function can make all subsequent code meaningless.

    A schematic structure of the minimal probing code is shown below (pseudocode, expressing only the layering idea):

    1. // Layering sketch: init -> render -> input -> main loop
    2. STATUS InitSubsystem(VOID);
    3. VOID RenderFrame(INT32 State);
    4. BOOLEAN ReadInput(INPUT_EVENT *Event);
    5. VOID GameMainLoop(VOID);

    Asking the model to first produce an interface list and its assumptions, and only then write the implementation, can significantly reduce the hallucination rate.

    3. Prompt Strategy: Trading Constraints for Stability

    In strongly constrained tasks, the role of a prompt is not to “ask more politely” but to make implicit premises explicit. Four practices that work in practice:

    1. Declare environment boundaries first: State clearly which capabilities are available, which libraries must not be assumed, and the memory and stack limits.
    2. Produce the interface contract first: Require function signatures and data structures to be listed and confirmed before writing the implementation, avoiding a large batch of erroneous code generated at once.
    3. Converge step by step: Solve only one problem per stage so that each output can be verified independently.
    4. Enforce self-checking: Require the model to list an “unverified assumptions list” at the end, making uncertainty explicit and easy for humans to triage quickly.

    The benefit of this strategy is reproducibility: the same prompt yields smaller differences across time and across models, which is what makes longitudinal comparison in evaluation possible.

    4. Reviewing Results: Three Gates Every Model Output Must Pass

    1. Static gate: Check whether nonexistent interfaces are referenced, and whether there are out-of-bounds accesses or uninitialized variables.
    2. Runtime gate: Execute in the real target environment and record first-screen behavior, input response latency, and abnormal exit conditions.
    3. Regression gate: Re-run all L1–L4 cases with the fixed code to prevent “fix one, break two”.

    Only output that passes all three gates is eligible to enter a project. The missing regression step is the main reason most evaluation conclusions are distorted.

    5. Selection Advice and Engineering Adoption

    For developers and enterprise users, the conclusion should land on process rather than a leaderboard:

    • Build an internal benchmark set: Turn the typical constraints of your own business into 5–10 small tasks that can be judged automatically.
    • Distinguish scenario weights: For scripting tasks, look at first-pass rate; for long-chain engineering, look at repair efficiency and structural clarity.
    • Keep a human fallback: In strongly constrained environments, final quality responsibility still rests with the reviewer.
    • Keep costs predictable: Combine general model service categories available on the cloud with logging and monitoring capabilities to observe call volume and control budget, rather than relying on a single hands-on impression.

    On whether to test only domestic models: from an engineering perspective, the value of an evaluation lies in a transferable method. Once the benchmark task, scoring dimensions, and review process are fixed, any model can be measured with the same ruler, and selection discussions can move from impressions to data. At the same time, continuously feeding real-world scenarios back to model providers is the most direct driver of capability improvement.

    In summary, the point of a strongly constrained benchmark task is not to produce winners and losers, but to convert “can the model be used” into “how much rework is needed to use it”. This practice, spanning task layering, prompt constraints, and the three review gates, can be reused directly for evaluating code capability in any low-level environment or constrained runtime.