How Repository-Level AI Coding Agents Work: A Technical Breakdown

    This article breaks down the technical architecture of repository-level AI coding agents, showing that the real capability leap comes from the runtime layer rather than the underlying model. It explains four core layers—the main loop, permission boundaries, subagent-based context isolation, and the verification loop—along with practical guidance for evaluation and adoption.

    1. Key Takeaway: The Capability Leap Happens at Runtime, Not in the Model

    When discussing repository-level AI coding agents, the most common misconception is attributing their effectiveness entirely to the underlying model being “better at writing code.” A more accurate explanation is that model capability is only a necessary condition. What actually changes the engineering experience is the runtime layer wrapped around the model. This layer determines what the model can see, what it can modify, when it must stop, and how it proves its work is correct afterward.

    This runtime can be abstracted into a four-layer structure:

    1. Main loop: how a task is continuously driven forward;
    2. Permission boundaries: which actions are allowed and which require human confirmation;
    3. Context separation: how to prevent information from accumulating into noise;
    4. Verification loop: how to move from “generation” to “deliverable.”

    Industry surveys generally show that the adoption rate of such tools among developers climbed to the top ranks within a year of release, indicating that they benefit from the engineering workflow rather than short-term novelty. The following sections expand on each layer.

    2. Layer 1: The Main Loop Is “Read–Plan–Call–Write Back,” Not One-Shot Completion

    The interaction model of traditional intelligent completion is “one request, one response,” typically scoped to the current file or the area near the cursor. The interaction model of a repository-level agent is a continuously running loop:

    1. Read context → Form a plan → Call tools → Observe results → Write back/correct → Continue to the next step

    This loop brings three fundamental differences:

    • The scope rises from “file” to “repository.” Questions in a task description such as “the callers of this interface” or “which modules reference this configuration” require cross-file retrieval to answer.
    • The output changes from “code snippets” to “a set of changes.” This includes creating new files, modifying multiple implementations, adding tests, and updating configurations.
    • The process changes from “one-shot” to “intervenable.” A human can correct course at any point during the loop instead of only being able to re-ask the question.

    For this reason, users often feel on first contact that it is “not like an editor plugin,” but more like an engineering assistant in the terminal. The engineering implication is clear: when evaluating such tools, you cannot look only at single-turn generation quality; you must also examine whether the loop has stable termination conditions and observable intermediate states.

    3. Layer 2: Permission Modes Are a System Capability, Not a Prompt Constraint

    The real risk of AI coding is never “not knowing how to write,” but “writing recklessly, writing beyond authority, and writing without seeing the boundaries clearly.” Mature solutions therefore make permissions an independent system capability. Common modes can be arranged by “degree of granted authority” into several tiers:

    • Read-only/research mode: retrieval and reading are allowed, but writing modifications to disk is not;
    • Default mode: reading and writing files is possible, but confirmation is required before executing high-risk actions;
    • Auto-accept edits mode: file modifications are exempt from confirmation, while command execution still requires caution;
    • No-ask mode: reduces interruptions in controlled environments (such as disposable containers);
    • Fully open mode: used only inside an isolated sandbox.

    Two design ideas here are the most valuable. First, do not grant authority by default: each round first defines “what the agent can see, what it can modify, and which actions must stop and ask a human.” Second, make “planning” a separate permission tier. After entering plan mode, the agent only reads code and researches the approach without modifying any files, and executes only after the plan is confirmed.

    Plan mode essentially reduces the probability of “fixing A and breaking B”: it lets the model first collect evidence (call relationships, type definitions, configuration sources, existing tests) before taking action. In engineering, this constraint can be expressed as a hard rule:

    1. if action is in {delete, force push, production change, major dependency version upgrade}:
    2. human confirmation required
    3. else if action is in {write file, run tests, local build}:
    4. allowed to execute and keep a trace
    5. else:
    6. read-only

    Supporting audit capability is also required: write every tool call, its parameters, and its results into a logging service, and combine it with monitoring and alerting to form a traceable change chain.

    4. Layer 3: Subagents Solve Context Pollution

    The place where large models are most likely to break down when handling engineering tasks is stuffing “finding clues, understanding the repository, writing the implementation, running verification, and explaining reasons” all into the same context window. As rounds increase, the context fills up with repeated retrieval results, failed attempts, and outdated assumptions; the model’s attention is diluted and the error rate rises.

    The essence of the subagent mechanism is context isolation: different subagents have independent contexts, independent tool constraints, and independent permission tiers. A typical division of labor is as follows:

    • Exploration subagent: responsible for locating relevant files and call chains in the repository, returning only conclusions and key paths;
    • Planning subagent: produces an implementation plan and impact analysis based on the conclusions;
    • Verification subagent: responsible for running builds and tests, returning failure summaries;
    • Main session: retains only key decisions and final changes, without carrying raw noise.

    This division of labor can be expressed in pseudocode:

    1. findings = Explore(goal="Locate where the authentication middleware is registered", scope="read-only")
    2. plan = Plan(findings, constraints=["Do not modify public interface signatures"])
    3. diff = Implement(plan)
    4. report = Verify(diff, commands=["build", "unit-test"])

    Its technical principle is not mysterious: break a large, messy task into multiple smaller tasks with cleaner contexts. This is also the core reason why such solutions are more stable than “single-session tools” in large repositories—stability comes from information architecture, not from stronger single-turn generation.

    5. Layer 4: The Verification Loop Determines Whether It Can Stop at “Deliverable”

    If the process stops at “generating code,” it is still just advanced completion. What truly pushes it toward an engineering system is the verification loop: after modifications are complete, automatically run the build, unit tests, and static checks, read the failure output, locate the specific file and line, modify again, and repeat until it passes or clearly reports a blocker.

    A practical minimal loop:

    1. 1. Generate changes
    2. 2. Run formatting and static checks
    3. 3. Run the build
    4. 4. Run relevant tests (prioritizing the affected scope)
    5. 5. On failure, parse the output → return to step 1 (with a maximum retry limit)
    6. 6. On pass, output a change summary, impact scope, and uncovered risks

    There are three key engineering details: first, retries must have a limit to avoid infinite looping; second, test selection must be trimmed by impact scope, otherwise feedback is too slow in large repositories; third, failure information must be returned in a structured way rather than stuffing the entire log back into the context—which returns to the isolation principle of Layer 3.

    6. Implementation Advice: How to Evaluate and Adopt

    • First validate understanding accuracy in read-only and research modes, then gradually grant authority;
    • Run high-authority tiers in a container platform or disposable development environment, using object storage to save artifacts and a logging service to keep traces;
    • Constrain output with the team’s existing standards, such as commit message format, directory conventions, and dependency version policies;
    • Focus on observability metrics: number of human confirmations, average feedback time, verification first-pass rate, and rollback rate;
    • Write permission policies and auditing into team rules rather than relying on users’ self-discipline.

    7. Summary

    The competitiveness of a repository-level AI coding agent lies not in prettier single-turn generation, but in the combination of four things: a sustainable main loop, making permissions a system capability, using subagents for context isolation, and closing with a verification loop. Understanding these four layers enables more rational decisions in selection, adoption, and governance, and makes it possible to build your own secure and controllable intelligent R&D workflow on top of the general capabilities of cloud platforms such as Baidu AI Cloud (container platform, logging service, monitoring and alerting, object storage).