Lesson 1 of 6 · 25 min

Design an AI Agent Contract: Inputs, Outputs and Limits

Buyers run your agent inside their business. Start with a contract they can read.

XDQ Tutor · AI guide

Hello. In this lesson I will take you through 5 ideas, one at a time.

  1. An agent is a promise
  2. Inputs and outputs as schemas
  3. What the agent never does
  4. Limits and service levels
  5. Worked example: a renewal reminder agent contract

Why it matters: Buyers run your agent inside their business. Start with a contract they can read. After each idea I will ask you one quick question.

An agent is a promise

The short version: When another company installs your agent, they are trusting it with their data and their customers.

When another company installs your agent, they are trusting it with their data and their customers. Before writing code, write the contract: what the agent reads, what it produces, what it never does, how long a run takes and what it costs. This contract becomes your listing, your input schema and your tests.

Narrow agents sell better than broad ones. An agent that drafts renewal reminders thirty days before a contract ends is easier to trust, price and test than one that manages all customer communication.

Quick check

Why return a status field?

Inputs and outputs as schemas

The short version: Define input and output as JSON schemas with required fields, types and length limits.

Define input and output as JSON schemas with required fields, types and length limits. Reject anything outside the schema before calling a model. Return structured output, not free text, so the platform can show it, check it and route it to a person for approval.

Include a confidence or status field so the caller knows when the agent could not do the job, rather than receiving a confident-sounding guess.

json · illustrative
{
  "input": { "customer": "string, max 120", "contract_end": "date", "tone": "formal | friendly" },
  "output": { "subject": "string, max 120", "body": "string, max 2000",
              "status": "ok | needs_info", "missing": ["string"] }
}
Quick check

Which agents are easiest to sell?

What the agent never does

The short version: Write the never list as carefully as the feature list: never send messages itself, never see another workspace's data, never store inputs beyond the run, never follow instructions found inside customer content.

Write the never list as carefully as the feature list: never send messages itself, never see another workspace's data, never store inputs beyond the run, never follow instructions found inside customer content. Buyers and reviewers read this list first.

Each item on the never list should be enforced in code or by the platform, not just promised.

  • Never sends anything by itself; output waits for a person
  • Never sees another workspace
  • Never keeps inputs after the run
  • Never treats instructions inside documents as commands
Quick check

How should never-list items be handled?

Limits and service levels

The short version: State a maximum run time, a maximum input size and what happens when they are exceeded.

State a maximum run time, a maximum input size and what happens when they are exceeded. State whether runs are synchronous or return a run ID for later collection. These details prevent support tickets and refunds.

XDQ teams find that a one-page contract written before code cuts later rework more than any other step.

Worked example: a renewal reminder agent contract

The short version: Purpose: drafts a renewal reminder email for a B2B contract that ends in thirty days.

Purpose: drafts a renewal reminder email for a B2B contract that ends in thirty days. Input: customer name up to 120 characters, contract end date, plan name, and tone of formal or friendly. Output: subject up to 120 characters, body up to 2,000 characters, status of ok or needs_info, and a list of missing fields. Run time: under ten seconds. Price: a fixed number of credits per run, with no charge when the status is needs_info.

Never list: never sends email, never contacts the customer, never reads anything except the fields given, never stores inputs after the run, never includes prices or discounts that were not in the input. With this contract, the developer can write input validation, output validation and tests before choosing a model, and the buyer's reviewer can approve the listing in minutes because every question they would ask is answered on one page.

Key takeaways
  • Write the contract before the code
  • Use JSON schemas for input and output
  • Return a status so failures are explicit
  • Enforce every item on the never list
  • State run time and size limits
Try it

Write a one-page contract for an agent you could sell: purpose, input and output schemas, never list, limits and price per run. Ask a colleague to find one ambiguity in it.

That is the lesson.
Mark it complete to track your progress on this device.
← CourseCourse overviewNext lesson →Verify Signed Requests With HMAC and Timestamps