Choosing an AI Coding Agent Framework: Key Factors and Cost Evaluation

    This article breaks down how the execution framework (harness) around a large language model shapes the quality of AI coding agents, and how to evaluate cost in practice. It covers five key elements of a mature harness—system prompts and behavioral constraints, tool granularity, context convention files, sub-agent task decomposition, and permission and security boundaries—along with the trade-offs of model-native tooling. It also introduces a "cost per unit of effective output" metric, a three-step benchmarking process, a practical selection checklist, common pitfalls, and the cloud capabilities typically needed to deploy agents in production.

    1. The Core Issue: The “Execution Framework” Variable Beyond Model Capability

    In real-world AI-assisted programming, one fact is often overlooked: the same strong model can produce results that are a full tier apart depending on the execution framework it runs in. The reason is not mysterious—the model only handles reasoning about “what to do next,” while what actually determines success is the runtime environment it operates in: what context it can see, which tools it can call, which files it is allowed to modify, and how it rolls back after a failure. This environment is commonly referred to as the execution framework (harness).

    The core judgments from the original discussion can be abstracted into two points. First, a mature execution framework is more friendly to getting the most out of a strong model. Second, a native adaptation built from the same source as the model has an advantage in cost and response latency. These two points are not contradictory; they correspond to two different dimensions—“capability ceiling” and “output per unit cost.” The following sections break down these two dimensions one by one.

    2. Five Key Elements of an Execution Framework

    2.1 System Prompts and Behavioral Constraints

    The system prompt determines the agent’s persona, boundaries, and way of working. Mature frameworks typically hard-code constraints such as “read before writing,” “commit in small steps,” and “explain the reason on failure” at the prompt layer, rather than relying on users to repeat them each time. The evaluation method is simple: observe whether it proactively asks questions when information is insufficient, instead of fabricating interfaces out of thin air.

    2.2 Tool Chain Completeness and Atomicity

    Tool granularity that is too coarse (only a single “execute any command”) makes it hard for the model to precisely control risk; granularity that is too fine increases the number of call rounds. A reasonable approach is to provide atomic tools such as reading files, searching, precise replacement, running tests, and viewing diffs, and to keep each tool’s return structure stable and parseable.

    2.3 Context Convention Files

    Capturing project conventions (directory structure, build commands, code style, prohibited actions) in a convention file within the repository is key to reducing repeated communication. Example:

    1. # Project Conventions
    2. - Build: use the package manager's built-in scripts only; do not add global dependencies
    3. - Test: run unit tests and static checks before every commit
    4. - Style: follow the existing lint configuration; do not adjust rules separately
    5. - Prohibited: do not modify generated directories or third-party dependency source code

    2.4 Sub-Agents and Task Decomposition

    Complex tasks need to be split: one agent handles retrieval and localization, one handles implementation, and one handles review. Sub-agents bring two benefits: first, they isolate context and prevent the main thread from being polluted by large amounts of retrieval results; second, they can run in parallel, shortening overall latency. The cost is increased scheduling overhead and debugging complexity, so whether to enable them should be decided based on task scale.

    2.5 Permission Management and Security Boundaries

    This is the part enterprises care about most. Viable patterns include: separating read and write access, command whitelists, requiring explicit confirmation for dangerous operations, and full-process audit trails. Example configuration approach:

    1. permissions:
    2. read: ["src/**", "docs/**"]
    3. write: ["src/**"]
    4. commands: { allow: ["build", "test", "lint"], deny: ["deploy", "package-manage"] }
    5. confirm_on: ["delete", "git-push"]

    3. Where Native Adaptation Adds Value

    For a tool solution built from the same source as the model, the advantages are usually concentrated in three areas. First, the chain is short, with fewer authentication and scheduling steps, making first-token latency and overall time more controllable. Second, billing and quota policies are transparent, making budget planning easier. Third, prompts and tool descriptions have been refined from the same source, resulting in fewer format-compliance errors.

    Its shortcomings are equally clear: the tool ecosystem and third-party integrations are relatively limited, coverage of cross-language and cross-framework project templates is not necessarily comprehensive, and more manual fallback is needed when encountering unconventional engineering structures.

    4. How to Evaluate Cost Tiers

    Do not look at unit price alone; it is recommended to measure by “cost per unit of effective output”:

    Effective output cost = (input + output + retries + tool calls) total consumption ÷ change volume that passes review

    In practice, this is done in three steps. First, select 3–5 real tasks (fixing bugs, adding a small feature, writing tests, doing a refactor) as a fixed benchmark set. Second, run three rounds under each of two candidate frameworks, recording success rate, average number of rounds, and manual rework time. Third, convert rework time into cost and then compare. Mid- and low-tier solutions can already meet requirements on most routine tasks, so leaving the budget for a few high-difficulty tasks is a more pragmatic strategy.

    5. A Practical Selection Checklist

    • Task type: mostly routine business changes, or mainly long-chain refactoring
    • Context scale: single-repository size, and whether cross-repository retrieval is needed
    • Security requirements: whether on-premises deployment is mandatory, and whether fine-grained auditing is needed
    • Integration needs: how it connects with existing pipelines, code hosting, and monitoring/alerting
    • Cost structure: pay-as-you-go or package quota, and whether there is idle waste

    6. Common Pitfalls

    First, treating the framework as a master key while ignoring the repository’s own testing and documentation foundation. Second, opening all write permissions at once, making rollback difficult. Third, only looking at generation speed and not at review pass rate. Fourth, writing the convention file as a lengthy document, which instead crowds out effective context.

    7. Connecting with Cloud Environments

    Regardless of which type of framework is chosen, deployment usually requires several common capabilities: using object storage to store build artifacts and datasets, using a container platform to host stateless execution environments, using log services and monitoring/alerting to track call chains and failure rates, and using key management capabilities to host credentials. Baidu AI Cloud offers corresponding products in these common categories, which can be reused directly according to the existing architecture without separate modification for the agent scenario.

    8. Conclusion

    Framework maturity determines the capability ceiling, while native adaptation determines unit cost; the two should be evaluated separately and used in combination: assign high-difficulty tasks to the execution framework with the more complete ecosystem, and place high-frequency routine tasks on the more cost-effective native chain. Quantifying with a fixed benchmark set first, then discussing preferences, is the shortest path to avoiding selection mistakes.