Intent Integrity for AI Agents: Do No Harm at Machine Speed

When a human authorizes an AI agent to build something, a contract forms: this is what I want, go make it real. The agent transforms that intent through dozens of intermediate steps — architecture decisions, code generation, refactoring, optimization, compilation, deployment. At each step, the original intent can drift, degrade, or disappear entirely. Intent integrity is the engineering discipline that prevents this.

What Intent Integrity Means

Intent integrity is the property that what humans authorized is what actually executes — preserved through every transformation between authorization and runtime behavior. It's not about whether the code compiles or tests pass. It's about whether the system still does what was asked after everything the agent did to build it.

A measure engine that passes all tests but calculates quality scores using the wrong specification year has perfect test coverage and zero intent integrity. The code works flawlessly; it just doesn't do what was authorized. In healthcare, that gap costs organizations real money in payment adjustments. In safety-critical systems, it costs more.

Why It Matters When Agents Transform Code

Human developers maintain intent implicitly — they remember what they're building while they build it. AI agents don't have this implicit connection. They optimize for the objective function in front of them, which might be "make tests pass" rather than "accomplish what the human actually wanted." An agent can refactor code into something technically superior that no longer serves its original purpose. It can optimize a query for performance in a way that changes which records are included. It can resolve a merge conflict by choosing the wrong side.

At machine speed, these drift events compound. An agent making 50 changes per hour accumulates intent drift faster than any human reviewer can detect. By the time someone inspects the output, the system may be internally consistent (everything builds, tests pass, types check) but externally incorrect (it no longer does what was authorized).

How Intent Contracts Work

Intent Contracts are formal declarations of what a piece of code is authorized to accomplish, expressed in a form that survives compilation and deployment. They are not comments — comments are discarded by compilers and ignored by runtimes. Intent Contracts are structured assertions that travel with the code through every transformation.

A contract declares: this function must return the count of patients who meet CMS measure 130 criteria for the 2025 reporting year. That declaration persists whether the implementation uses SQL, Python, or a materialized view. It persists through refactoring, optimization, and agent-driven rewrites. At any point, a verifier can ask: does this implementation still satisfy its contract?

The contract doesn't specify how — that's the agent's job. It specifies what was authorized — that's the human's prerogative. The separation is what makes autonomous execution safe: agents have freedom to optimize implementation while being bound to declared intent.

Primum: Do No Harm Monitoring

Primum — named for primum non nocere (first, do no harm) — is the runtime monitoring layer that watches whether execution still accomplishes what was authorized. It operates continuously, not just at deployment boundaries. Every pipeline run, every data refresh, every agent-modified component is evaluated against its declared intent.

Primum doesn't prevent change — it prevents unauthorized change. An agent can rewrite an entire module, and Primum will approve it if the new implementation still satisfies the intent contract. But if an optimization subtly changes which patients qualify for a measure, Primum catches the drift immediately — not three months later when CMS audits the submissions.

The monitoring is independent from the agent that produced the code. This independence is essential: the same reasoning that introduced drift cannot be trusted to detect it.

Connection to Stage-Gate-Loop

Intent integrity operates across all three layers of the Stage-Gate-Loop governance model:

The three layers operate at different speeds but serve the same purpose: maintaining the chain from human authorization to runtime execution. Intent integrity is what makes autonomous loops safe — not by limiting what agents can do, but by ensuring that whatever they do still serves the original purpose.


Related


Douglas Jones · Codifide