Practical Bottlenecks and Reflections on LLMs in Complex Engineering Refactoring
As LLMs evolve from function-level code completion to engineering-level automated refactoring, their performance in complex business scenarios—particularly in system-level programming language projects with strict compilation checks—often becomes unpredictable. Based on a recent complex engineering refactoring project and multiple algorithmic validation tasks, this article analyzes the current bottlenecks of LLMs in complex coding tasks, such as attribution bias and shotgun programming, and explores corresponding mitigation strategies to guide LLMs toward true engineering-level intelligence.
As LLMs continue to iterate in code generation, developers’ expectations for intelligent coding tools have escalated from simple “function-level completion” to “engineering-level automated refactoring.” However, in real-world complex business scenarios, particularly when dealing with system-level programming language projects that involve massive dependencies and strict compilation checks, LLMs often exhibit significant variance and unpredictable fluctuations in performance. This article draws on a recent complex engineering refactoring project and several algorithmic validation tasks to deeply analyze the current bottlenecks of LLMs in complex coding tasks and discuss corresponding mitigation strategies.
1. “Attribution Bias” and “Shotgun Programming” in Complex Engineering Refactoring
During a recent large-scale refactoring task for a system-level programming language project, we used intelligent tools to generate an extremely detailed execution plan in advance, specifying each code modification point and its corresponding validation method. To horizontally evaluate the capabilities of current mainstream LLMs, we distributed the identical codebase and plan to several mainstream LLMs in the industry for execution testing.
While most mainstream models demonstrated high stability in understanding the plan, executing modifications, and passing compilation tests, a certain new-generation LLM exposed several fatal logical flaws:
1. Attribution Bias
During the first two steps of the plan, the model claimed completion in just five minutes but immediately concluded that “build tool cache issues prevented correct compilation” and requested human intervention. After being instructed by a human to clean the build cache, the model did not actually verify whether the compilation passed before moving to the next step. When it encountered compilation failures again, it once again blamed “severe compiler cache issues affecting normal operation.” This behavior of attributing “syntax or logical errors in its own generated code” to “underlying toolchain failures” is a typical hallucination and self-rationalization. The model failed to correctly parse the error logs output by the compiler, leading to a complete failure in error localization.
2. Falling into the “Shotgun Programming” Trap
After a human forcibly corrected its perception (explicitly stating that the code itself contained errors and must be fixed and pass tests before proceeding), the model’s behavior degraded. It began making “shotgun-style” blind modifications: making illogical additions, deletions, and changes across the codebase—tweaking a line here, adjusting a parameter there. This lack of an overall logical closed-loop caused compilation errors to increase rather than decrease. After two hours of futile tinkering, the codebase was completely ruined (with over 3,000 cumulative modifications) and still could not pass the most basic compilation. This indicates that when a model lacks the ability to deeply analyze dependencies within a large project context, its modification strategy degrades into probability-based random guessing, ultimately leading to irreversible engineering chaos.
2. Lack of Logic and Common Sense in Multimodal and Algorithmic Tasks
Beyond pure-text complex code engineering, some LLMs equipped with multimodal and agent capabilities have also exposed weak foundational logic in visual presentation and algorithmic implementation tasks.
1. Ignoring Physical Common Sense and Basic Rules
In a bowling scene test based on frontend 3D rendering technology, although the model could generate seemingly cool lighting and particle effects, it severely lacked common sense regarding core physical rules. For example, the generated gaps between bowling pins were too large, making it impossible to achieve a “strike,” a standard game objective; the scene’s lighting settings were extremely unreasonable, resulting in a pitch-black interface that was difficult to discern. This shows that when generating multimodal content, the model overfitted to visual effects training data while neglecting adherence to real-world physical laws and the core objectives of the task.
2. Disconnect Between Execution and Rendering in Reinforcement Learning Scenarios
In a maze Q-learning reinforcement learning task, the model’s performance was equally unsatisfactory. In multiple attempts, the model not only made basic errors such as abnormal Agent rendering sizes and maze generation failures, but even in the final runnable version, there was a misalignment between the Agent’s action layer and the terrain layer, completely paralyzing the game logic. Although the model demonstrated an innovative presentation in its chain of thought by mapping Q-values onto the floor, and some training eventually converged, the overall unavailability of the function rendered these localized highlights meaningless.
3. Developer Strategies and Engineering Practice Recommendations
Faced with the above bottlenecks exposed by LLMs in complex tasks, developers should adopt more cautious and structured auxiliary strategies in actual engineering to avoid efficiency regressions caused by over-reliance.
1. Decompose Verification Units and Build a Closed-Loop Feedback Mechanism
For complex system-level language engineering, massive multi-step plans should not be handed over to the model for execution all at once. Tasks should be decomposed into atomic-level modification units, each accompanied by explicit automated test cases. Only when the code output by the model passes the unit tests should it be allowed to proceed to the next phase. This effectively prevents global pollution caused by “shotgun programming.”
2. Enforce Log Constraints to Block Model Hallucinations
To address the model’s “attribution bias,” strong constraints must be introduced at the Prompt and system architecture levels. By leveraging logging services and container platforms (such as Baidu AI Cloud), real compiler error logs and stack trace information can be directly extracted and injected into the model’s context. The model must be required to make corrections based on specific line numbers and error types in the logs, strictly prohibiting it from outputting vague and unfounded conclusions like “toolchain failure.”
3. Separate the Generation Pipelines for Multimodal and Core Logic
When performing tasks involving physical rules or complex algorithms (such as reinforcement learning), it is recommended to separate the generation of “visual rendering” and “business logic.” Business logic should be generated using strictly verified traditional code frameworks or pure-text models, supplemented by rigorous interface testing; multimodal rendering should only serve as the presentation layer, interfacing with the logic layer through well-defined APIs. This prevents the model from sacrificing the correctness of core functions while trying to accommodate visual effects.
Conclusion
The potential of LLMs in code generation is undeniable, but when faced with the strict compilation environments, complex engineering dependencies, and multimodal business logic of system-level languages, their reasoning capabilities and engineering literacy still need improvement. While enjoying the efficiency dividends brought by AI, developers must maintain a reverence for engineering baselines. Through reasonable task decomposition, real log feedback, and the assistance of cloud infrastructure, we can guide LLMs toward true “engineering-level intelligence.”
