Inferensys

Prompt

Tool Contract Breaking Change Detection Prompt

A practical prompt playbook for using Tool Contract Breaking Change Detection Prompt in production AI workflows.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Identify every breaking change between two tool schema versions before an agent encounters them in production.

This prompt is designed for platform engineers and integration developers who own the contract between AI agents and external tools. The core job-to-be-done is comparing two versions of a tool schema—whether OpenAPI, MCP, JSON Schema, or a custom contract—and producing a structured change impact report. The report must classify every difference by severity, assign a migration urgency score, and provide explicit guidance on what agent code, prompts, or tool configurations must be updated to prevent silent failures. Use this prompt before deploying a new tool version, as a gate in your CI/CD pipeline during contract verification, or when auditing a tool registry for compatibility risks across multiple agents.

Do not use this prompt for runtime tool selection or for generating new schemas from scratch. It assumes two complete, valid schemas as input and focuses exclusively on detecting breaking changes between them. The prompt is not a substitute for schema validation, and it will not catch semantic drift where a tool's behavior changes without a corresponding schema change. For runtime scenarios, pair this with a tool output contract validation prompt. For schema creation, use the Tool Contract Schema Definition Prompt Template instead. The ideal user has access to both schema versions, understands the agent's dependency on the tool, and needs a structured report that can feed directly into a migration checklist or automated compatibility gate.

Before running this prompt, ensure both schemas are normalized to the same format. If you are comparing an OpenAPI spec to an MCP tool definition, run the OpenAPI-to-MCP Schema Translation Prompt first. The prompt expects square-bracket placeholders for [OLD_SCHEMA] and [NEW_SCHEMA], and optionally [AGENT_CONTEXT] describing how the agent uses the tool. The output is a structured JSON report with fields for change type, severity, affected agent paths, and migration urgency. In high-risk environments—such as financial transactions, healthcare data, or security-sensitive operations—always route the report through human review before deploying. The prompt identifies what broke; a human must decide whether the break is acceptable and what the migration window should be.

Common failure modes include false positives when a field is renamed but semantically equivalent, and false negatives when a new required field is added inside a nested object that the prompt's diff logic does not fully traverse. To mitigate this, include [AGENT_CONTEXT] that specifies which fields the agent actually uses, so the prompt can prioritize changes that impact real agent paths rather than flagging every schema delta. After receiving the report, validate the top three highest-severity findings against your agent's actual tool-call logs before initiating any migration work. The next step is to feed the report into your change management process: update agent prompts that reference deprecated fields, adjust argument coercion rules, and schedule a canary deployment that monitors tool-call error rates against the new schema version.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you must provide before running it in a production pipeline.

01

Good Fit: Structured Schema Diffs

Use when: comparing two well-defined tool schemas (JSON Schema, OpenAPI, or typed MCP definitions) where field-level changes must be classified. Guardrail: ensure both schemas are normalized to the same format before diffing; the prompt assumes structural equivalence, not semantic reconciliation.

02

Bad Fit: Undocumented Runtime Behavior

Avoid when: the breaking change is behavioral (e.g., latency spikes, changed error codes, new rate limits) rather than structural. Guardrail: pair this prompt with a runtime contract test harness; schema diffs cannot detect semantic regressions or undocumented side effects.

03

Required Input: Versioned Schemas

What to provide: two complete tool contract versions with argument definitions, output shapes, error codes, and enum values. Guardrail: missing optional field annotations or implicit defaults will produce false negatives; validate schema completeness before running the prompt.

04

Operational Risk: False Confidence

What to watch: the prompt may classify a change as non-breaking when downstream consumers depend on undocumented behavior. Guardrail: always run a consumer impact analysis against actual agent call logs; schema-level compatibility does not guarantee behavioral compatibility.

05

Pipeline Integration: Pre-Deploy Gate

Use when: embedding breaking change detection into CI/CD for tool contract releases. Guardrail: configure the severity threshold to block deploys on high-severity changes only; low-severity warnings should trigger review tickets, not pipeline failures.

06

Human Review: Migration Urgency

What to watch: the prompt assigns urgency scores, but business context determines actual migration priority. Guardrail: route high-urgency outputs to platform engineers for manual triage; automated migration scheduling based solely on prompt output risks unnecessary churn.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for detecting breaking changes between two versions of a tool contract schema.

This prompt template is designed to compare two versions of a tool contract schema—typically a JSON Schema, OpenAPI fragment, or MCP tool definition—and produce a structured change impact report. The report identifies field removals, type changes, new required fields, enum value deprecations, and other breaking modifications. It also assigns a severity classification and a migration urgency score to each finding. Replace every square-bracket placeholder with your actual schemas, risk tolerance, and output format requirements before sending the prompt to the model.

text
You are a tool contract auditor. Your task is to compare two versions of a tool schema and identify every breaking change that could cause an agent or integration to fail.

## INPUTS

### Previous Schema (Version A)
[PREVIOUS_SCHEMA]

### Current Schema (Version B)
[CURRENT_SCHEMA]

### Tool Name
[TOOL_NAME]

### Additional Context
[CONTEXT]  // e.g., "This tool is used in a financial audit pipeline. Downtime requires Sev-2 escalation."

## DEFINITION OF BREAKING CHANGE
A change is breaking if an agent or client built against Version A could fail, produce incorrect results, or silently drop data when interacting with Version B. Include:
- Field removal (required or optional)
- Type change (e.g., string to integer, object to array)
- New required field added without a default
- Enum value removal or renaming
- Output shape change (removed response fields, changed response types)
- Constraint tightening (e.g., maxLength reduced, new pattern enforced)
- Semantic change (same field name, different meaning or unit)
- Endpoint or operation removal
- Authentication or authorization requirement change

## OUTPUT SCHEMA
Return a single JSON object with this exact structure:
[OUTPUT_SCHEMA]

## CONSTRAINTS
[CONSTRAINTS]  // e.g., "Do not flag cosmetic changes like description text updates. Only flag changes that affect runtime behavior."

## SEVERITY CLASSIFICATION
- **CRITICAL**: Agent will crash, hang, or produce incorrect results with no workaround.
- **HIGH**: Agent will fail on specific inputs or edge cases; workaround possible but fragile.
- **MEDIUM**: Agent behavior changes but does not break; may require code updates.
- **LOW**: Backward-compatible but warrants attention (e.g., new optional field that agents should adopt).

## MIGRATION URGENCY SCORING (1-10)
- 9-10: Deploy immediately; production is or will break.
- 7-8: Deploy within current sprint; risk is imminent.
- 4-6: Plan migration; breaking under specific conditions.
- 1-3: Nice-to-have; no immediate risk.

## INSTRUCTIONS
1. Parse both schemas completely.
2. Identify every difference between Version A and Version B.
3. Classify each difference as breaking or non-breaking per the definition above.
4. For each breaking change, assign a severity and migration urgency score with a one-sentence rationale.
5. Group findings by affected component (arguments, outputs, error responses, operations).
6. Include a summary section with total breaking changes, highest severity, and recommended migration window.
7. If no breaking changes are found, explicitly state that and explain why.
8. Return ONLY the JSON object. No markdown fences, no commentary outside the JSON.

Adaptation guidance: Replace [PREVIOUS_SCHEMA] and [CURRENT_SCHEMA] with the actual JSON Schema, OpenAPI fragment, or MCP tool definition for each version. The [OUTPUT_SCHEMA] placeholder should contain your desired JSON structure—define it precisely so the model returns parseable output every time. Use [CONSTRAINTS] to exclude known false positives, such as internal-only fields or documentation changes that your team has already reviewed. The [CONTEXT] field is optional but valuable for calibrating urgency scores to your operational reality. If your tool ecosystem uses a different severity taxonomy, replace the four-level classification with your own. For high-risk domains such as payments, healthcare, or auth, add a [RISK_LEVEL] field and instruct the model to escalate urgency scores accordingly.

What to do next: After copying this template, wire it into a CI pipeline that runs on every schema change PR. Pair it with the Tool Contract Validation Prompt to verify that the model's output JSON conforms to your [OUTPUT_SCHEMA] before surfacing findings. For production-critical tools, route CRITICAL and HIGH findings to a human review queue before merging. Avoid running this prompt on schemas larger than your model's context window without chunking; split large contracts by operation or component and merge results in application code.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Tool Contract Breaking Change Detection Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to verify the input is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[PREVIOUS_SCHEMA]

The baseline tool contract schema version to compare against

{"openapi": "3.0.1", "paths": {"/users": {"get": {"parameters": [{"name": "id", "in": "query", "required": true, "schema": {"type": "string"}}]}}}}

Must be valid JSON or YAML parseable as an OpenAPI 3.x, JSON Schema, or MCP tool definition. Reject if empty or unparseable.

[CURRENT_SCHEMA]

The updated tool contract schema version to compare for breaking changes

{"openapi": "3.0.1", "paths": {"/users": {"get": {"parameters": [{"name": "user_id", "in": "query", "required": true, "schema": {"type": "integer"}}]}}}}

Must be valid JSON or YAML parseable as an OpenAPI 3.x, JSON Schema, or MCP tool definition. Reject if identical to [PREVIOUS_SCHEMA] byte-for-byte.

[SCHEMA_FORMAT]

The schema specification format used by both inputs

openapi-3.1

Must be one of: openapi-3.0, openapi-3.1, json-schema-draft-2020-12, mcp-tool-definition, graphql-sdl. Reject unrecognized values.

[CHANGE_WINDOW]

The time period or version range over which breaking changes are assessed

v2.1.0 to v3.0.0

Must be a non-empty string. Accepts version ranges, date ranges, or commit SHAs. Used for urgency scoring context.

[CONSUMER_LIST]

Known downstream consumers or agents that depend on this tool contract

["order-fulfillment-agent", "customer-portal-backend"]

Optional array of consumer identifiers. If provided, each consumer name must be a non-empty string. Null allowed if consumer impact analysis is not required.

[SEVERITY_THRESHOLD]

Minimum severity level to include in the report

medium

Must be one of: low, medium, high, critical. Changes below this threshold are excluded from the output. Defaults to medium if not provided.

[DEPRECATION_POLICY]

The organization's deprecation policy window for determining migration urgency

90-day-notice-required

Must be a non-empty string referencing a known policy. Accepts freeform policy names. Used to calculate migration urgency scores and deadlines.

[OUTPUT_SCHEMA]

The expected structure for the change impact report

{"breaking_changes": [], "warnings": [], "migration_urgency": "", "consumer_impact": []}

Must be a valid JSON Schema or example object. The prompt will conform its output to this shape. Reject if unparseable.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the breaking change detection prompt into a CI pipeline, schema registry, or API gateway with validation, retries, and human review gates.

This prompt is designed to operate as a gating step in a schema evolution pipeline, not as a one-off analysis tool. The implementation harness should invoke the prompt whenever a tool's OpenAPI spec, MCP server manifest, or gRPC protobuf definition changes in version control. The prompt compares two schema versions—[OLD_SCHEMA] and [NEW_SCHEMA]—and produces a structured change impact report. The harness must supply both schemas in a normalized format (preferably JSON Schema or OpenAPI 3.x) to avoid the model hallucinating field names or types from inconsistent serializations. If your tool registry stores schemas in multiple formats, add a normalization step before prompt invocation to convert everything to a canonical representation.

The harness should enforce a strict output contract. After the model returns the change impact report, validate that the JSON output contains all required fields: breaking_changes (array of objects with field_path, change_type, severity, migration_note), non_breaking_changes, new_required_fields, deprecated_enum_values, and migration_urgency_score. Use a JSON Schema validator in your application code—do not rely on the model to self-correct without verification. If validation fails, retry once with the validation errors injected into [CONSTRAINTS] as explicit repair instructions. If the second attempt also fails, log the failure, flag the schema change for manual review, and block the merge or deployment. For high-risk tools (those handling payments, PII, or irreversible operations), always require human approval on any detected breaking change with severity high or critical, regardless of validation success.

Model choice matters here. Use a model with strong structured output capabilities and a large context window, as some enterprise API specs exceed 20K tokens. GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable defaults. Enable structured output mode (JSON mode or function calling with a strict schema) rather than relying on prompt-level formatting instructions alone. For cost control, cache the [OLD_SCHEMA] across multiple comparisons by storing it in a prompt cache or using a model that supports prefix caching. Wire the harness into your CI system (GitHub Actions, GitLab CI, Jenkins) so that every PR touching a tool schema file triggers the check. Post the change impact report as a PR comment and attach the full JSON payload as a CI artifact for audit trails. Do not auto-merge PRs that introduce breaking changes unless the migration urgency score is below a configurable threshold and the changes are explicitly allowlisted by the platform team.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the breaking change detection report. Use this contract to parse the model output, validate correctness, and route severity scores to your migration pipeline.

Field or ElementType or FormatRequiredValidation Rule

change_report.change_id

string (UUID v4)

Must parse as valid UUID v4. Reject if missing or malformed.

change_report.base_version

string (semver)

Must match pattern ^\d+.\d+.\d+$. Reject if not present in input [OLD_SCHEMA].

change_report.target_version

string (semver)

Must match pattern ^\d+.\d+.\d+$. Reject if not present in input [NEW_SCHEMA].

breaking_changes

array of objects

Must be a JSON array. Allow empty array if no breaking changes detected. Reject if null or not an array.

breaking_changes[].field_path

string (JSONPath)

Must reference a valid path in [NEW_SCHEMA] or [OLD_SCHEMA]. Reject if path does not resolve.

breaking_changes[].change_type

enum string

Must be one of: field_removed, type_changed, new_required, enum_value_removed, constraint_narrowed. Reject unknown values.

breaking_changes[].severity

enum string

Must be one of: critical, high, medium, low. Reject if missing or invalid.

breaking_changes[].migration_urgency_score

integer 0-100

Must be integer between 0 and 100 inclusive. Reject if out of range or non-integer.

PRACTICAL GUARDRAILS

Common Failure Modes

Breaking change detection prompts fail in predictable ways when schema diffs are ambiguous, severity is misclassified, or the model hallucinates changes that don't exist. These cards cover the most common production failure patterns and how to guard against them.

01

False Positive Breaking Changes

What to watch: The model flags additive changes—new optional fields, expanded enum values, or added endpoints—as breaking when they are backward-compatible. This floods teams with false alarms and erodes trust in the detection system. Guardrail: Include explicit definitions of backward-compatible changes in the prompt with counterexamples. Require the model to justify each severity classification with a specific consumer impact statement.

02

Missed Semantic Breaking Changes

What to watch: The model correctly identifies structural changes like field removals but misses semantic breaks—a field that keeps the same type but changes meaning, a status code that now fires under different conditions, or a default value shift that silently alters behavior. Guardrail: Pair structural diffing with behavioral contract descriptions. Require the prompt to compare field descriptions and documented semantics, not just type signatures. Flag any description change as requiring human review.

03

Severity Inflation or Deflation

What to watch: The model assigns CRITICAL severity to cosmetic changes or LOW severity to field removals that break core consumer workflows. Inconsistent severity scoring causes teams to ignore high-priority migrations or waste time on trivial changes. Guardrail: Anchor severity levels to concrete consumer impact criteria in the prompt. Require the model to answer: 'Does this change prevent existing consumers from functioning without code changes?' before assigning severity.

04

Enum Value Deprecation Blindness

What to watch: The model treats enum value additions as safe but misses that a previously accepted value is now deprecated or removed. Consumers sending the old value will receive errors or unexpected behavior, but the structural diff shows only additions. Guardrail: Explicitly instruct the prompt to enumerate all values in both schema versions and flag any value present in the old schema but absent or marked deprecated in the new schema as a breaking change.

05

Required Field Addition Misclassification

What to watch: The model classifies a new required field as a minor change because the field is 'just an addition,' but consumers that don't send the field will receive validation errors. This is a breaking change that blocks all existing integrations. Guardrail: Add a specific rule in the prompt: 'Any new required field in a request schema is a breaking change regardless of other considerations.' Include this as a non-negotiable classification rule with examples.

06

Nested Schema Change Omission

What to watch: The model performs shallow comparison and misses breaking changes in nested objects, array item schemas, or union types. A field removal three levels deep in a response object goes undetected because the top-level structure appears unchanged. Guardrail: Instruct the prompt to recursively traverse all nested schemas and report changes at every depth level. Require the output to include the full JSON path to each changed field, not just the top-level field name.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of a breaking change detection report before integrating it into a CI/CD pipeline or agent governance workflow. Each criterion targets a specific failure mode in production tool contract management.

CriterionPass StandardFailure SignalTest Method

Severity Classification Accuracy

All field removals and type changes are classified as 'breaking'. New required fields are classified as 'breaking'. Enum value additions are 'non-breaking'.

A removed optional field is flagged as 'breaking' or a new required field is missed.

Run against a golden set of 10 known schema diffs with pre-labeled severities. Require 100% recall on breaking changes.

Migration Urgency Scoring

Score is 'critical' if a breaking change affects an endpoint used in production traces. Score is 'low' if the change is in a deprecated endpoint.

A 'critical' score is assigned to a non-breaking change or a 'low' score is assigned to a field removal.

Validate against a test harness that injects production usage data. Check that urgency correlates with call frequency and change type.

Field Removal Detection

Every field present in [OLD_SCHEMA] but absent in [NEW_SCHEMA] is listed with its previous type and a deprecation status.

A removed nested field is omitted from the report.

Use a recursive JSON diff tool to compare the report's removal list against a programmatic diff of the input schemas.

Type Change Identification

Every field with a changed type is listed with both old and new types. Widening conversions (int to float) are noted as potentially breaking.

A type change from string to integer is not reported.

Parse the report's type change list and cross-reference with a schema comparison script. Check for false negatives on string-to-enum changes.

New Required Field Flagging

All fields added to [NEW_SCHEMA] without a default value or with a 'required: true' constraint are listed.

A new required field is listed as 'non-breaking' or omitted entirely.

Diff the required field arrays from both schemas. Verify the report captures the exact field names and their types.

Enum Value Deprecation Warning

Values present in [OLD_SCHEMA] enums but missing in [NEW_SCHEMA] enums are listed with a recommendation to check for data migration needs.

An enum value removal is reported as a type change instead of a deprecation.

Provide schemas with known enum contractions. Check that the report section exists and contains the correct deprecated values.

Output Format Adherence

The report is valid JSON matching the [OUTPUT_SCHEMA] exactly. All required fields are present. No additional commentary outside the JSON structure.

The model returns a markdown-wrapped JSON block or omits the 'breaking_changes' array.

Validate the raw output against the [OUTPUT_SCHEMA] using a JSON schema validator. Reject on parsing errors or missing required keys.

Hallucination Resistance

The report contains no fabricated fields, types, or constraints not present in either [OLD_SCHEMA] or [NEW_SCHEMA].

The report invents a 'deprecated_at' timestamp or adds a constraint not in the source schemas.

Diff the set of all field paths in the report against the union of field paths in the input schemas. Flag any path not found in either input.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single schema pair. Use a frontier model with a large context window. Skip severity scoring and focus on field-level diff detection. Accept plain-text output instead of structured JSON.

Simplify the prompt to:

code
Compare [OLD_SCHEMA] and [NEW_SCHEMA]. List every field that was removed, renamed, had its type changed, or became required. Group findings by operation.

Watch for

  • Enum value changes reported as type changes
  • Nested object diffs flattened incorrectly
  • New optional fields flagged as breaking
  • No distinction between additive and breaking changes
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.