Why contracts come first
The tools are the only way the assistant can change the world. Their contracts are the stable layer: the Microsoft Foundry build and the LangGraph build both call the same operations, and the evaluation set checks the same arguments. A strict contract makes the system testable, lets the tool gateway enforce policy and limits what a manipulated model can do.
- Arguments are typed, bounded and validated by the tool gateway, never trusted from the model.
- Every tool declares whether it changes anything, whether it is safe to retry and what scope it needs.
- Free text is limited in length and never fed back to the model from backend responses.
- A write needs a prior read: hold before commit, and commit needs a confirmation token.
The tool catalogue
| Tool | Purpose | Changes data | Safe to retry | Scope | Needs confirmation |
|---|---|---|---|---|---|
| search_rules | Retrieve airport rules and terms as cited clauses | No | Yes | knowledge.read | No |
| get_airport | Hours, services, capacity and local restrictions | No | Yes | airport.read | No |
| quote_services | Price a set of services | No | Yes | pricing.read | No |
| check_availability | Hangar, ramp and fuel availability for a window | No | Yes | inventory.read | No |
| hold_resources | Hold resources for a fixed window | Yes | Yes, by key | booking.hold | No, but shows terms |
| commit_booking | Turn a hold into a booking | Yes | Yes, by key | booking.commit | Yes, token |
| change_booking | Change the time or services of a booking | Yes | Yes, by key | booking.change | Yes, token |
| cancel_booking | Cancel and apply the cancellation terms | Yes | Yes, by key | booking.cancel | Yes, token |
| request_service | Request a crew car, catering or de-icing | Yes | Yes, by key | service.request | No for standard, desk for custom |
| get_booking | Read a booking on the caller's own account | No | Yes | booking.read | No |
| handoff | Open a ticket for the line desk with the thread | Yes | Yes, by key | desk.write | No |
An operation, in OpenAPI
The commit operation is the most sensitive. It needs an idempotency key and a single-use confirmation token, and its responses say exactly what happens on a replay or a stale hold.
openapi: 3.1.0
info: { title: Booking tools, version: 2.3.0 }
paths:
/bookings:
post:
operationId: commit_booking
summary: Commit a held booking. Requires a confirmation token.
parameters:
- { name: Idempotency-Key, in: header, required: true, schema: { type: string, minLength: 16 } }
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [hold_id, confirmation_token]
properties:
hold_id: { type: string }
confirmation_token: { type: string, description: Single use, issued after the guest's explicit CONFIRM }
responses:
"201": { description: Committed, content: { application/json: { schema: { $ref: "#/components/schemas/Booking" } } } }
"200": { description: Same Idempotency-Key replayed; returns the original booking }
"409": { description: Hold expired or already committed }
"422": { description: Token invalid, expired or already used }
"403": { description: Caller scope or account ownership check failed }The same tool, as an MCP definition
The assistant sees tools through the Model Context Protocol. The definition repeats the constraints that matter: patterns, bounds, an enumerated list of services and read-only hints.
{
"name": "quote_services",
"description": "Price a set of ground services at one airport for one aircraft. Read only. Prices come from the pricing service.",
"inputSchema": {
"type": "object",
"required": ["airport", "arrival_from", "arrival_to", "aircraft_id", "services"],
"properties": {
"airport": { "type": "string", "pattern": "^[A-Z]{4}$" },
"arrival_from": { "type": "string", "format": "date-time" },
"arrival_to": { "type": "string", "format": "date-time" },
"aircraft_id": { "type": "string" },
"services": {
"type": "array", "maxItems": 12,
"items": { "type": "object", "required": ["type"],
"properties": { "type": { "enum": ["fuel", "hangar", "handling", "crew_car", "catering", "deice"] },
"quantity": { "type": "number", "minimum": 0 },
"notes": { "type": "string", "maxLength": 200 } } }
}
}
},
"annotations": { "readOnlyHint": true, "idempotentHint": true }
}Error model
| Code | Meaning | What the assistant does |
|---|---|---|
| invalid_argument | A field failed validation | Ask the guest for the missing or corrected detail; never retry unchanged |
| not_found | Airport, aircraft or booking unknown | Check the identifier with the guest; do not guess |
| conflict | Hold expired or resources taken | Explain, re-check availability and offer alternatives |
| forbidden | Scope or ownership check failed | Do not retry; offer a person; raise a security event |
| rate_limited | Too many calls | Back off, then degrade |
| unavailable | Backend down or timed out | Retry once with the same key, then hand off |
Sequence: a lost response and a safe retry
The retry cannot double-book because the key identifies the request. The rejection happens in the gateway, before any backend sees the call.
Rules every tool follows
Idempotency
Every write takes an idempotency key. A replay returns the original result and never creates a second one.
Ownership
The tool gateway binds each call to the verified account. An identifier from another account is rejected, whatever the model asked for.
Bounded output
Responses are structured and size-limited. Customer-entered notes are stripped before the model sees them.
Versioning
Contracts are versioned. A breaking change is a new major version, run side by side until the evaluation set passes on it.
Audit
Each call writes an audit record with the arguments hash, the caller, the outcome and the trace identifier.
Contract tests
- Every tool definition validates against the schema and has an owner, a scope and a retry rule.
- Property tests send out-of-range, oversized and malformed arguments and expect invalid_argument, never a partial write.
- A replay test sends each write twice with the same key and expects one result.
- A cross-account test calls each tool with another customer's identifier and expects forbidden.
- The Foundry build and the LangGraph build run the same contract suite against a mock backend.
Build this for your business
This example is a booking assistant for a ground-handling network, but the same pattern, a governed gateway, runtime security, grounded knowledge, deterministic commits and measured quality, fits any customer-facing assistant that takes actions. We can scope a pilot on your own systems.
Book a discovery call