$ fssg build --deterministic --validate |

AI Agents Need Two Contracts: Behavior and Execution

FACET

An agent can obey its goal and still perform an operation it was never authorized to perform. It can also stay within its permissions while violating the task’s invariants. These are different failures. Treating both as “prompt alignment” hides the boundary that engineering needs.

I use a two-contract model:

  1. The behavior contract defines what must remain true while the agent pursues a goal.
  2. The execution contract defines what the runtime may compile, authorize, and commit.

Neither contract replaces the other. Together they turn a vague instruction into a system with two independent reasons to stop.

The first contract constrains the trajectory

A behavioral contract describes the agent’s obligations across a multi-step task: preconditions, invariants, postconditions, prohibited states, and recovery rules. The recent Agent Behavioral Contracts work formalizes this direction around design-by-contract and runtime monitoring.

The useful unit is not a single tool schema. It is a property that must survive the trajectory.

Consider an agent updating a deployment configuration:

precondition: target environment is staging
invariant: production credentials never enter generated artifacts
postcondition: configuration parses and references an existing image digest
recovery: on failed validation, preserve the previous configuration

These rules answer: what outcome and intermediate states are acceptable?

A model can produce syntactically valid calls while breaking any one of them. Tool arguments may match JSON Schema; the sequence can still cross a forbidden state. Behavioral monitoring catches the gap between local validity and task-level correctness.

The second contract constrains authority

FACET addresses another plane. Its specifications define a deterministic contract layer around model execution: canonical representation, typed interfaces, effect declarations, policy, context layout, reproducibility, and passive provider adapters. The runtime can inspect this layer before inference and before an external effect.

An execution contract answers different questions:

  • Which interface may be called?
  • What effect class does the operation declare?
  • Which capability authorizes it?
  • What exact context and policy were compiled?
  • Is the provider adapter preserving semantics?
  • Can the preparation artifact be reproduced and reviewed?

This is why I do not describe FACET as a better prompt format. The important boundary is not prose quality. It is whether probabilistic intent reaches the world through a compiled, inspectable envelope.

I have written separately about pre-execution authorization and FACET compiler inspection artifacts. The two-contract model connects those mechanisms to task-level invariants without collapsing them into one policy language.

One action, two independent decisions

Suppose an agent proposes:

{
  "tool": "deploy.release",
  "args": {
    "environment": "staging",
    "image": "registry.example/app@sha256:..."
  }
}

The execution contract may conclude:

interface: valid
effect: external-write
capability: allowed for staging
policy: allow

That is necessary, but it does not prove that the release satisfies the task’s behavioral postconditions. The image might be older than the approved candidate. A required migration check may be missing. The operation is authorized yet wrong for this trajectory.

The reverse also happens. The proposed release may satisfy every behavioral invariant, but the current principal has no deployment capability. The action is correct in intent yet unauthorized in execution.

A reliable runtime therefore needs a conjunction:

commit = behavior_monitor.accepts(state_transition)
      && execution_guard.allows(action_envelope)

A denial from either side stops the effect. The reason must remain distinct in the trace. “Invariant violation” and “missing capability” require different repair paths, different owners, and different evidence.

Do not build one giant contract

The tempting design is to merge every rule into a universal policy document. I think that creates a new ambiguity.

Behavioral contracts reason about task state over time. Execution contracts reason about authority, representation, and effects at a concrete boundary. They evolve at different rates and belong to different reviewers.

Question Behavior contract Execution contract
Primary object State transition Action envelope
Typical rule “Production state must not change” “This capability cannot invoke production writes”
Evaluation time Across the trajectory Before compile/dispatch/commit boundaries
Failure owner Task designer or domain owner Platform/security/runtime owner
Evidence Monitor events and state snapshots Canonical artifact, policy decision, effect receipt

The separation also prevents accidental authority escalation. A behavioral statement such as “restore service health” must not silently grant access to every tool that could help. Goals describe desired state; capabilities grant verbs. Connecting them is an explicit runtime decision.

The trace needs a join key

Two independent contract systems are useful only if their evidence can be joined. I would bind both decisions to the same transition identity:

{
  "transition_id": "tr_01J...",
  "behavior_contract_digest": "sha256:...",
  "execution_contract_digest": "sha256:...",
  "proposal_digest": "sha256:...",
  "behavior_decision": "accept",
  "execution_decision": "allow",
  "effect_id": "eff_01J..."
}

This is not a claim that current FACET tooling emits this combined receipt. It is the integration artifact I believe the architecture requires. Without shared identity, an audit can show that two checks happened but cannot prove they evaluated the same proposed transition.

The digest also protects review semantics. If arguments, policy, or the relevant behavioral contract change, the previous decision no longer authorizes the new envelope. This follows the same principle as semantic policy hashes: evidence must bind to meaning, not merely to a filename or timestamp.

Where the model still belongs

Contracts do not make an open-ended goal deterministic. The model still proposes plans, interprets ambiguous context, and selects candidate actions. Behavioral predicates can themselves be incomplete. Runtime policy can authorize a harmful operation if the capability design is wrong.

The point is narrower and more useful: uncertainty should not own the final boundary.

The model proposes a transition. The behavior monitor checks whether the trajectory remains valid. FACET compiles the execution envelope and the guard checks authority. Only then may the runtime commit an effect.

This architecture does not promise an infallible agent. It gives every consequential action two explicit questions—and preserves which question failed. That is a much stronger foundation than asking one prompt to be intelligent, aligned, authorized, and correct at the same time.

Sources

FACET AI CLI Terminal
facet@ai:~$