LLM Selection for Coding Assistance: A Task-Complexity Approach

    As LLM-assisted coding becomes common, teams need a repeatable way to choose models for different tasks rather than relying on impressions. This article defines task levels, proposes an evaluation framework with concrete dimensions and record structures, and discusses large-file handling, source-code analysis, total cost, and layered model-selection strategies.

    LLM Selection for Coding Assistance: A Task-Complexity Approach

    1. Why Model Selection Is Now an Engineering Problem

    As coding assistants become widespread, the question for teams is no longer whether to use large language models to write code. It is which model to use for a specific task. Model versions iterate quickly, and their strengths trade off across different dimensions. A model that performs well on small function completion may lose global conventions when working in a file with thousands of lines. Model selection therefore needs a reproducible method, not one or two subjective impressions.

    This article turns a typical subjective comparison into a general evaluation framework and discusses the meaning, measurement, and decision logic of each dimension. The examples are generic and do not refer to proprietary parameters of specific products.

    2. Define Task Levels Before Comparing Model Capabilities

    The answer to “which model is stronger” depends on the task. A practical approach is to divide development tasks into three levels:

    • Simple tasks: single-function completion, regular expression writing, format conversion, and simple unit tests. Input and output boundaries are clear, and errors are easy to catch through compilation or tests.
    • Medium tasks: module-level feature implementation, API integration, and extending code according to existing patterns. These tasks require understanding project conventions such as naming rules, directory structure, and error-handling style.
    • Complex tasks: cross-file refactoring, large-file splitting, source-level analysis, architecture review, and optimization planning. These tasks require the model to maintain consistent judgment across a large context.

    The point of this layering is to match model capability to task requirements. For simple tasks, capable models often differ little, so cost and response speed deserve more attention. For complex tasks, small misunderstandings can be amplified layer by layer, so model choice has a greater impact on the result.

    3. Build a Reproducible Evaluation Framework

    3.1 Evaluation Dimensions

    A practical evaluation framework should include at least six dimensions:

    1. Intent understanding: Can the model explain why code is designed this way, not just describe what the code does?
    2. Delivery completeness: Are all functional modules present? Does the output pass existing tests? Are configuration, documentation, or migration steps missing?
    3. Large-file handling: After splitting, are module boundaries reasonable? Are dependencies closed? Are interfaces consistent?
    4. Architecture analysis: Is the analysis based on exploration of the project’s global structure? Are recommendations prioritized? Can they be translated into concrete changes?
    5. Boundaries and exceptions: Are cases such as null values, concurrency, timeouts, and insufficient permissions considered?
    6. Cost and time: What are the invocation cost, waiting time, and proportion of manual correction required?

    3.2 Evaluation Record Structure

    To make each comparison reviewable, use a fixed test set and record the model version, prompt, output, and score. Below is an example evaluation record structure:

    1. from dataclasses import dataclass, field
    2. @dataclass
    3. class EvalCase:
    4. case_id: str
    5. level: str # simple / medium / complex
    6. dimension: str # intent / completeness / large_file / architecture / edge / cost
    7. prompt: str
    8. acceptance: list[str] # acceptance criteria, each item can be checked individually
    9. @dataclass
    10. class EvalResult:
    11. case_id: str
    12. model: str
    13. model_version: str
    14. output_ref: str # location of the output for later review
    15. scores: dict[str, int] = field(default_factory=dict) # each acceptance item scored 0/1 or 0-5
    16. elapsed_seconds: float = 0.0
    17. review_minutes: float = 0.0 # time spent on manual review and correction

    Acceptance criteria should be written as sentences that can be checked one by one, such as “each file after splitting compiles independently” or “the signatures of all existing public interfaces remain unchanged.” This is how scoring moves from “it feels good” to comparable data.

    3.3 Keep Test Conditions Fixed

    When comparing models, control the variables: use identical prompts, provide identical context, and run each task multiple times to observe variation. Model outputs are stochastic, so a single result cannot represent true capability.

    4. Large-File Handling: The Most Underestimated Dimension

    Large-file tasks test the model’s ability to maintain global consistency over a long context. There are three common failure modes:

    • Broken dependencies: Extracted files reference each other, but import paths or export names do not match.
    • Scattered state: Configuration or global variables that were centrally managed are split across multiple files, changing initialization order.
    • Convention drift: An error-handling style used in the first half is quietly replaced by another style in the second half.

    A practical response is to split a large task into two steps. First, ask the model to output a dependency graph and a splitting plan, and have a human confirm it before changing code. Second, generate files one by one and run static checks and tests at each step. Below is a basic checking approach:

    1. import ast
    2. from pathlib import Path
    3. def collect_imports(path: Path) -> set[str]:
    4. tree = ast.parse(path.read_text(encoding="utf-8"))
    5. names = set()
    6. for node in ast.walk(tree):
    7. if isinstance(node, ast.ImportFrom) and node.module:
    8. names.add(node.module)
    9. elif isinstance(node, ast.Import):
    10. names.update(alias.name for alias in node.names)
    11. return names
    12. def check_module_refs(root: Path, known_modules: set[str]) -> list[str]:
    13. problems = []
    14. for file in root.rglob("*.py"):
    15. for mod in collect_imports(file):
    16. if mod.startswith(root.name) and mod not in known_modules:
    17. problems.append(f"{file}: references unknown module {mod}")
    18. return problems

    This code only checks whether imports point to known modules, which is the most basic closure check. Real projects also need type checking and unit tests.

    5. Source-Code Analysis: From Reading to Understanding Intent

    Reading source code can be divided into three levels.

    The first level is syntax and structure: what a function does and how calls relate to each other. Most models perform consistently at this level.

    The second level is design decisions: why a particular abstraction was chosen and why some logic was placed in a middle layer. This requires the model to infer the trade-offs the author made among alternatives.

    The third level is evolution and boundaries: where the design will fail first when requirements change, and which constraints are implicit.

    To evaluate source-code analysis capability, design a set of questions that deepen level by level:

    1. What is the responsibility boundary of this module?
    2. If an abstraction layer were removed, which call sites would need to change?
    3. Under which input conditions would this design fail?

    If a model can answer only the first question, it remains at the reading level. Only when it can answer the second and third questions is it approaching an understanding of design intent.

    6. Calculate Cost as Total Cost

    Looking only at the per-call price can lead to one-sided conclusions. A more reasonable approach is to calculate total cost:

    Total cost = invocation cost + waiting time × time cost + manual review time × labor cost + rework count × per-rework cost

    A model with a low unit price may not have a lower total cost if it requires more manual correction. Conversely, a higher-priced model may be more economical overall if it succeeds on the first attempt. Teams should measure the proportion of each item based on their own task samples.

    7. Layered Selection Strategy

    Based on the evaluation dimensions above, an initial selection table can be formed:

    Task level Focus Suggested strategy
    Simple Response speed, per-call cost Prefer low-cost, fast models and sample-review results
    Medium Compliance with project conventions Provide examples and convention documents, compare two models, and choose the better result
    Complex Global consistency, intent understanding Choose models with stronger long-context processing and analysis capabilities, execute in steps, and enforce test runs
    Tight budget Overall cost-effectiveness Use low-cost models for simple tasks and higher-quality models for complex tasks

    This mixed-use approach is especially effective when the budget is limited. The key is to first determine which level a task belongs to and then decide which model to call, rather than looking for a single “strongest model” that fits every scenario.