Interview Prep/Agentic AI/Prompting & structured outputs

The model keeps adding extra text around the JSON you asked for. How do you fix it?

IntermediateScenarioPrompting & structured outputs
Answer

Use schema-enforced output mode if the API supports it. Otherwise say "Return only JSON, no explanation", show an example of the exact output, and parse defensively by extracting the first JSON object. Add a validation step that retries on failure.

All Agentic AI questions Roadmap: LLM fundamentals & RAG

More on Prompting & structured outputs