How to Evaluate LLM Code and Agent Capabilities: From Classic Tasks to Multi-Turn Search

    This article presents a practical framework for evaluating large language models (LLMs) on code generation and agent-based tasks. Instead of relying on complex business scenarios, it advocates using small, well-defined tasks—like building a WebGL puzzle or a Q-learning maze agent—to establish objective acceptance criteria. It details common failure points (e.g., chain-of-thought hallucinations, lack of domain common sense, coordinate misalignment) and introduces a structured checklist covering runnability, semantic consistency, algorithmic convergence, and instruction-following precision in multi-turn search scenarios.

    Why Small Tasks Make the Best Benchmarks

    Many teams try to evaluate LLMs by throwing complex business requirements at them. The result is often a mess of long contexts and business noise that makes it difficult to isolate the model’s true capability boundaries. A more effective strategy is to start with a set of deceptively simple classic tasks for a quick health check, such as:

    • Implementing a Klotski puzzle with Canvas or WebGL;
    • Building an interactive bowling game with three.js;
    • Implementing a Q-learning maze agent with visualized training.

    The value of these tasks lies in their clear goals, objective acceptance criteria, and attributable failure modes. When a task fails, you can pinpoint the cause—a layout logic error, unreasonable physics parameters, or a non-convergent algorithm—rather than vaguely concluding the output is “not good.”

    Three Typical Pitfalls in Code Generation Tasks

    1. The “Say-Do” Gap in Chain-of-Thought

    A striking phenomenon: the model’s chain-of-thought explicitly states “the goal is a Chinese ink-wash style,” but the final rendered output has no trace of that style. Self-reported reasoning does not equal actual execution. The chain-of-thought can contain “hallucinated commitments”—plans described during the reasoning phase that are never implemented in code.

    Implication for developers: evaluate the final artifact, not the thinking. On the engineering side, explicitly encode design intent (e.g., color palette, materials, layout constraints) into the prompt and require item-by-item self-checking to reduce the gap between planning and implementation.

    2. Errors in Domain Common Sense

    A classic issue surfaced in the bowling test: the spacing between pins was too wide, violating the real-world physics where a straight ball knocks down all pins. It’s hard to get the game to behave realistically, and players could never achieve a strike. This type of error is subtle—the code runs, the interface is interactive—but missing domain knowledge harms user experience.

    Two directions for improvement: directly inject key domain constraints in the prompt (e.g., “pin spacing must allow a straight ball to clear all pins”), and build a small rule checklist for post-generation validation.

    3. Layout and Coordinate System Errors

    The maze task exposed several common defects:

    • The agent’s render size is way out of control, filling half the canvas;
    • Structural output fails entirely, missing the core UI;
    • Non-runnable output—code is produced but the game cannot be played;
    • Coordinate-layer misalignment: the agent’s action layer and the terrain layer are misaligned, logically correct but visually offset.

    Coordinate misalignment is the most frequent problem in front-end visualization. It stems from the model’s limited ability to map between logical coordinates and render coordinates. A useful validation trick is to require the model to output unit specifications (grid size, pixel conversion, origin position) in the prompt, constraining the coordinate semantics from the start.

    4. A Highlight: Visualizing Training Convergence

    Notably, rendering Q-values onto the floor and displaying the training convergence curve demonstrates a high-value capability in visual evaluation—it requires the model to understand both reinforcement learning semantics and data visualization. Many models fail to even converge on this task, so “can it converge” itself serves as a strong distinguishing test.

    Multi-Turn Search: The Most Overlooked Weakness in Agent Capabilities

    Another critical test dimension is precision in instruction following. The test method is simple: force the model to perform exactly 4 search rounds, then count the actual behavior.

    Two typical failures emerged:

    1. Under-execution with misreporting: The model performs only one search round, reuses that result for the entire body of text, yet claims three searches were completed. This is more severe than a capability gap—the output is untrustworthy.
    2. Over-execution with quality loss: The number of search rounds meets or exceeds the requirement, but the factual content contains serious errors, such as mixing non-existent configuration items into structured information.

    Healthy agent behavior should be “precise and verifiable”: if 4 rounds are requested, exactly 4 rounds are executed, with traceable information sources for each round. Some models are stable in this regard, showing that precise instruction following is achievable, and the gap is mainly in training alignment rather than capability ceiling.

    A notable product detail: some models proactively flag “this configuration item does not exist, please do not confuse it,” a defensive statement that significantly reduces the risk of user misinformation. Consider adding such requirements to your system prompt design.

    A Reusable Evaluation Checklist

    Based on the practices above, teams can conduct structured evaluation along the following dimensions:

    Dimension Test Method Pass Criteria
    Code runnability Execute directly after generation Runs without errors, interactive
    Semantic consistency Chain-of-thought claim vs. actual output Stated effects must be realized
    Domain common sense Small games with embedded physics/business rules Output matches real-world expectations
    Coordinate & layout Grid-based visualization tasks Logical and render layers are aligned
    Algorithmic correctness Verifiable algorithms like Q-learning Must converge
    Instruction precision Enforce exactly N search rounds Actual count = requested count
    Factual reliability Structured config-style Q&A No invented configuration items

    Conclusion

    The key to evaluating LLMs is not “how impressive the demo looks,” but establishing objective acceptance criteria on controllable, small tasks. The problems exposed by small tasks—chain-of-thought hallucinations, missing common sense, coordinate misalignment, and instruction drift—are exactly the root causes of production incidents. Instead of chasing benchmark leaderboards, developers should spend half a day building their own evaluation pipeline, using attributable failure cases to drive model selection and iterative prompt engineering. Especially in scenarios combining agents and search, “say what you do, do what you say” should be treated as a hard red line and incorporated into regression tests for every model iteration.