Why contracts come first
The tools are the only way the platform can change an account, a message or a restriction. 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.
- Tools that only reduce risk can be automatic; tools that restrict a player beyond the rules need a named person.
- No tool exists to accept a bet, set odds, settle a bet or move money. Those are deterministic services outside the agents' reach.
The tool catalogue
| Tool | Purpose | Changes data | Safe to retry | Scope | Needs approval |
|---|---|---|---|---|---|
| get_player_summary | Read status, limits and exclusions, with identity masked | No | Yes | player.read | No |
| get_account_activity | Summarise deposits, stakes, sessions and limit changes | No | Yes | activity.read | No |
| check_eligibility | Read the result of the age, location and exclusion rules | No | Yes | eligibility.read | No |
| search_terms | Retrieve terms and house rules with citation and effective date | No | Yes | knowledge.read | No |
| get_dispute_evidence | Bet, result source and settlement for a disputed bet | No | Yes | evidence.read | No |
| propose_intervention | Record a proposed intervention with reasons | Yes, a proposal only | Yes, by key | intervention.propose | No |
| apply_protection | Suppress marketing, pause bonuses, reality check, limit prompt, enforce exclusion | Yes, reduces risk only | Yes, by key | protection.apply | Rule threshold or request: no. Otherwise a specialist |
| send_player_message | Send an approved intervention or service message | Yes | Yes, by key | message.send | Approved template and consent or service basis |
| restrict_account | Restrict play, pause withdrawals or hold funds beyond the rules | Yes | Yes, by key | account.restrict | Always a named specialist or analyst |
| create_goodwill | Credit goodwill | Yes | Yes, by key | goodwill.create | Above the limit: supervisor |
| draft_report | Assemble an evidence draft for a regulator or sports body | Yes, a draft only | Yes, by key | report.draft | Filing is a person's act |
An operation, in OpenAPI
Applying a protection is the most sensitive automatic write. The operation accepts only actions that reduce risk, requires an idempotency key and a stated basis, and refuses any restrictive action.
openapi: 3.1.0
info: { title: Player protection tools, version: 1.5.0 }
paths:
/players/{player_id}/protections:
post:
operationId: apply_protection
summary: Apply a protective action that only reduces risk. Reversible by a specialist.
parameters:
- { name: player_id, in: path, required: true, schema: { type: string } }
- { name: Idempotency-Key, in: header, required: true, schema: { type: string, minLength: 16 } }
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [action, basis]
properties:
action: { type: string, enum: [suppress_marketing, pause_bonuses, reality_check, limit_prompt, enforce_exclusion] }
basis: { type: string, enum: [rule_threshold, specialist_approved, player_request],
description: Why this action is allowed; specialist_approved needs specialist_id }
specialist_id: { type: string }
expires_at: { type: string, format: date-time }
responses:
"201": { description: Applied }
"200": { description: Same Idempotency-Key replayed; returns the original action }
"409": { description: Already in force }
"422": { description: Action not permitted for this basis, or a restrictive action was requested }
"403": { description: Caller scope failed }A read tool, as an MCP definition
The platform sees tools through the Model Context Protocol. The definition repeats the constraints that matter: a bounded period, an enumerated list of what to include, no identity fields and read-only hints.
{
"name": "get_account_activity",
"description": "Summarise a player's recent activity for a specialist: deposits, stakes, session length and limit changes over a period. Read only. No identity fields.",
"inputSchema": {
"type": "object",
"required": ["player_id", "period_days"],
"properties": {
"player_id": { "type": "string" },
"period_days": { "type": "integer", "minimum": 1, "maximum": 90 },
"include": { "type": "array", "maxItems": 4,
"items": { "enum": ["deposits", "stakes", "sessions", "limit_changes"] } }
}
},
"annotations": { "readOnlyHint": true, "idempotentHint": true }
}Error model
| Code | Meaning | What the platform does |
|---|---|---|
| invalid_argument | A field failed validation | Route to a person with the reason; never retry unchanged |
| not_found | Player, bet or case unknown | Check the identifier; do not guess |
| conflict | Protection already in force, or a case already closed | Re-read state and reconsider; never force |
| forbidden | Scope or approval check failed | Do not retry; route to a person; raise a security event |
| rate_limited | Too many calls | Back off, then queue |
| unavailable | Backend down or timed out | Retry once with the same key, then queue for a person |
Rules every tool follows
Idempotency
Every write takes an idempotency key. A replay returns the original result and never creates a second one.
Basis and approval
A write states why it is allowed. The tool gateway checks the basis against the action and the caller's authority.
Risk-reducing only
Automatic tools can only reduce risk. A request for a restrictive action through an automatic tool is refused.
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 basis, 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 restriction test sends restrictive actions through the automatic tool and expects a refusal.
- 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 player protection and operations platform for a licensed betting operator, but the same pattern, deterministic rules for every hard duty, a governed gateway, runtime security, protect-first automation and measured quality, fits any regulated, customer-facing service. We can scope a pilot on your own systems.
Book a discovery call