Copilot Studio Friction
"A JSON could not be generated. Edit your prompt instruction…"
Last verified
Details & related
Assessment
- Confidence
- Confirmed officialConfirmed by Microsoft documentation or an official statement.
- Severity
- Blocking
- Typical time lost
- Hours
Identification
Verification & changes
Verified
Doc check by human: Official JSON output and prompt performance pages re-read during seed migration; error text, metadata-wrapping cause and slim-structure guidance still documented.
Change
Provisionally approved by the Product Owner; external LLM quality review pending.
Change
Initial record created from the seed dossier (migration wave 1).
Are you in the right place?
- You built a prompt tool with its output set to "JSON".
- Testing it fails with
A JSON could not be generated. Edit your prompt instruction and try again.in the prompt builder. - The same prompt works when the output is set to "Text".
- The error returns no matter how often you retry.
If instead the JSON works but never reflects your later edits → see the format-freeze record (record planned). If instead users see raw JSON in the chat → see Chat shows raw JSON instead of an answer. If instead the prompt output can't be selected in your topic → see the disabled-output record (record planned).
What's happening
Copilot Studio does not enforce your JSON structure as a strict schema. It infers the format from your example, then checks each response against it. The error appears when the model wraps its JSON in extra text or metadata. The platform then cannot verify the requested format and gives up. Think of a form scanner: it rejects the page when someone scribbles notes in the margins. Two things raise the failure odds: vague instructions that invite commentary, and complex structures with many keys. Official guidance says unnecessary structure also increases cost and latency (documented as of 2026-07-08). So the same cleanup that fixes the error makes the prompt cheaper and faster.
For technicians
The official JSON output documentation names this error and its cause: model output wrapped with metadata prevents format verification.
There is no response_format-style schema constraint; the format is example-based inference.
Once you edit the JSON example manually, the format becomes "Custom" and freezes.
It then never updates from later tests; the generated JSON schema is viewable but not editable (documented as of 2026-07-08).
How to fix it
Solution 1
Official workaroundSharpen the prompt instruction
- In Copilot Studio, open "Tools".
- Open the failing prompt.
- In the instruction, state the exact fields you expect.
- Remove any wording that invites explanations or commentary around the output.
- Select "Test".
✅ You should now see: a JSON response in the test output, without the error.
Solution 2
Official workaroundSlim down the JSON structure
- Remove every key your agent does not use afterwards.
- Flatten nested objects where a flat field carries the same information.
- Shorten example values to realistic, minimal content.
- Select "Test" again.
✅ You should now see: the error gone — and faster, cheaper responses as a side effect.
Check that it worked
Run "Test" in the prompt builder with three different realistic inputs. Expected: every run returns JSON with your keys and no error. Then call the prompt from your agent in the test pane.
If it didn't work
- The instruction still invites prose. Wording like "explain your reasoning" pushes the model into commentary. Cut it.
- The structure is still too ambitious. Halve the keys and retest. Grow the structure back step by step.
- Your manual edits froze the format as "Custom". Frozen formats never update from tests again (record planned). Re-lock the format deliberately after structure changes.
- The published agent still fails. Channels can serve an old version after edits. See Teams answers with an old version of your agent.
Prevent it next time
- Start every JSON output with the smallest structure that works — slim structures fail less and cost less.
- Treat instruction and structure edits like code changes: retest the prompt after each one.
- Plan a deliberate re-lock step whenever your JSON structure evolves.
Evidence
Official documentationlearn.microsoft.com
The JSON output documentation names the error verbatim and attributes it to the model wrapping the JSON with metadata that prevents format verification.
Official documentationlearn.microsoft.com
Official performance guidance recommends simplifying the JSON structure and minimizing keys because unnecessary content increases cost and latency.