DevTools Logo

Tool Call Mock Responder

Tool Call Mock Responder

Paste a tool JSON Schema and generate valid mock responses, boundary cases and error envelopes for a replay harness.

Runs in your browser
Try an example

Tool JSON Schema

empty · draft-07 subset

Generation is local and deterministic. Samples are inert data — nothing is executed or replayed.

Generated responses

0 case(s) · 0 sample(s)

No schema pasted

Load the weather tool schema to see happy, boundary and error responses.

Examples

Weather response

Input
required: location, temp_c, units
Output
{"role":"tool","content":"{\"location\":\"Paris\",...}"}

The example location, first enum member and numeric bounds are respected.

Enum pinning

Input
anyOf with three status values
Output
branch 1 → pending

Set the branch field to force a specific member through your loop.

Recursive schema

Input
$ref pointing back at a tree node
Output
Empty leaf after depth 6

A cycle guard stops generation and emits a warning chip instead of looping forever.

Invalid pattern

Input
pattern with a lookahead
Output
Fixed 'sample' string with unverified warning

The bounded sampler only claims verification when a generated string actually matches the regex.

About this tool

The Tool Call Mock Responder turns a pasted tool JSON Schema into the responses a model or tool would actually exchange: a happy-path instance, labeled boundary cases, error envelopes and seeded JSONL samples. A recursive walker materializes values for const, enum, example, default, required, items, properties, formats and numeric or string constraints.

Generated cases are round-checked by a small validator that covers the supported draft-07 subset. When a constraint cannot be satisfied — an unsamplable regex, a recursive reference, a required key missing from properties — the sample is still shown with a visible warning instead of failing silently. anyOf and oneOf branches can be pinned, and local $ref pointers resolve with a cycle guard.

Instances can be wrapped as an OpenAI-style role: tool result or as an assistant tool_calls message, and error presets cover OpenAI, Anthropic and generic shapes. Everything is produced locally from a seed: no model call, no network request, no execution of the generated data.

What this tool does not do

  • Only a draft-07 subset is supported; full JSON Schema validation and unevaluated keywords are out of scope.
  • The regex sampler covers literals, character classes, alternatives and simple quantifiers, not lookarounds or backreferences.
  • Recursive schemas are cut off at depth 6 rather than expanded infinitely.

How to use this tool

  1. Paste a schema

    Load the weather example or paste your own draft-07 subset. Parse errors report a JSON pointer near the offending node.

  2. Set generation controls

    Choose a seed, a sample count, an anyOf/oneOf branch and whether to wrap output as a tool result or assistant tool call.

  3. Review the cases

    Read the happy path, boundary cards and error envelopes; constraint warnings and violations appear under each card.

  4. Export samples

    Show the JSONL samples, then copy or download up to 1000 records for a deterministic replay harness.

Use cases

Local harness scaffolding

Test tool dispatch without a live API key or network round trip.

QA smoke tests

Exercise happy, empty, maximal and error paths through the same schema in one pass.

Function-calling demos

Prepare canned tool traffic for a course or walkthrough with reproducible output.

Generated artifacts

CardContents
Happy pathRequired properties with enums, examples and formats honored
BoundariesMinimal, maximal, zero/empty, first enum and last enum cases
ErrorsOpenAI tool error, Anthropic tool_result error, generic envelope and timeout

Each card is wrapped in the selected message role, so the output is directly usable as canned harness traffic.

Common mistakes

Mistake:Expecting the tool to validate the schema with full JSON Schema semantics.

Fix:A small validator covers the common draft-07 subset; 2020-12-only keywords are ignored by design.

Mistake:Pasting a schema whose required keys are not declared in properties.

Fix:The generator emits a null key with a warning; declare the property for a meaningful sample.

Mistake:Assuming generated samples are unique.

Fix:The seed guarantees reproducibility, not variety; inspect the JSONL before using it as a diversity test.

Frequently asked questions

How do I mock a function call response for OpenAI?

Paste your tool's JSON Schema, choose 'role: tool result' and copy the happy-path card. It emits an object with role, tool_call_id and a JSON-stringified content payload, matching what an OpenAI-style loop expects after a tool call. Choose 'assistant tool_calls' instead if you need to simulate the model side of the exchange.

Does it respect required fields and enums?

Yes. The walker fills required properties, uses const/example/default before synthesizing, takes the first enum value on the happy path and offers first/last enum boundary cases. A built-in validator checks the result against types, lengths, numeric bounds, patterns and required lists, and labels any violation.

Can it generate error responses?

Yes. Four presets are included: an OpenAI tool error with is_error, an Anthropic tool_result error envelope, a generic {error:{code,message,details}} shape and a timeout envelope. Edit the message field once and all presets update.

How does it handle $ref and anyOf?

Local #/ pointers are resolved within the pasted document, with a depth cap and cycle guard that emit an empty leaf plus a warning for recursive structures. For anyOf or oneOf, set the branch field to pin a specific alternative; otherwise a seeded choice is made.

Is the data generated locally?

Completely. Schema parsing, generation, validation and export run in this tab with no dependency on a full validator library. Samples are inert data: nothing is evaluated, executed or replayed from this page.

Can I get many samples for a replay script?

Yes. Set a seed and a count up to 1000, then show or download the JSONL stream — one generated instance per line. The same seed and branch always produce the same stream, which makes replay runs comparable.