Blog

Let a coding agent propose the contract

The Data Model Is an Intent File, Part 4 of 5

A Globex reviewer asks for one more field: the invoice's due date, when the document explicitly states one. They don't want the extractor to calculate a date from “Net 30.” In Part 3, we used the existing Globex contract to show how to turn a request into a checked result. Now let's change that contract.

Make the request specific

I'd give a coding agent the current YAML and three examples, and ask it to propose a revision:

Add dueDate to the Globex invoice intent. Use a string in YYYY-MM-DD form, or null if the document gives no explicit date. Always return the key. Leave the existing fields and currency list unchanged. Update the instruction and schema together, increment the version, and show how you'd test a stated date, payment terms alone, and a reply with the wrong date format.

The agent can propose the edit. A reviewer decides whether it should become the running version. Here's the revised contract used by the example checks:

Globex invoice contract, version 2Intent file
name: Globex.Invoice.Extract
version: 2
intent: >
  Extract the invoice number, total, currency, and purchase order number.
  Keep identifiers as written, including leading zeros.
  Return the three-letter currency code. If no purchase order number
  is present, return null for purchaseOrderNumber. Do not invent one.
  Return dueDate in YYYY-MM-DD form only when the invoice explicitly states
  a due date. Return null otherwise, including when it gives only payment terms.
shape:
  kind: schema
  schema:
    type: object
    properties:
      invoiceNumber: { type: string, minLength: 1 }
      currency: { type: string, enum: [USD, EUR, GBP] }
      total: { type: number, minimum: 0 }
      purchaseOrderNumber: { type: [string, "null"] }
      dueDate:
        type: [string, "null"]
        pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}$'
    required: [invoiceNumber, currency, total, purchaseOrderNumber, dueDate]
    additionalProperties: false
attempts: 2
timeout: PT15S

Check what changed

The website checks this exact YAML against three scripted replies. A reply of 2026-11-30 passes. A reply with dueDate set to null passes too. A reply of 11/30/2026 fails both allowed attempts and returns an unsuccessful result. The original two-invoice example remains unchanged.

Those checks use canned replies without calling a model. A live extraction should be tested separately, including whether the model returns null for “Net 30” alone. The pattern checks the format: 2026-02-31 still matches it. Add a calendar check if the date must be valid, and check the source or route the item to review when it must support that date.

Keep review and activation separate

The simplest review path is an ordinary repository diff. The agent proposes YAML, a person reviews the change and its effects on consumers, and the application loads the approved file through its normal process.

If the application uses a versioned document store, IntentSharp's edit APIs can check that the proposed document loads. The default writer applies accepted edits. If you need an approval step before activation, configure a writer that holds the proposal as a candidate. A loadable contract can still break a consumer, so keep compatibility tests and a person in the decision.

With supported reloads, later calls can pick up the approved definition while an in-flight call keeps the version it started with. In Part 5, I'll draw the line between the contracts I'd keep in files and the C# models I'd keep in code.

Try IntentSharp in your .NET project.