Intelligent Coding Harness Architecture: Vertical Coupling vs. Horizontal Replaceability
This article examines the trade-off between vertically coupled and horizontally replaceable designs in intelligent coding harnesses, and argues for a third approach: making every layer a replaceable plugin. It explains why existing product ecosystems push teams toward shallow model swapping, then details a five-layer architecture covering model adapters, prompt packs, tool registries, session and memory, and the agent loop. Readers will find practical guidance on capability negotiation, side-effect classification, replayable logs, regression evaluation, and a phased adoption path starting from the tool registry.
1. The Problem: Two Routes and a Structural Gap
Two design orientations have long coexisted in the evolution of intelligent coding harnesses.
The first is vertical coupling: the model and the execution harness are tightly integrated and tuned together. The upside is a smooth end-to-end experience and stable responses in specific scenarios. The cost is a long upgrade chain: whenever the model is replaced, the prompts, tool-calling strategy, and context organization all have to be rebuilt.
The second is horizontal replaceability: the model is treated as a pluggable capability, the harness stays stable, and models connect through a unified protocol. The upside is freedom of choice and controllable cost. The difficulty is that models differ in instruction following, structured output, and long-context utilization, so “one prompt set for all models” degrades into a pile of conditional branches.
The real gap is that most solutions replace only the model layer while treating prompts, the tool registry, session logs, and the agent loop as internal implementation details of the framework. As a result, replaceability happens only at the surface. The moment you need to change the tool protocol, the memory strategy, or the evaluation criteria, you still have to modify the framework source code.
The third route proposes making all of these components replaceable plugins, so the harness returns to its core job of pure execution and orchestration. This article discusses the technical considerations of that architectural choice from a neutral perspective.
2. Why an Existing Ecosystem Distorts Product Design
A common observable pattern: organizations with a large existing business and an established user interface tend to embed new coding capabilities into the existing interaction shell (a sidebar, an editor panel) rather than build a command-driven workflow for engineers from scratch.
This is not a product judgment error but a rational choice under structural constraints:
- Legacy compatibility first: existing interfaces carry a large user base and established workflows, so any plan that “serves a niche of geeks first” is hard to approve internally.
- Short-term metrics: embedded entry points ship fast and reach a large visible base, so early data looks good and resources follow.
- Ecosystem lock-in tendency: the capability is required to bind deeply to the existing product matrix, cross-environment portability is weakened, and the outcome is a local optimum that “only works inside our own stack.”
The consequence is that model capability is placed in a supporting role, and the evolution of the harness is subordinated to compromises with the existing ecosystem. To escape this path dependency, the only technically reliable move is to make coupling points explicit and contract-based, reducing the cost of replacement from “modify the framework” to “swap a plugin.”
3. The Third Route: A Fully Plugin-Based Layered Architecture
Split the system into five layers, each exposed through a unified contract and independently replaceable and versionable.
Model Adapter
Responsibility: hide differences across models in interface shape, authentication, streaming protocol, and structured output capability.
Key points: unify the input/output schema; declare capability differences as metadata (tool calling support, parallel tool calling, context window limit, image input support) so upper layers negotiate capabilities instead of hardcoding branches.Prompt Pack
Responsibility: turn role definitions, coding conventions, output format constraints, and safety boundaries into versionable resource packages.
Key points: decouple prompts from code; support loading different packs by repository, language, or team; establish prompt regression evaluation to avoid “change one sentence, degrade everything.”Tool Registry
Responsibility: declare each tool’s name, input/output schema, permission scope, idempotency, and side-effect level.
Key points: the tool description is the contract; force write operations to declare a side-effect level and require explicit confirmation; support dynamically trimming the available tool set by environment (local, container, remote sandbox).Session & Memory
Responsibility: record multi-turn interactions, tool call traces, patches, and verification results to form a replayable execution trace.
Key points: structured, redactable, prunable logs; separate “short-term context” from “long-term project memory,” where the latter must carry provenance and freshness to avoid stale conclusions polluting decisions.Agent Loop
Responsibility: orchestrate the iterative process of “read context → plan → call tools → verify → converge.”
Key points: make termination conditions, retry policy, and budget limits (steps/time/calls) configurable; make the loop itself replaceable to fit different task shapes (one-shot generation vs. long-chain repair).
Illustrative plugin manifest (neutral pseudocode, expressing contract shape only):
# Plugin manifest example: every layer is a replaceable unitadapter:name: "generic-llm-adapter"capabilities: { tool_call: true, parallel_tool_call: false, vision: false }endpoint_ref: "secret://model-endpoint" # the actual address is injected by the deployment environmentprompt_pack:name: "repo-conventions-v3"applies_to: { languages: ["python", "go"] }precedence: ["repo", "team", "global"]tool_registry:tools:- name: read_fileside_effect: noneschema_ref: "schemas/read_file.json"- name: apply_patchside_effect: writerequires_confirmation: trueidempotent: falseloop:max_steps: 40budget_tokens: 400000stop_on: ["tests_passed", "budget_exceeded"]
4. Key Details of Contract Design
Capability negotiation over branch checks. Instead of writing if model == X in code, let the adapter report capability metadata and let the execution layer decide whether to call tools in parallel or degrade to single-turn generation. Adding a model then means adding one adapter plugin.
Side-effect classification is the safety foundation. Use at least three levels: none (read-only), write (reversible local modification), and irreversible (commits, releases, deleting remote resources). The third level must require explicit confirmation and leave a trace, and must integrate with the permission system following the least-privilege principle.
Replayability determines operability. Session logs should fully replay a task: the input context snapshot, the tool call sequence, and each step’s output and verification result. When quality regresses, you can pinpoint whether a prompt change, a model change, or a tool description change caused it, instead of guessing.
Evaluation and regression are not optional. Maintain three benchmarks: code generation correctness (unit test pass rate), instruction following (format and constraint satisfaction rate), and safety (interception rate of privilege escalation and dangerous operations). Run them on every plugin replacement to form an engineering loop that is “replaceable without losing control.”
5. Engineering Adoption: Start with a Minimal Viable Plugin Set
You do not need to refactor all five layers at once. Recommended order:
- Extract the tool registry first: fastest payoff, immediately unifies permission and audit semantics.
- Then extract the model adapter: enables multi-model canary rollout and cost optimization, avoiding single-vendor risk.
- Next extract the prompt pack: lets conventions evolve with the repository and establishes regression evaluation.
- Finally extract the agent loop: after the first three layers are stable, differentiate orchestration by task shape.
On the infrastructure side, generic cloud capabilities can host these replaceable units: object storage for prompt packs and evaluation baselines, a container platform for sandboxed tool execution environments, logging and monitoring/alerting services to track call chains and budget consumption, and a message queue to decouple asynchronous execution of long-chain tasks. All are described in generic category terms to avoid binding to a specific implementation.
6. Common Pitfalls
- Treating “multi-model support” as the whole of horizontal replaceability: swapping only the model while leaving tools and prompts fixed keeps replaceability superficial.
- Equating plugin-based with fragmentation: without unified contracts and a versioning strategy, growing plugin counts cause combinatorial explosion, so a registry and compatibility checks are mandatory.
- Ignoring convergence and budget: a long-chain loop without step and call limits will lose control of cost and latency.
- Ungoverned memory: long-term memory without provenance and freshness annotations leads to wrong conclusions being cited repeatedly.
7. Conclusion
Vertical coupling and horizontal replaceability are not either/or. The real engineering answer is to make every coupling point contract-based: model adapter, prompts, tool registry, session logs, and agent loop are all replaceable, while the harness only handles orchestration and constraints. This preserves the end-to-end experience, keeps the system evolvable in an environment of rapid model iteration, and holds the safety and quality line through side-effect classification, replayable logs, and regression evaluation. Teams that want to build intelligent coding capabilities in their own cloud environment can assemble the layers above on generic capabilities such as object storage, container platforms, logging, and monitoring/alerting; Baidu AI Cloud can be evaluated as one of the hosting foundations in these generic infrastructure categories.
