This prompt is for AI quality engineers and integration developers who need to build test harnesses for tool-bearing agents. The job is to produce a diverse, realistic set of mocked tool responses—including success, error, and edge-case variants—directly from a tool's contract schema. You use this when you have a defined tool interface (OpenAPI spec, function declaration, MCP server descriptor) but do not yet have a live backend, or when you need to test agent behavior against failure modes that are difficult to trigger in a real environment. The ideal user understands the tool's expected behavior and can provide a schema with field types, constraints, and error codes.
Prompt
Mock Tool Response Generation Prompt Template

When to Use This Prompt
Define the job, reader, and constraints for generating mock tool responses from a tool contract schema.
Do not use this prompt when you need to test against a live system's actual behavior, when the tool contract is unknown or purely conversational, or when the goal is to evaluate the agent's planning logic rather than its response handling. This prompt generates synthetic payloads, not behavioral assertions. It is a data-generation step that feeds into downstream test runners, eval harnesses, and contract compliance checks. The prompt assumes you already have a tool contract to provide as input—it does not help you design or validate that contract.
Before using this prompt, ensure you have a complete tool contract ready, including argument schemas, output schemas, and a catalog of known error codes. Pair the generated mock responses with an agent behavior verification prompt to create a full test loop. Avoid using these mocks as the sole validation step for production deployment; always supplement with live integration tests and human review for high-risk or irreversible tool actions.
Use Case Fit
Where this prompt works, where it fails, and what you need before using it in a test harness.
Good Fit: Structured Contract Input
Use when: you have a formal tool contract (OpenAPI, JSON Schema, or typed function signature) and need realistic mocked responses for integration testing. Guardrail: validate that the input contract is complete—missing enum values or nullable fields will produce unrealistic mocks.
Good Fit: Edge-Case and Error Variant Generation
Use when: you need success, error, timeout, and boundary-case response variants from a single contract to build a comprehensive test suite. Guardrail: specify the exact failure taxonomy (4xx, 5xx, rate-limit, malformed) in the prompt constraints to avoid generic error responses.
Bad Fit: Undocumented or Implicit Tool Behavior
Avoid when: the tool has undocumented side effects, implicit state changes, or non-deterministic behavior not captured in its contract. Guardrail: pair this prompt with a manual review step for tools where the contract is incomplete or stale—mocked responses will inherit those gaps.
Bad Fit: Production Tool Simulation Without Isolation
Avoid when: you need to test against live tool behavior, network conditions, or real authentication flows. Guardrail: use this prompt only for offline test harnesses and CI pipelines—never as a substitute for staging-environment integration tests with real tool endpoints.
Required Input: Complete Tool Contract Schema
What to watch: missing field descriptions, undocumented nullability, or ambiguous enum semantics in the input contract will produce mocks that pass schema validation but misrepresent real tool behavior. Guardrail: run a contract validation prompt before this one to flag schema gaps, and include example payloads when available.
Operational Risk: Schema Drift Over Time
What to watch: tool contracts evolve, and mocked responses generated from stale schemas will silently diverge from production behavior, creating false confidence in agent tests. Guardrail: version-lock your tool contracts, regenerate mocks on contract changes, and add a contract-version field to every generated mock for traceability.
Copy-Ready Prompt Template
A reusable prompt template for generating realistic mocked tool responses from a tool contract schema, including success, error, and edge-case variants.
This prompt template is the core of your mock generation harness. It takes a tool contract schema—typically an OpenAPI snippet, a JSON Schema definition, or a structured description of inputs and outputs—and produces a catalog of mocked responses. The template is designed to be invoked programmatically, with placeholders that your test runner populates before sending the request to the model. The output is structured JSON that downstream validators can parse and compare against the original contract.
textYou are a test data generator for an AI agent's tool integration harness. Your job is to produce realistic mocked responses for a single tool, given its contract. You must generate responses that cover success, error, and edge-case scenarios. Every response must conform to the declared output schema. ## TOOL CONTRACT [TOOL_CONTRACT] ## OUTPUT SCHEMA [OUTPUT_SCHEMA] ## GENERATION CONSTRAINTS [CONSTRAINTS] ## EXAMPLES (Optional) [EXAMPLES] ## INSTRUCTIONS 1. Parse the TOOL CONTRACT to understand the tool's purpose, arguments, and expected output shape. 2. Generate a JSON array of mocked response objects. Each object must have the following structure: { "scenario_id": "string identifier for the test case", "scenario_type": "success | error | edge_case", "description": "human-readable description of what this mock simulates", "input_arguments": { /* arguments that would trigger this response */ }, "response_payload": { /* the mocked tool response, strictly conforming to OUTPUT_SCHEMA */ }, "expected_agent_behavior": "description of how the agent should handle this response" } 3. Generate at least [MIN_SCENARIOS] scenarios, distributed across scenario_types. 4. For error scenarios, use realistic HTTP-level or application-level error structures as defined in the contract. 5. For edge_case scenarios, include: empty results, maximum-length strings, boundary numeric values, null fields where optional, and unexpected but valid response shapes. 6. Ensure every response_payload validates against OUTPUT_SCHEMA. Do not invent fields. 7. If the contract defines pagination, include at least one multi-page scenario. 8. If the contract defines rate limiting or retry-after headers, include at least one rate-limit scenario. 9. Do not include destructive or state-mutating argument values unless explicitly allowed by [RISK_LEVEL]. 10. Output ONLY the JSON array. No markdown fences, no commentary.
To adapt this template, start by populating [TOOL_CONTRACT] with the raw API specification or a structured summary of the tool's behavior. The [OUTPUT_SCHEMA] placeholder should contain the exact JSON Schema or type definition that the tool's response is expected to match—this is what your compliance checker will validate against. Use [CONSTRAINTS] to inject domain-specific rules, such as 'never generate PII in mock data' or 'all IDs must be valid UUIDs.' The [EXAMPLES] placeholder is optional but valuable: include one or two hand-crafted mock responses to set the tone and structure the model should follow. Set [MIN_SCENARIOS] based on your coverage requirements—start with 5 for a quick smoke test, 15–20 for a thorough integration suite. The [RISK_LEVEL] placeholder should be set to low, medium, or high to control whether destructive argument values (deletes, writes, privilege changes) are included in the generated mocks. For high-risk tools, always set this to high and add a human review step before the mocks are used in any test that touches real systems.
Prompt Variables
Inputs required by the Mock Tool Response Generation Prompt Template. Each placeholder must be populated before the prompt can produce reliable, schema-compliant mocked responses.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TOOL_CONTRACT_SCHEMA] | The complete tool definition including name, description, input schema, and declared output schema | {"name": "search_docs", "parameters": {...}, "returns": {"type": "object", "properties": {...}}} | Must be valid JSON Schema or OpenAPI fragment. Parse check required before prompt assembly. Missing required fields in schema will cause mock generation gaps. |
[RESPONSE_VARIANTS] | List of response types to generate: success, error, edge-case, timeout, malformed | ["success", "error_4xx", "error_5xx", "empty_result", "oversized_payload"] | Must contain at least one variant. Each variant must map to a known tool failure mode. Null not allowed. Validate against allowed variant taxonomy. |
[VARIANT_COUNT_PER_TYPE] | Number of distinct mocked responses to generate per variant type | 3 | Integer between 1 and 10. Higher counts increase diversity but risk schema drift. Default to 3 if unspecified. Must be positive. |
[OUTPUT_FORMAT] | Target format for mocked responses: JSON, JSONL, or inline code block | "jsonl" | Must be one of: json, jsonl, codeblock. JSONL preferred for batch test ingestion. Validate against allowed enum before prompt execution. |
[SCHEMA_STRICTNESS] | Whether mocked responses must strictly conform to output schema or may include intentional violations for negative testing | "strict" | Must be strict or relaxed. Strict enforces full schema compliance. Relaxed allows intentional type mismatches and missing fields for validation test scenarios. Default to strict. |
[SEED_VALUE] | Optional seed for deterministic mock generation across test runs | 42 | Integer or null. When provided, enables reproducible test suites. When null, generation is non-deterministic. Validate as integer or null before passing to prompt. |
[DOMAIN_CONTEXT] | Optional domain-specific context to make mocked responses realistic for the tool's purpose | "e-commerce product catalog with categories, prices, and inventory counts" | String or null. When provided, mocked field values should reflect domain-appropriate data. When null, generic placeholder values are used. Length should not exceed 200 characters to avoid prompt bloat. |
[ERROR_TAXONOMY] | Custom error taxonomy mapping error codes to expected response shapes for this tool | {"404": {"body": {"error": "string", "code": "NOT_FOUND"}}, "429": {"body": {"error": "string", "retry_after": "integer"}}} | Must be valid JSON object or null. When provided, error variants must conform to this taxonomy. When null, generic HTTP error shapes are used. Validate structure before prompt assembly. |
Implementation Harness Notes
How to wire the mock tool response generation prompt into an automated test harness with validation, retries, and schema compliance checks.
The mock tool response generation prompt is designed to be called programmatically as part of a CI/CD pipeline or pre-release test suite. You will typically invoke it once per tool contract, requesting a batch of responses that cover success, error, and edge-case variants. The prompt expects a structured tool contract as input—usually a JSON Schema or OpenAPI fragment—and returns a JSON array of response objects. Wire this into your test harness by first loading the tool contract from your API spec or tool registry, then constructing the prompt with the contract injected into the [TOOL_CONTRACT] placeholder and the desired variant count in [VARIANT_COUNT]. The model should be instructed to return only valid JSON matching the declared output schema, with no additional commentary.
After receiving the generated responses, run each one through a schema compliance validator that checks: (1) the response parses as valid JSON, (2) all required fields from the tool contract's output schema are present, (3) field types match the declared types, (4) enum fields contain only allowed values, and (5) no extra fields appear unless the schema permits additional properties. For error variants, validate that the error structure matches your standard error envelope (e.g., error.code, error.message, error.retryable). Log any schema violations and flag the generated response for manual review or regeneration. If more than 10% of generated responses fail validation, retry the prompt with a stricter [CONSTRAINTS] block that explicitly forbids schema deviations and provides a counterexample of a malformed response.
For production-grade harnesses, store each generated mock response alongside its expected agent behavior contract—the assertion that defines how the agent should react when it receives this response. This pairing enables automated end-to-end tests where the mock is injected into the agent's tool call layer and the agent's subsequent action is compared against the expected behavior. Use a model with strong JSON mode support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and set temperature between 0.7 and 0.9 to ensure response diversity across variants. For high-risk tool contracts (write operations, financial transactions, PII access), always include a human review step before mock responses are committed to the test suite. Finally, version-lock your generated mocks alongside the tool contract version they were generated from, and regenerate them whenever the contract's output schema changes—stale mocks are the most common source of false-positive agent behavior tests.
Expected Output Contract
Defines the required fields, types, and validation rules for each mocked tool response generated by the prompt. Use this contract to build automated validation gates before responses are injected into agent test harnesses.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
response_id | string (UUID v4) | Must match UUID v4 regex. Uniquely identifies the mocked response instance. | |
tool_name | string | Must exactly match a tool name from the provided [TOOL_CONTRACT] schema. Case-sensitive. | |
variant_type | enum: success | error | edge_case | Must be one of the three allowed enum values. Reject any other string. | |
status_code | integer | Must be a valid HTTP status code (100-599). For non-HTTP tools, use 0 and validate against [TOOL_CONTRACT] conventions. | |
response_body | object | Must parse as valid JSON. Structure must conform to the output schema declared in [TOOL_CONTRACT] for the specified tool_name. | |
response_headers | object | If present, keys must be lowercase strings. Values must be strings. Null allowed. | |
latency_ms | integer | Must be a non-negative integer. For timeout edge cases, set to value exceeding [TIMEOUT_THRESHOLD_MS]. | |
error_code | string or null | Required when variant_type is 'error'. Must match a known error code from [ERROR_CATALOG] or be null for success/edge_case variants. |
Common Failure Modes
Mock tool responses fail silently when they drift from the contract, lack diversity, or mask edge cases the agent will encounter in production. These are the most common failure modes and how to prevent them.
Schema-Compliant but Semantically Wrong
What to watch: The mock passes JSON Schema validation but contains impossible values—negative quantities, future dates for past events, or IDs from the wrong namespace. The agent learns to trust structurally valid garbage. Guardrail: Add semantic validation rules per field. For example, check that total equals unit_price * quantity, or that created_at is not after updated_at. Run these checks alongside schema validation before the mock is served.
Uniform Happy-Path Responses
What to watch: Every mock returns a perfect 200 with complete, well-formatted data. The agent never practices handling partial results, null fields, or error codes, so it hallucinates data when the real tool returns a 422 or a truncated response. Guardrail: Generate a response catalog that includes at least one 4xx, one 5xx, one timeout, one empty result set, and one partial-success per endpoint. Randomize which variant is served during test runs.
Stale Mock Drift from Live Contract
What to watch: The tool provider adds a required field, changes an enum value, or deprecates an endpoint. The mock stays frozen, so tests pass while production agents fail with real schema violations. Guardrail: Version-lock mocks to a specific tool contract hash. Run a pre-test check that compares the mock's schema fingerprint against the current live contract. Fail the test suite if a drift is detected, and flag the mock for regeneration.
Missing Idempotency Simulation
What to watch: The mock returns a fresh result on every call, even with the same idempotency key. The agent never learns to handle duplicate responses or detect that a retry succeeded on the first attempt. In production, this causes double-writes and incorrect state assumptions. Guardrail: Implement idempotency-key-aware mocking. When the same key is sent, return the identical response—including the same timestamp and resource ID—and verify the agent does not treat it as a new event.
Overly Deterministic Edge Cases
What to watch: The mock always returns the same error on the third call, or always times out after exactly 5 seconds. The agent overfits to the pattern and fails when real failures are stochastic or correlated with payload size rather than call sequence. Guardrail: Introduce probabilistic failure injection. Configure error rates per endpoint (e.g., 5% timeout, 2% 503) and vary latency within realistic percentiles. Log the injected failure distribution so test outcomes are reproducible and debuggable.
Unbounded Response Payloads
What to watch: The mock returns a 2MB JSON array with 10,000 items because no limit was specified. The agent's context window overflows, or it silently truncates the response and reasons over incomplete data. Guardrail: Enforce response size caps in the mock generator. Default to paginated responses with a next_cursor field. Test that the agent correctly requests subsequent pages or handles truncation markers rather than assuming it received the full dataset.
Evaluation Rubric
How to test output quality before shipping. Use this rubric to evaluate mock tool responses generated by the prompt template against schema compliance, diversity, and realism criteria.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Schema Compliance | Every generated response validates against the provided [TOOL_OUTPUT_SCHEMA] with zero type mismatches, missing required fields, or unexpected fields | JSON Schema validator returns errors; required field [FIELD_NAME] is missing; field [FIELD_NAME] has type string instead of integer | Run jsonschema.validate() on each generated response; count violations per variant |
Response Variant Coverage | At least one success variant, one error variant, and one edge-case variant are present in the output for each tool endpoint | All generated responses are success-only; no error codes appear; edge cases like null fields or empty arrays are absent | Classify each response by variant type; assert count(success) >= 1 AND count(error) >= 1 AND count(edge_case) >= 1 |
Error Code Realism | Error variants use HTTP status codes or error types declared in [TOOL_ERROR_CATALOG]; error messages match the tool's documented error format | Error response contains status 200 with error body; error code 999 appears; error message is generic 'something went wrong' with no tool-specific context | Parse error responses; verify status code in [400, 401, 403, 404, 409, 422, 429, 500, 502, 503]; check error message against [TOOL_ERROR_CATALOG] patterns |
Field-Level Null Handling | Nullable fields in [TOOL_OUTPUT_SCHEMA] are exercised with null values in at least one edge-case variant; required fields are never null | Required field [FIELD_NAME] is null in a generated response; nullable field [FIELD_NAME] is never shown as null across all variants | For each field in schema: if required is true, assert field is not null in all responses; if required is false, assert null appears in at least one edge-case response |
Response Diversity Score | No two generated responses are identical; field values differ meaningfully across variants rather than changing only one field | Two success variants have identical bodies; only the errorCode field differs between error variants; edge-case variant is a copy of success with one field removed | Compute pairwise Jaccard similarity on response bodies; assert max similarity < 0.9; spot-check that at least 3 fields differ between any two variants |
Argument-Response Consistency | Generated responses are consistent with the [SAMPLE_ARGUMENTS] that would produce them; success responses contain data matching the requested resource ID | Response contains resource ID [DIFFERENT_ID] that does not match the [SAMPLE_ARGUMENTS] request; response data describes a different entity than requested | Extract resource identifiers from [SAMPLE_ARGUMENTS]; verify response body references match; flag any identifier mismatch |
Latency and Size Realism | Response payload sizes fall within [MIN_RESPONSE_BYTES] and [MAX_RESPONSE_BYTES]; no response exceeds 10x the typical size for the endpoint | A list endpoint returns 10,000 items when typical max is 100; a single-record response is 5MB; response is empty object {} with no explanation | Measure byte length of each response body; assert MIN_RESPONSE_BYTES <= size <= MAX_RESPONSE_BYTES; flag outliers > 3 standard deviations from mean |
Idempotency Key Echo | When [IDEMPOTENCY_KEY] is provided in arguments, success responses echo the key in the appropriate header or body field per the tool contract | Idempotency key is ignored in response; response contains a different idempotency key; key appears in error responses where it should not | Parse response for idempotency key field; assert response.idempotencyKey equals [IDEMPOTENCY_KEY] for success variants; assert absent for error variants unless contract specifies otherwise |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single tool contract and lighter validation. Focus on generating the three core variant types (success, error, edge-case) without strict schema enforcement. Accept any structurally plausible JSON as valid output.
Prompt modification
- Remove or relax the
[OUTPUT_SCHEMA]constraint toGenerate responses that look like plausible tool outputs. - Reduce
[VARIANT_COUNT]to 3–5 per contract. - Skip the eval criteria section entirely.
Watch for
- Responses that drift from the tool's declared argument shape
- Missing error codes or HTTP status conventions
- Overly narrow edge cases that miss real failure modes

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us