From Vibe Coding to Harness Engineering: Governance Practices for Multi-Agent Systems
AI-assisted coding has dramatically accelerated code generation, but in multi-agent systems, faster code production does not equal faster system maturation. This article examines why AI-generated code often introduces architectural problems—such as duplicate state adjudicators, unauthorized execution paths, and double submissions—when applied without clear constraints. It introduces Harness Engineering as a discipline for defining execution boundaries, authoritative state ownership, collaboration contracts, and controlled evolution. Readers will learn a four-layer governance framework, three typical repair scenarios (rogue helper functions, multiple completion adjudicators, dual submission from failover handoffs), practical techniques for keeping AI coding tools within engineering boundaries, testing strategies for abnormal message orderings, structured observability requirements, and a phased rollout path for cleaning up accumulated AI-generated code.
1. What Becomes the Real Bottleneck Once Code Generation Speeds Up
AI-assisted coding has changed the cost structure of software development. Code that once required line-by-line authoring can now be generated quickly through natural language descriptions, contextual hints, and multiple rounds of feedback. For prototype validation, UI building, and modules with relatively clear rules, this approach typically shortens the distance from requirement to running implementation.
This development style—driven by intent descriptions and rapid feedback—is commonly known as Vibe Coding.
But code generation speed is not the same as system maturation speed. A module that runs only proves it produces the expected behavior for a given set of inputs; it does not prove that responsibilities, state, and exception handling between it and other modules have stabilized into a reliable contract.
This gap is especially visible in multi-agent systems. Such systems contain not just task execution code, but also planning, tool invocation, task assignment, message passing, state persistence, permission checks, and failure recovery. A local change can cross multiple execution paths and affect the entire task lifecycle.
For example, to fix a missing result, an AI coding tool might add a result-completion function; to handle a timeout, it might add a backup execution path. Each change looks reasonable in isolation, but without explicit constraints, you may end up with:
- Both the normal path and the backup path able to declare task completion;
- Workers and coordinators each maintaining their own copy of “current state”;
- Message-receiving modules modifying business state as a side effect of parsing messages;
- Legacy compatibility logic absorbing new requirements until it becomes a second implementation.
The question is therefore not just “is the code correct,” but “does the system explicitly define which code is allowed to do what.”
Engineering governance aims to turn these definitions from verbal consensus into executable, checkable, traceable constraints.
2. Understanding Harness Engineering
In the context of agent engineering, Harness Engineering has no fully standardized industry definition. This article defines it as: establishing a set of execution controls, quality verification, and evolution constraints around agent runtime and development, so that system behavior remains explainable, testable, and recoverable within defined boundaries.
It is not a single wrapper layer, nor a substitute name for any particular tool. More precisely, it is a set of engineering mechanisms connecting architecture design with day-to-day development.
These mechanisms must answer at least four questions:
What are the execution boundaries?
Which capabilities agents may invoke, which operations require approval, and how resource consumption is limited.Who confirms the system’s facts?
Which component is responsible for recording task state, execution results, and failure causes—and how other components read them.How are collaboration contracts enforced?
How agents hand off tasks, handle duplicate messages, and confirm responsibility transfer.How is system evolution controlled?
How new code proves it does not break existing boundaries, when compatibility logic gets cleaned up, and how failures roll back.
This does not conflict with traditional software engineering. State machines, access control, contract testing, and audit logging are all mature methods. What makes agent systems special is that model output is uncertain, execution paths change dynamically, and code can be generated rapidly by AI coding tools. These methods therefore need to move more explicitly into the runtime and the development workflow, not merely live in documentation.
One foundational principle: a model may propose actions, but should not define its own execution permissions; it may generate results, but should not bypass acceptance rules on its own.
3. A Four-Layer Governance Framework: From Abstract Principles to System Structure
The following four layers are an engineering division aimed at multi-agent projects—not a universal standard. Their value lies in separating easily confused responsibilities so problems can be localized to specific boundaries.
Layer 1: Execution—Limiting the Behavior Scope of a Single Agent
The execution layer handles tool access, input/output validation, time budgets, cancellation handling, and side-effect control within a single run.
This layer should distinguish two categories of operations:
- Low-risk operations such as reading information or generating drafts;
- Operations with external side effects, such as modifying data, sending messages, or committing transactions.
The second category requires authorization checks, human confirmation, or idempotency protection proportional to business risk. An agent should not be assumed to have execution permission merely because it generated a correctly formatted call request.
Timeout and cancellation also should not just mean the caller “stops waiting.” If the underlying execution continues, it may submit a result after the task was cancelled, causing state pollution. The system must define how cancellation signals propagate, and whether late results are rejected, quarantined, or retained for audit.
Layer 2: State—Establishing Authoritative Facts and Transition Rules
The state layer manages task lifecycles and key facts.
Common states include: pending, executing, waiting for external input, succeeded, failed, and cancelled. But state names are not the point—the point is that every transition must have explicit conditions and an accountable owner.
For example:
- Pending → executing requires a valid execution token;
- Executing → succeeded requires the result to pass acceptance;
- Executing → failed requires a recorded failure classification;
- A cancelled task cannot be flipped to succeeded by a late result.
An authoritative source of facts does not mean all data must live in a single table. Each class of key facts needs a clearly designated authoritative source. Task state may live in a state service while artifacts reside in object storage—but the two must be reliably linked.
Caches, UI displays, and message copies can hold derived state, but should never independently adjudicate final results.
Layer 3: Collaboration—Managing Handoffs and Responsibility Transfer
The collaboration layer covers task assignment between agents, context passing, handoff confirmation, and exception recovery.
A task handoff cannot just be a natural-language message like “please continue with this task.” At minimum it must specify:
- Task identifier;
- Current execution round;
- Handoff target;
- Input context or a reference to it;
- Completion conditions;
- Deadline;
- How duplicate requests are handled;
- When the original executor loses submission rights.
In particular, distinguish “message sent,” “message received,” and “task taken over.” These are three different states.
For cross-process or cross-node collaboration, network delays and retries are routine. Do not design for exactly-once delivery; allow duplicate delivery and rely on idempotent processing to prevent duplicate effects.
Layer 4: Evolution—Embedding Architectural Constraints into Development
The evolution layer concerns whether the system remains controllable after sustained iteration.
It includes code review, dependency constraints, contract testing, fault drills, change records, and cleanup of compatibility paths.
AI coding tools can help generate implementations, but changes involving state writes, permission decisions, cross-module calls, and recovery flows should undergo higher-intensity verification.
This layer should also maintain explicit exit mechanisms: temporary compatibility branches need documented reasons, scope, and removal conditions—otherwise “temporary” easily becomes permanent architecture.
4. Three Typical Repairs: From Local Patches to Governance Improvements
The scenarios below are illustrative examples, not records of a specific project’s failures.
Repair 1: A Helper Function Becomes a Second Main Path
Suppose the normal flow has a task executor call a tool and submit the result. After one tool returns malformed output, a helper function is added to fix the output.
As more anomalies appear, the function takes on re-invoking the tool, retrying tasks, generating substitute results, and updating state.
Superficially it improves fault tolerance; in reality, it has morphed from a format-fixing utility into a hidden task executor.
The problem is not the function’s name or its length, but the powers it acquired that never belonged to it.
The repair has three steps:
First, trace the actual call chain: does the helper produce external side effects, update task state, or bypass acceptance checks?
Second, redistribute responsibilities. Format repair only returns a fixed result; retries are decided by the scheduler; state submission goes through the state layer; backup execution follows the same authorization and acceptance rules as the main path.
Third, add boundary tests. For example, if the input cannot be repaired, the helper must return an explicit error rather than automatically starting a new round of task execution.
Governance lesson: you cannot solve privilege escalation just by “splitting big functions into small ones.” What must be reclaimed is decision authority and state-write authority.
Repair 2: Multiple Adjudicators for Task Completion
Another common scenario: a worker agent considers the task successful, the coordinator thinks it is still waiting, and the UI already shows completion.
This usually stems from multiple components maintaining state independently and each inferring the final result upon receiving messages.
The fix is to separate “execution reports” from “authoritative state changes.”
A worker agent may report execution finished, submit artifacts, and provide acceptance evidence—but whether the task enters the succeeded state must be decided by the component that owns that authority, according to rules.
For possible concurrent submissions, check state versions or execution rounds. The following is illustrative pseudocode, not tied to any product interface:
submitResult(taskId, executionRound, expectedVersion, artifactRef):begin transactionread current taskif task is already in a terminal state:return already-processed or rejectedif executionRound is not the current valid round:reject stale submissionif currentVersion != expectedVersion:return concurrency conflictif artifact fails acceptance:log acceptance failurekeep or transition to the specified stateelse:save artifact referencetransition task to succeededincrement state versioncommit transaction
Version checking and writing must be implemented through transactions or another atomic mechanism—otherwise races can still occur after the check.
Governance lesson: unifying state display is not enough. You must unify state adjudication rules and make stale executors unable to overwrite new facts.
Repair 3: Backup Execution and Task Handoff Create Double Submissions
Suppose a worker is slow, so the coordinator starts a backup worker. The original worker then recovers, and both submit results.
If the system only uses “whoever returns first” as the validity criterion, results may repeatedly overwrite each other, and external side effects may occur twice.
The core fix is to assign a valid identity to each execution round and update the current execution token at handoff time.
A workable approach:
- Record an independent execution identifier for each round;
- After a takeover, the old execution identifier loses submission eligibility;
- All result submissions verify the currently valid execution identity;
- Assign independent idempotency keys to external side effects;
- Design compensation or manual intervention flows for non-revocable operations.
Note: rejecting an old result at the task layer does not prevent the old worker from producing external side effects. If the old worker can still call external systems after losing its authority, authorization must also be checked at side-effect entry points, or use a mechanism that rejects stale execution requests.
For external operations that support neither idempotency nor rollback, document the residual risk rather than promising strict “exactly once.”
Governance lesson: a timeout is not a failure, and a takeover does not mean the old execution has stopped. Responsibility transfer requires a protocol, and side-effect control requires independent guarantees.
5. Keeping AI Coding Within Engineering Boundaries
Governance should not only intervene after failures; it should enter before code generation and before changes are merged.
1. Define Invariants Before Describing Implementation Requirements
Invariants are constraints the system must always satisfy, for example:
- A task has only one valid submission identity at any moment;
- Terminal states cannot be overwritten by ordinary execution messages;
- Message parsing layers cannot directly modify business state;
- Backup paths cannot have broader permissions than the main path;
- External side effects must go through a unified authorization entry point.
Rather than telling an AI coding tool only “fix the duplicate task completion issue,” provide these invariants as well. Generated solutions will then be more likely to respect the correct boundaries instead of piling on local patches.
2. Require Change Explanations of Impact Scope
Every change touching core flows should state:
- Which state transitions were added or removed;
- Whether new state writers were introduced;
- Whether retry and cancellation semantics changed;
- Whether new cross-layer dependencies were added;
- Whether a compatibility branch was introduced;
- When the original path will stop being used.
These questions can serve as a review template. They get closer to the real risks of agent systems than “is the code clean.”
3. Tiered Checks for High-Risk Changes
Pure copy edits and state protocol changes should not use the same review intensity.
Tiers can be based on impact scope:
- Local, side-effect-free changes: focus on functional correctness;
- Input/output contract changes: add compatibility and contract tests;
- State and handoff changes: add concurrency, out-of-order, and failure-recovery tests;
- Permission and external side-effect changes: add security review, auditing, and rollback plans.
The goal of tiering is not to slow development, but to direct verification effort where the system’s boundaries can actually break.
6. Testing Focus: Verify Abnormal Orderings, Not Just Happy Paths
Problems in multi-agent systems often occur when “messages arrive in an order different from what was expected.”
So testing must cover more than one smooth execution. Cover cases such as:
- The same message arriving twice;
- An old round’s result arriving after the new round’s result;
- A worker returning after the task was cancelled;
- State submission succeeds but notification delivery fails;
- Notification is sent, then the execution process exits;
- A handoff request is sent but the confirmation is lost;
- After acceptance fails, a backup path tries to mark success directly.
Test assertions should check final state, valid execution identity, artifact linkage, and side-effect counts—not just whether an exception was thrown.
For the “state saved but message not yet sent” problem, you can narrow the consistency gap by transactionally recording pending events and delivering them asynchronously. But consumers still typically need deduplication; this does not automatically eliminate all duplicates and delays.
Tests should also check permission boundaries: a component without state-adjudication authority must not be able to modify final state—even if it constructs a perfectly well-formed request.
7. Observability: Enabling the System to Explain Why a Task Ended the Way It Did
Application logs alone are insufficient for multi-agent governance. Verbose natural-language logs record plenty of process detail while missing the decisive facts.
Record structured information around the task lifecycle:
- Task identifier and execution identifier;
- Current state and state version;
- Who initiated the state change;
- Basis for the change and acceptance results;
- Handoff targets and confirmation records;
- Retry reasons;
- Backup path trigger conditions;
- Idempotency keys for external side effects;
- Reasons for rejected submissions.
These records need appropriate access controls, retention periods, and sensitive-data handling—avoid hoarding user data just for debugging convenience.
On the operations side, monitor metrics like backup path trigger rate, duplicate submission rejection rate, handoff timeout rate, and acceptance failure rate. But interpret metrics in the context of task types and business phases; do not treat all retries as architectural defects.
Truly valuable observability means being able to answer after an incident: which component made the decision, on what basis, who held authority at the time, and why alternative outcomes were not adopted.
8. A Rollout Path: Govern Critical Powers First, Then Clean Up Code Incrementally
For projects that have already accumulated large amounts of AI-generated code, an immediate full refactor is inadvisable. A more feasible path:
Phase 1: Inventory the powers.
Locate all state-write points, task-start points, permission decision points, and external side-effect entry points. Identify the places that actually control system behavior first.
Phase 2: Establish key invariants.
Prioritize high-risk issues—duplicate completions, stale submissions, unauthorized calls, uncontrolled retries—and encode constraints into runtime checks and tests.
Phase 3: Converge execution paths.
Make the main path, backup paths, and compatibility paths share the same authorization, acceptance, and state-submission rules, avoiding parallel implementations with different governance strength.
Phase 4: Clean up legacy compatibility.
Delete obsolete branches gradually based on call records and migration plans, with explicit removal conditions. For paths lacking observability data, add instrumentation first, then decide whether they can be safely retired.
Phase 5: Institutionalize the development process.
Fold contract descriptions, impact analysis, and risk-tiered checks into the daily change workflow, so AI-generated code and human code obey the same rules.
This path prioritizes risk over code aesthetics. A module with unglamorous naming but clear boundaries is usually more reliable than an elegantly structured module that allows state to be modified anywhere.
9. Conclusion: Growing Generation Speed and Governance Capability Together
Moving from Vibe Coding to Harness Engineering does not negate the value of AI-assisted coding. It acknowledges that code generation and system governance are distinct capabilities.
AI coding excels at producing implementations quickly; engineering governance ensures those implementations do not erode system boundaries under sustained modification.
For multi-agent systems, the critical constraints are not complicated: who can start execution, who can confirm state, when task handoffs take effect, what permissions backup paths hold, and how every change proves these rules still hold.
When these questions have explicit answers—embodied in contracts, runtime checks, tests, and audit records—the speed that AI coding delivers can translate into long-term, sustainable delivery capability. A truly mature system is not one that never fails, but one that—after failures, retries, takeovers, and evolution—still maintains clear accountability, consistent facts, and controllable behavior.
