Technical Architecture and Engineering Practices of Coding Agents
This article breaks down the technical architecture and engineering practices behind coding agents. It explains why an agent is not just smarter autocomplete, introduces a layered reference architecture, and shows how context engineering, tool permissions, task orchestration, and process data determine real-world performance. Readers will find practical guidance on evaluation, implementation, and adoption.
1. From Code Completion to Agentic Coding: Clarifying the Concept
A coding agent is not simply “smarter autocomplete.” Traditional completion operates on a single interaction unit: predicting the next token at the cursor. An agent operates on a goal: given a one-sentence requirement, it must break down the steps, search the repository, read and write files, execute commands, observe results, and decide whether to retry. This difference shifts the technical focus from “model quality” to “orchestration capability at the application layer.”
The industry commonly refers to this application-layer wrapper as an agentic harness. It consists of four parts: a context assembler, a tool and permission layer, a loop controller, and state and memory storage. The model only chooses the probability-optimal next action at each step, while the harness turns actions into real side effects and feeds those side effects back as new context. Understanding this is the first principle for evaluating any coding agent solution: the capability ceiling is determined by the model, but actual performance is determined by the harness.
2. Layered Architecture: A Practical Reference Structure
┌─────────────────────────────────────────┐│ Interaction: IDE plugin / CLI / chat & ticket entry │├─────────────────────────────────────────┤│ Orchestration: task planning, loop control, retry & rollback │├─────────────────────────────────────────┤│ Capability: retrieval, editing, execution, testing, review │├─────────────────────────────────────────┤│ Context: repo index, session memory, long-term knowledge │├─────────────────────────────────────────┤│ Model: general-purpose LLM + code-specialized model │└─────────────────────────────────────────┘
The key constraint of layering is one-way dependency: upper layers may call lower layers, but lower layers must not be aware of upper layers. This keeps model swaps, tool swaps, and entry-point swaps isolated from one another, and provides the engineering basis for the “decoupling of model and harness” discussed later.
3. Context Engineering: The Real Bottleneck
In real repositories, the token budget is always insufficient. A practical approach is layered supply:
- Static layer: directory structure, build configuration, dependency manifests, and coding conventions, compressed and kept resident.
- Retrieval layer: hybrid recall of relevant file fragments based on symbol indexing and vector retrieval, rather than stuffing in whole files.
- Dynamic layer: current errors, recent changes, and failing test output, with the highest priority.
- Compression layer: summarize historical steps, retain decisions and constraints, and discard verbose logs.
It is important to note that more context is not always better. Noise dilutes attention and causes the model to “see but not use” information. A common engineering practice is to set a quota for each type of information and evict by priority when the limit is exceeded.
4. Tool Invocation and Permission Boundaries
An agent’s capabilities come from tools, and so do its risks. A robust toolset typically includes file reading, precise editing, command execution, test running, static checks, and version control operations. There are three design points:
- Least privilege: read-only by default; write operations and network access require explicit authorization.
- Rollback capability: all changes land in a disposable work branch or sandbox and are destroyed on failure.
- Observability: log the input arguments, duration, and exit code of each tool call for traceability and cost accounting.
An illustrative tool description structure:
{"name": "run_tests","description": "Run the specified test target and return a failure summary","parameters": {"target": "string, required, test path or case name","timeout_seconds": "number, default 300"},"side_effect": "read_only","requires_approval": false}
5. Task Orchestration: From Single Session to Long Horizon
Single-session generation can only solve “write a function.” Long-horizon tasks require loop control: plan, execute, verify, and correct. Common patterns include “plan first, then execute,” “dual-role cross-checking between execution and review,” and “escalate to a human after three failures.” To prevent infinite loops, set limits on the number of steps, the budget, and repeated-action detection.
When a task spans multiple conversation turns and multiple collaboration entry points, multi-session context management and parallel scheduling become efficiency bottlenecks. A viable architectural approach is to persist the task object: each task has its own state machine and memory area, and the harness synchronizes progress across entry points, enabling the agent to follow up across sessions rather than starting from scratch each time.
6. Process Data: The Deeper Motivation for Building Your Own Agent
Public code repositories mainly provide “outcome data,” meaning what the final code looks like. “Process data” refers to how users describe intent, how the model goes wrong, how users correct it, and when they give up. This signal is scarce and valuable. It can be used for preference alignment and online policy optimization, allowing the model to learn “how to do it right step by step,” not just “write code that looks right.” Therefore, having your own coding agent entry point has direct significance for model iteration. Some solutions use real-time reinforcement learning for continuous iteration, in which case cost control and architectural efficiency become core engineering metrics.
7. Evolution of Form: From Software to the Physical World
As capabilities grow, the target of coding agents is expanding from pure code to physical devices: by observing the scene, generating control programs, receiving execution feedback, and adjusting actions, a closed loop is formed. Academia has also proposed the view of treating code as the executable, inspectable, and stateful core medium in agent systems—code is both a product and the construction material of the harness itself. This direction places higher demands on real-time performance, safety, and rollback capability.
8. Implementation Recommendations
When selecting or building in-house, enterprises are advised to proceed in the following order: first define task boundaries and acceptance criteria, then build retrieval and sandbox infrastructure, then integrate general cloud capabilities such as logging, monitoring, and alerting for observability, and only then discuss model selection. In such practices, Baidu AI Cloud is typically used to provide general foundational capabilities such as container platforms, object storage, and log monitoring. It is worth noting that while the industry’s early annualized market size has reached the tens-of-billions-of-dollars scale, what truly determines return on investment is still the two metrics of task success rate and cost per task, rather than model parameter size.
