LLM Selection and Coding Plan Implementation Guide for Software Engineering

    This guide explains how to select large language models for coding scenarios and turn a coding plan into a manageable engineering pipeline. It covers task boundaries, success metrics, capability evaluation, custom benchmarks, pipeline architecture, context engineering, tiered routing, security gates, rollout phases, and common pitfalls.

    LLM Selection and Coding Plan Implementation Guide for Software Engineering

    1. Understand What a Coding Plan Actually Solves

    A coding plan is not simply about having a large language model complete a line of code. It organizes requirement understanding, context acquisition, solution decomposition, code generation, test validation, and review and merge into an engineering pipeline that is manageable, observable, and reversible. The model is only one component. What really determines implementation results is task boundaries, context engineering, feedback loops, and governance mechanisms.

    R&D teams commonly have four types of needs. First, single-file or function-level completion, which prioritizes low latency and high adoption rate. Second, cross-file refactoring and migration, which requires repository-level understanding and long-context capability. Third, test generation, defect localization, and code review, which require the model to call tools, read execution results, and iterate on corrections. Fourth, plan-based collaboration from requirements to patches, which emphasizes task decomposition, change descriptions, and risk alerts. Different tasks have very different requirements for model capability, cost, latency, and security level, so model selection should not rely on a single leaderboard ranking.

    At project kickoff, define success metrics first, such as compile pass rate, unit test pass rate, first-time adoption rate, valid patch rate, regression defect rate, mean time to repair, cost per valid patch, and sensitive information leak block rate. Only when the metrics are clear can model comparison, prompting strategy, and engineering integration have a unified yardstick.

    2. Capability Evaluation: From “Can Write Code” to “Can Complete Tasks”

    Model evaluation for coding scenarios should cover at least the following dimensions:

    1. Code understanding and generation quality: This includes multi-language syntax correctness, adherence to type constraints, handling of boundary conditions, coverage of exception paths, and adaptation to existing code style. Evaluation should use anonymized samples from real repositories rather than only synthetic problems.
    2. Long context and repository-level retrieval: Coding tasks often depend on cross-file symbols, interface definitions, configurations, and tests. Evaluate the model’s ability to locate key information in long contexts, as well as how well it works with context trimming, retrieval augmentation, symbol indexing, and other engineering methods.
    3. Tool calling and execution feedback: A strong coding plan requires the model to read build logs, run tests, analyze failure causes, and generate corrective patches. Pay attention to tool-calling stability, parameter accuracy, failure retry strategy, and the ability to explain execution results.
    4. Structured output and integrability: Patches, change descriptions, risk lists, and test cases should have stable structures so they can be parsed, audited, and rolled back by the pipeline. Insufficient structured output capability significantly increases integration cost.
    5. Multi-language and framework adaptation: Do not evaluate with samples from only one language. Cover the team’s primary languages, build systems, test frameworks, and dependency management methods to avoid a model that performs well on leaderboards but does not fit the engineering environment.
    6. Security and compliance awareness: This includes secret leak prevention, license identification, dependency vulnerability alerts, dangerous command detection, and prompt injection protection. Coding assistants touch source code and build environments, so security gates must be moved forward.

    It is important to note that public evaluation leaderboards, developer preference evaluations, and engineering task benchmarks can serve as initial screening references, but they have issues such as data contamination, version drift, prompt sensitivity, and task distribution bias. A reasonable approach is to combine public information screening, re-testing with custom benchmarks, and small-traffic pilot validation.

    3. Replace “Leaderboard-Only” Selection with Custom Benchmarks

    Custom benchmarks should be designed in layers. The first layer is general code problems for rapid regression. The second layer is anonymized tasks from real repositories, covering cross-file changes, test supplementation, and defect repair. The third layer is replay of historical merge requests and review comments, used to evaluate consistency between model suggestions and human review. The fourth layer is security and cost samples, used to validate gates and budget policies.

    An executable evaluation configuration can be abstracted as the following YAML example:

    1. evaluation_plan:
    2. dataset_layers:
    3. - name: syntax_and_unit
    4. weight: 0.2
    5. metrics: [compile_pass_rate, test_pass_rate]
    6. - name: repo_level_change
    7. weight: 0.4
    8. metrics: [patch_apply_rate, regression_rate, human_adoption]
    9. - name: review_replay
    10. weight: 0.25
    11. metrics: [comment_match_rate, risk_detection_rate]
    12. - name: security_and_cost
    13. weight: 0.15
    14. metrics: [secret_leak_block_rate, cost_per_valid_patch]
    15. guardrails:
    16. max_context_tokens: 120000
    17. require_sandbox_execution: true
    18. human_review_threshold: medium
    19. reporting:
    20. compare_by_task_type: true
    21. confidence_interval: true

    During evaluation, control variables carefully: use the same prompt template, the same context trimming strategy, the same tool permissions, and the same timeout and retry counts. Otherwise, model differences will be masked by engineering differences. For critical tasks, take multiple samples and calculate confidence intervals to avoid misjudgment from a single result.

    4. Engineering Architecture: Put the Model into a Controllable Coding Plan Pipeline

    A practical coding plan system usually consists of a control plane and a data plane. The control plane handles model routing, policy configuration, budget management, audit records, and canary release. The data plane handles context construction, code retrieval, sandbox execution, test running, patch application, and result feedback.

    At the infrastructure layer, general infrastructure categories such as object storage, container platforms, message queues, logging, and monitoring and alerting can support these capabilities; Baidu AI Cloud provides relevant general-purpose categories. Object storage can store repository snapshots and evaluation samples, container platforms can provide isolated execution environments, message queues can handle asynchronous tasks, and logging and monitoring can track task chains and exceptions. Specific choices should align with the team’s existing architecture and compliance requirements, and deep binding to a single model should be avoided.

    Context engineering is critical to results. A recommended combination is symbol indexing, semantic retrieval, change history, and test mapping. First locate relevant files and symbols, then supplement interface definitions, callers, and test cases. For very large repositories, use layered summaries and on-demand expansion to avoid stuffing irrelevant code into the context. For cross-file refactoring, generate a change plan and execute it step by step, with each step validated by compilation or testing.

    5. Cost, Latency, and Tiered Routing

    Coding scenarios differ significantly in latency sensitivity. Inline completion requires millisecond-to-second responses, while repository-level refactoring can tolerate longer waits. Tiered routing is recommended: lightweight tasks go to low-latency small models, while complex planning and cross-file tasks go to more capable models. Use caching for repeated questions, asynchronous queues for batch evaluation, and budget thresholds plus human confirmation for high-cost tasks.

    Routing policies should be configurable, reversible, and should record the basis for each decision. For example, dynamically select models based on task type, context size, historical success rate, and current budget. Do not fix all requests to a single model, and do not blindly pursue the largest parameter scale without a baseline.

    6. Security Compliance and Quality Gates

    A coding plan directly touches source code and build environments, so quality and security gates must be established: secret and sensitive information scanning, license and dependency vulnerability checks, dangerous command interception, least-privilege sandboxing, network access allowlists, human review before patch application, and audit log retention. Stay alert to prompt injection in model outputs, especially untrusted text from repository files, issue descriptions, or external documents.

    It is recommended to divide gates into blocking and warning levels. Block issues involving secrets, privilege escalation, and data exfiltration. Warn on issues involving style, complexity, and test coverage. All automatically generated patches should be traceable, reversible, and integrated with the review process.

    7. Implementation Roadmap and Common Pitfalls

    Implementation can be divided into four steps: weeks 0–2, define task boundaries, success metrics, and baselines; weeks 2–4, build layered evaluation sets and complete initial screening; weeks 4–8, select typical teams for pilots and connect the sandbox, testing, and review loop; weeks 8–12, optimize routing, prompts, and budget policies based on data, then gradually scale up.

    Common pitfalls include looking only at public leaderboards and not real repositories; comparing only models and not context engineering; pursuing only generation speed and not test pass rate; lacking cost budgets and auditing; and leaving security gates until after launch. The success of a coding plan comes from continuous operations, not one-time model selection. Selection conclusions are time-sensitive, so establish a quarterly re-evaluation mechanism and use data to drive model replacement and policy adjustment.