Evaluating LLMs in Long-Horizon Programming Tasks: Methods and Risk Boundaries
This article explores practical methods for evaluating large language models (LLMs) in long-horizon programming tasks and outlines their risk boundaries. It shifts the focus from simple algorithmic coding to real-world software development, covering context understanding, cross-module execution, and delivery completeness. Key topics include assessing models in legacy projects, enforcing security constraints and permission isolation, verifying product completeness, and identifying areas where manual intervention is mandatory.
1. Why Redefine the Evaluation of Coding Capabilities
When evaluating coding models, looking at public leaderboard scores is common practice. Leaderboard tasks are usually small in scale, have clear boundaries, and can be automatically judged, making them suitable for comparing basic capabilities. However, real-world software development rarely works this way. A single requirement often involves modifying APIs, data models, background tasks, and frontend pages simultaneously, while also respecting undocumented conventions in legacy code.
Therefore, the focus of evaluation should shift from “can it write a correct piece of code” to “can it push a complete task to a deliverable state.” Here, deliverable means at least three things: the code runs, relevant tests pass, and the scope of changes aligns with the requirements.
1.1 Differences Between Single-Point Tasks and Long-Horizon Tasks
Single-point tasks test local reasoning, such as implementing a sorting function or fixing a specific bug. Long-horizon tasks test state retention. The model needs to remember previous design decisions, maintain consistency across dozens of files, and adjust its approach when failures occur midway, rather than starting from scratch.
In practice, the failure modes of these two task types differ. Common errors in single-point tasks are logical mistakes. In long-horizon tasks, more frequent issues include missing a caller, inconsistent API fields, migration scripts not matching model definitions, and modifying the tests themselves just to make them pass.
1.2 Three Evaluation Dimensions
It is recommended to record results across the following three dimensions:
- Context Understanding: Did the model understand the responsibilities, naming conventions, and data flow of existing modules?
- Cross-Module Execution: Can the model maintain consistency across multiple layers and execute changes in dependency order?
- Delivery Completeness: Does the feature run, do tests cover new paths, and are documentation and configurations updated synchronously?
Each dimension should be backed by observable evidence. For instance, context understanding can be judged by the model’s reading plan and the list of files it touches; delivery completeness relies on actual execution results, not the model’s self-description.
2. Evaluating Understanding in Legacy Projects
Legacy projects are excellent scenarios for testing a model’s understanding. These projects usually share a few characteristics: inconsistent directory structures, logic scattered across configurations and scripts, and undocumented “tribal knowledge” conventions.
2.1 Ask the Model to Output a Reading Plan First
Before modifying any code, require the model to output a reading plan. This should list the modules it plans to inspect, the assumptions it needs to confirm, and the potentially affected areas. Manually reviewing this plan helps catch misunderstandings early.
An effective plan typically includes:
- Entry files and call chains involved in the requirement.
- Existing definitions of database tables or data structures.
- Locations of existing permission checks.
- The list of files planned for modification and the order of changes.
- Tests that need to be added or updated.
If the plan mentions module names that do not exist in the project, the model is likely relying on general experience rather than the actual codebase. In this case, correct the context before allowing it to proceed.
2.2 Write Constraints into the Task Description
Legacy projects often have implicit conventions, such as field naming rules, error code formats, and logging level practices. If these are not clearly stated, the model will likely implement based on general conventions, resulting in inconsistencies with the project’s style.
It is recommended to compile these constraints into a brief statement placed at the beginning of the task. This should include: public APIs that must not be modified, required error handling methods, prohibited dependency types, and performance or resource limits.
3. Security Constraints and Permission Isolation
One of the most notable issues in this evaluation is the permission isolation flaws exposed after features are completed. These issues are hard to find during functional testing because the normal path usually passes.
3.1 Common Risks in User Asset Import
Allowing users to upload images and reference them in pages introduces the following risks:
- File type spoofing (e.g., renaming a script file as an image).
- Path traversal (e.g., including parent directory symbols in filenames).
- Unauthorized access (e.g., users reading other users’ assets by guessing IDs).
- Resource abuse (e.g., uploading oversized files to exhaust storage).
- Malicious content (e.g., executing unexpected scripts in an animation page).
These risks must be handled individually on the server side; frontend validation serves only as an auxiliary measure.
3.2 Path Validation Example
The following example demonstrates the basic logic for filename handling and directory scope checking. It illustrates the principle only; actual projects need adjustments based on the framework and storage method.
from pathlib import PathALLOWED_EXTS = {".png", ".jpg", ".jpeg", ".webp", ".gif"}MAX_SIZE_BYTES = 5 * 1024 * 1024def resolve_asset_path(storage_root: Path, user_id: str, filename: str) -> Path:# Keep only the filename part, discard any directory componentssafe_name = Path(filename).nameif Path(safe_name).suffix.lower() not in ALLOWED_EXTS:raise ValueError("unsupported file type")user_root = (storage_root / user_id).resolve()target = (user_root / safe_name).resolve()# The resolved real path must still be within the user's directoryif not target.is_relative_to(user_root):raise PermissionError("path escapes user directory")return target
There are three key points in this code. First, the filename is truncated to a pure name, stripping path components. Second, extension checking is only the first filter; true type identification should read the file header. Third, path validation occurs after resolution, comparing the real path rather than the original string.
3.3 Isolation Methods for HTML Animations
If a page needs to reference user-uploaded HTML animations, they should be placed in a restricted runtime environment. Common practices include:
- Loading content using an iframe with sandbox attributes, without granting same-origin permissions as the main site.
- Using Content Security Policy (CSP) to restrict script sources and prohibit loading unvetted external resources.
- Performing structural checks on user-uploaded HTML to reject files containing dangerous tags or event attributes.
- Using different domains or subdomains for assets and the main site to avoid sharing cookies and storage.
<iframesrc="https://assets.example.com/preview/xyz"sandbox="allow-scripts"referrerpolicy="no-referrer"></iframe>
The example does not include allow-same-origin, so the embedded content cannot read the main site’s cookies or local storage. This configuration limits some functionality but significantly reduces risk.
3.4 Why Permission Issues Are Easily Missed
When implementing features, models tend to make the normal flow work. Permission checks are often extra branches that are easily omitted or only implemented in some interfaces. For example, a list API might apply filtering, while a detail API returns data directly by ID.
When verifying permissions, prepare at least two test accounts and have them try to access each other’s resources. Test cases must cover all entry points: list, detail, update, delete, and export. Functional testing alone cannot uncover these issues.
4. Evaluating Completeness from Materials to Product
The second type of task starts from learning materials and product requirement documents (PRDs) to independently build a playable learning application. This tests whether the model can organize scattered information into a complete product.
4.1 Requirement Coverage Check
Break down the requirement document into verifiable items and annotate the corresponding implementation locations. Common omissions include:
- Unlock conditions for a certain level are not implemented.
- Progress is lost after a page refresh.
- Score calculation on the settlement page does not match the document’s rules.
- Missing feedback for incorrect answers.
A simple approach is to write an acceptance test case for each requirement, use an automated script to complete the operation path in the browser, and record the results.
4.2 Playthrough Path Validation
For game-like products, “can be completed” is the most direct acceptance criterion. Walk through the complete flow from start to finish, checking the entry, judgment conditions, and exit of each level. Also check for infinite loops, inaccessible branches, and irreproducible issues caused by random number dependencies.
4.3 Content Accuracy
Learning products also require checking the accuracy of knowledge points. The model might state concepts too absolutely or confuse similar terms. It is recommended to have someone with a relevant background spot-check the questions and explanations, especially those involving specific mechanisms and parameters.
5. Which Stages Require Manual Acceptance
Based on the practices above, the following stages should be mandatory for manual confirmation:
- Every rule regarding permissions and access control.
- Validation logic for external inputs, including files, links, forms, and query parameters.
- Data migration scripts, especially parts involving deleting or modifying existing data.
- Calculation logic involving money, quotas, or billing.
- Exposed API documentation and error messages.
These stages share a common trait: the cost of error is high, and functional testing usually does not cover them. Auto-generated code can speed up implementation, but the responsibility for review cannot be shifted to the model.
6. Practical Checklist
Before assigning a long-horizon programming task to a model, prepare using the following checklist:
- Clarify the task scope; list directories allowed and prohibited from modification.
- Provide key project conventions, such as naming rules, error handling, and dependency limits.
- Require the model to output a reading plan before modifying code.
- Break the task into smaller steps; run tests and commit after each step.
- Write tests for new features and retain logs of test results.
- Perform cross-validation with multiple accounts on permission-related code.
- Manually review all security and data-related changes.
- Keep a rollback plan to ensure any step can be undone.
The value of small-step commits lies in locating problems. When a single change spans over a dozen files, it is difficult to determine which step introduced a defect. Breaking the task down with clear validation results for each step significantly reduces troubleshooting costs.
7. Conclusion
The performance of LLMs in long-horizon programming tasks is now sufficient to support trials in real projects. Models can read complex contexts, continuously drive cross-module changes, and bring tasks to a runnable, testable state. These capabilities hold practical value for daily development.
At the same time, feature completion does not equal delivery completion. Permission isolation, input validation, data security, and final acceptance still require manual oversight. Evaluation should focus on evidence, including execution results, test coverage, and multi-role validation, rather than the model’s own statements.
Only by combining task design, process documentation, and manual review can long-horizon programming capabilities translate into reliable engineering benefits.
