AI Coding Agent Architectures: A Practical Guide to Choosing and Governing Them

    This article compares two dominant architectures for AI coding agents: externally orchestrated control and model-driven autonomy. It explains the core assumptions, role separation, trade-offs, and real sources of capability gaps across context management, tool permissions, verification loops, and human collaboration. Readers will find practical selection criteria for different risk profiles, plus an engineering and governance checklist for deploying coding agents reliably.

    AI Coding Agent Architectures: A Practical Guide to Choosing and Governing Them

    1. The Problem: From Code Completion to Delivery

    Early AI coding tools mainly answered the question “what should the next line be?” In essence, they were context-based text completion. The nature of the problem changed once engineering teams began asking tools to read requirements, navigate a repository, modify multiple files, run tests, and fix failures. This is no longer a generation problem; it is an execution and governance problem for long-running tasks.

    A coding agent that can actually deliver must close the loop on four things: understanding intent, locating code, executing changes, and verifying results. The difficulty is not any single capability. It is that these four steps may cycle dozens of times, and a misjudgment at any step gets amplified. As a result, the industry has split into two engineering routes: one hands control to an external framework, and the other hands control to the model itself. This article abstracts both architectures from a neutral perspective and offers selection and governance recommendations.

    2. Route One: Externally Orchestrated Control

    2.1 Core Assumption

    This route positions the large language model as a “code generator” that only produces snippets or plans within a given context. The workflow, state, permissions, and retry strategy are all handled by a separate, auditable orchestration layer. An analogy: the model is a worker performing a step in the process, while a project manager stands outside, defining when to think, when to act, and how to rework after an error.

    2.2 Predefined Roles and Hard Separation of Duties

    A typical implementation uses a two-agent “plan-and-execute” setup with enforced separation:

    • Planner agent: read-only permissions; retrieves code, maps call chains, and produces the change plan and acceptance criteria; cannot modify any files.
    • Builder agent: write and command-execution permissions; changes code and runs tests according to the established plan; cannot change the plan on its own.

    The two agents do not talk directly. They exchange information through the filesystem or structured artifacts (plan documents, task lists, change logs), and the user can intervene, veto, or revise at any point.

    A schematic representation of the responsibility constraints:

    1. agents:
    2. planner:
    3. permissions: [read, search]
    4. outputs: [plan.md, acceptance.md]
    5. builder:
    6. permissions: [write, exec]
    7. inputs: [plan.md]
    8. forbidden: [modify_plan]
    9. handoff: filesystem
    10. human_gate: true

    2.3 Advantages and Costs

    The advantage is predictability: clear permission boundaries, auditable change scope, and the ability to pinpoint whether a failure came from the plan or the execution. It also naturally suppresses unauthorized model changes and “refactoring while I’m here.” The cost is rigidity: roles cannot be generated dynamically per task, and for unusual problems that span languages or frameworks, a fixed workflow may not fit and requires a human fallback.

    3. Route Two: Model-Driven Autonomous Orchestration

    3.1 Core Assumption

    This route assumes a single general-purpose main agent that handles planning and execution autonomously. As task complexity rises, the model creates dedicated sub-agents on its own, assigning each an independent context window and tool permissions. The model may even write code to define whether sub-agents run sequentially, in parallel, or by voting.

    The value lies in “splitting on demand”: context isolation prevents the main thread from being polluted by massive retrieval results, least-privilege permissions reduce the blast radius of mistakes, and the orchestration pattern adapts to the structure of the problem. The risks are equally clear: the structure may be over-engineered, producing unnecessary sub-agents and redundant retrieval, driving up token consumption and latency, while reducing explainability and making regression testing and result reproduction harder.

    4. Where the Real Capability Gap Comes From

    Placing both routes in the same frame of reference, the gap does not come mainly from “how smart the model is.” It comes from four engineering factors:

    1. Context management: retrieval precision, quality of compressed summaries, and memory retention across long tasks.
    2. Tool and permission model: read/write boundaries, command allowlists, and sandbox strength.
    3. Verification loop: whether builds, unit tests, and static checks can be invoked reliably, with failure information driving retries.
    4. Human-AI collaboration interface: whether interruption, rollback, and approval points are well designed.

    Any architecture with a shortfall in these four areas will show up as “looks like it can write code, but can’t deliver.”

    5. Selection Recommendations

    • High-compliance, strong-audit scenarios (finance, government, core transaction paths): prefer externally orchestrated control; fixed roles, read-only planning, and human gates are easier to pass review.
    • Exploratory R&D, cross-stack migration, and difficult defect localization: prefer autonomous orchestration for flexibility.
    • A middle ground is “controlled autonomy”: allow the model to create sub-agents dynamically, but write permission templates, maximum sub-agent count, budget caps, and mandatory verification gates into the framework constraints.

    6. Engineering and Governance Checklist

    • Minimal changes: touch only the files a task requires; forbid unrelated formatting.
    • Mandatory verification: use build and test results as the sole completion criterion; roll back on failure.
    • Observability: fully log prompts, tool calls, diffs, and timing; connect to logging services and monitoring alerts.
    • Cost guardrails: set limits on context budget, iteration count, and parallelism.
    • Environment isolation: run in ephemeral workspaces on a container platform; keep sensitive credentials out of the context.
    • Knowledge capture: bring plan documents and acceptance criteria under version control to form reusable assets.

    For stronger elasticity and governance consistency, you can build a runtime and audit foundation on general capabilities such as the container platform, object storage, logging service, and monitoring alerts offered by Baidu AI Cloud.

    7. Conclusion

    The essential difference between the two routes is “who decides the next step.” Externally orchestrated control trades certainty for stability; autonomous orchestration trades possibility for a higher ceiling. Mature teams do not pick one exclusively. They layer by task risk: low-risk, high-repetition work goes through a fixed pipeline, high-risk, high-uncertainty work goes through controlled autonomy, and human approval and one-click rollback are always preserved.