How to Choose an AI Coding Agent: Aligning Models and Frameworks

    Choosing an AI coding agent comes down to one question: can the model and its runtime framework work well together? The same model can perform very differently across different agent frameworks. This article, written for engineering leads and architects, explains what each of the two layers is responsible for and provides a checklist you can use directly in your evaluation.

    How to Choose an AI Coding Agent: Aligning Models and Frameworks

    How should you choose an AI coding agent? The answer depends on whether the model and the runtime framework work well together. The same model plugged into different frameworks can produce very different results. This article, aimed at engineering leads and architects, explains what each of the two layers is responsible for and provides a checklist you can use directly in your evaluation.

    1. First, Separate the Roles of the Model and the Framework

    Many discussions conflate “model” and “agent,” so the two need to be distinguished first.

    The large language model is responsible for understanding intent, reasoning, and deciding the next action. The agent framework (agent harness) is responsible for carrying those actions out: reading files, executing commands, calling external tools, maintaining the conversation and context, enforcing permissions, and feeding results back to the model. A typical loop looks like this:

    1. while task not complete:
    2. context = assemble(system instructions, tool definitions, project docs, history)
    3. action = model.decide(context)
    4. if action requires confirmation:
    5. request user confirmation
    6. result = framework.execute(action)
    7. history.append(action, result)

    Differences mainly come from three sources: whether the tool protocol is well designed, how context is organized, and whether the model has been sufficiently trained on similar interaction formats. Evaluation therefore needs to cover both layers. Testing only the model, or only looking at the framework’s feature list, makes it hard to predict real-world performance.

    2. Tool Calls and Patch Editing

    2.1 Tool-Calling Protocols

    The framework should provide a clear schema for each tool, including its name, a description of its purpose, parameter types, required fields, and the return value format and error codes. The clearer the protocol, the less likely the model is to produce missing parameters or misinterpret return values.

    If a model has rarely seen a particular calling format during training, it will repeatedly raise parameter errors or omit required fields even if the framework is well designed. Troubleshoot in this order:

    1. Open the framework logs and find the raw call output by the model, not the parsed result.
    2. Check required fields, types, and enum values one by one against the tool schema.
    3. Determine whether the problem comes from the tool definition (vague descriptions, too many fields) or from the model output (format deviation).
    4. If it is a tool definition issue, fix the schema and retest. If it is a model issue, reduce the number of available tools, or switch to a model more familiar with that format, then retest.

    2.2 Prefer Incremental Patches Over Full-File Rewrites

    Full-file rewrites easily lose unrelated changes, increase review cost, and can introduce subtle errors. Mature agents tend to generate unified diffs that modify only the lines that need to change.

    Example:

    1. --- a/service/order.py
    2. +++ b/service/order.py
    3. @@ -42,7 +42,7 @@
    4. - if total > 0:
    5. + if total >= 0:

    This change looks minor but alters boundary behavior: when total equals 0, the original code does not enter this branch, while the modified code does. Changes with this kind of business meaning should be confirmed by a human.

    Patches can also fail, for three common reasons: the context lines no longer match the file’s current content, the file was modified by someone after the agent read it, or the patch matches multiple similar code segments. The framework should return the failed file name, line number, and expected content. The table below shows how to handle each type of failure.

    Failure cause Fields the framework should return Agent’s next action
    Context mismatch File name, line number, expected content, actual content Re-read the file and regenerate the patch based on the latest content
    File modified externally File modification time, current hash Re-read and confirm whether the original change still applies
    Multiple similar code matches Match count, candidate line numbers Expand context lines so the patch can be uniquely located

    After two consecutive failed applications, the agent should stop and ask for human intervention instead of retrying indefinitely.

    Rollback also needs to be prepared in advance. Before starting a task, commit the current state on a separate branch. To roll back, switch back to the original branch or run git revert. Do not rely on git reset --hard, which discards uncommitted changes.

    2.3 Restraint in Terminal Operations

    The command line is a high-risk entry point. A good agent reads before it writes: it inspects the directory structure, reads configuration and logs, and only then decides which command to run.

    The framework should express these rules as configuration rather than relying on the model’s self-discipline:

    1. command_policy:
    2. mode: parsed_argv_match
    3. read_only: [ls, cat, grep, "git status", "git diff", "git log"]
    4. confirm: [rm, mv, "git push", "git commit", curl, "pip install"]
    5. deny: [sudo, "chmod -R", dd, mkfs]
    6. confirm_timeout_seconds: 120
    7. on_confirm_timeout: deny
    8. workspace:
    9. root: /home/agent/projects/order-service
    10. allow_outside_root: false
    11. network:
    12. default: deny
    13. allow_domains: [pypi.org, files.pythonhosted.org]
    14. logging:
    15. store_raw_calls: true
    16. raw_calls_path: /var/log/agent/calls.log
    17. redact_patterns:
    18. - "(?i)(api[_-]?key|token|secret|password)\\s*[=:]\\s*\\S+"
    19. file_mode: "0600"

    Three points in this configuration deserve attention. First, the policy should match against parsed command arguments rather than string prefixes, otherwise command variants can slip through. Second, the deny list is a blacklist: it can only block known dangerous operations and cannot replace a sandbox. Third, keys and tokens in logs must be redacted before writing, and access to log files should be restricted.

    The baseline security requirements are as follows. The agent should run under a dedicated low-privilege account, its working directory should be limited to the project root, the network should be off by default with only whitelisted domains open. Do not place production credentials in any directory, environment variable, or configuration file the agent can read. During evaluation, use only test data and test accounts.

    3. Context Management and Caching Costs

    3.1 Context Assembly Order

    The framework assembles context on every turn. The recommended order is: system instructions, tool definitions, project documentation, history summary, and the most recent raw records. Stable content goes first and fast-changing content goes last, so that caching can be leveraged.

    Project documentation should be layered: global conventions, repository-level notes, and directory-level notes. The model should load only the directory notes relevant to the current task, rather than stuffing in all documentation at once.

    3.2 Trimming and Truncation

    Tool outputs are often long, such as test logs or large diffs. The framework can keep the beginning and end of the output, write the full content to a file, and return only the file path and a summary in the context. Older history should be compressed into a summary that retains completed steps, confirmed decisions, and open issues.

    3.3 How to Account for Caching Costs

    Caching falls into two categories: prompt prefix caching and tool result caching. The former requires the prefix content to be exactly identical, so any change to tool definitions or project documentation invalidates the cache. The latter is only appropriate for the results of read-only tools; the results of write operations should not be cached.

    When evaluating cost, do not look only at the price per call. Track the total spend per completed task, and compute the cache hit rate: the number of cached input tokens divided by the total number of input tokens.