A prompt is the text placed in front of a language model to make it do a task. Prompting is the practice of writing that text. Structured output is the narrower problem of getting a reply that a program can use directly, such as JSON that fits a schema, code that compiles, or one label from a fixed list. A model produces free text one token at a time, and most software around it needs something stricter, so the two problems usually travel together.
People write and test prompts by hand, or let an optimizer search for better ones. For structure, the options run from describing a format in the prompt and checking the reply, to constrained decoding, which changes how tokens are picked so that only output a grammar or type system allows can come out. Stricter formats are easier for programs to use, but research shows they can cost the model accuracy.
Prompting
The early techniques came from studying few-shot prompts, where a prompt includes a handful of worked examples. In 2021, Zhao et al. showed that this kind of prompting with GPT-3 was unstable. The format, the choice of examples and even their order could move accuracy from near chance to near the state of the art. They traced it to the model's bias toward certain answers, such as ones placed near the end of the prompt, and corrected for it by measuring the model's answer to an empty input like "N/A".[3] In 2022, Wei et al. found that showing a large model worked examples with intermediate reasoning steps, a method they called chain-of-thought prompting, improved its arithmetic, commonsense and symbolic reasoning. Eight such examples took a 540-billion-parameter model to the best published score on a set of grade-school math word problems.[2]
Many variations followed. Self-Discover has the model pick reasoning modules, such as critical thinking or step-by-step thinking, and assemble them into a plan before it answers. Its authors report gains of up to 32% over chain of thought on hard reasoning benchmarks, and beat methods that sample many answers and vote, with 10 to 40 times less compute.[6] Skeleton-of-Thought asks for an outline first and then fills in every point in parallel, to cut response time.[7] EmotionPrompt adds emotional phrases to a prompt and reports gains in tests on 45 tasks.[4] A 2024 survey, The Prompt Report, counted 58 text-only prompting techniques and 40 more for images, audio and other media.[1]
Careful testing makes many of these results look fragile. A 2025 report by Meincke et al. found that the scoring standard chosen for a benchmark can change how good a model appears, and that it is hard to know in advance whether a technique will help on a given question. Politeness toward the model helped on some questions and hurt on others. Constraining the answer did the same.[5]
Prompt optimization
Because hand-tuning is slow and its results carry over poorly, optimizers search for prompts automatically. GEPA, published by Agrawal et al. in 2025, runs a system on a task, has a model read the full record of what happened, including its reasoning and tool calls, and proposes changes to the prompt in plain language. It keeps a set of candidates that each do best on some examples and combines lessons from them. Across six tasks it beat GRPO, a common reinforcement learning method, by 6% on average while using up to 35 times fewer runs.[8]
The method spread fast among people who build agents. In April 2026, Nous Research released a system that uses GEPA to improve the skills, prompts and tool descriptions of Hermes, Nous Research's own agent, without retraining the model,[9] and a fork of Pi gave each model a GEPA-optimized prompt made for it.[10]
Structured output
Asking nicely and checking
The simplest way to get structured output is to describe the format in the prompt, then parse and validate what comes back. TypeChat, a Microsoft library, makes the schema a set of TypeScript types. It builds the prompt from the types, checks the reply against them, and asks the model to repair any reply that fails.[18] AskIt, a research language for calling models from code, also uses types to control output, and its authors report that across 50 tasks the prompts it generated were about 16% shorter than the prompts the benchmark tasks came with.[19] The weakness of the check-and-retry approach is that it catches errors only after the tokens are generated. A retry costs another model call, so the cost of serving a single request is no longer fixed.[17]
Constrained decoding
Constrained decoding moves the check into generation itself. At each step the decoder removes, or masks, every token that would make the output invalid, so the model can only continue in ways the format allows. This needs access to the model's token probabilities, which in 2023 meant open-weight models run locally. The llama.cpp inference engine added grammar-based sampling that takes a grammar written in a notation like BNF, the standard format for writing down a language's syntax rules, and masks tokens that would break it. Writing those grammars by hand is tedious, so tools such as gbnfgen generate them from TypeScript interfaces.[17] Hosted APIs offered function calling instead, which asks the model for JSON that fits a schema but in 2023 did not guarantee valid JSON.[17]
Grammars can cover more than JSON. Type-constrained decoding, from 2025, extends the idea to the type system of a general-purpose language. On TypeScript it cut compilation errors by more than half.[15]
Format also affects cost. JSON spends tokens on braces, quotes and repeated key names. One paper defines a compact shorthand with a grammar that converts it to and from the full format, and reports 3 to 5 times fewer generated tokens.[16] Super JSON Mode splits a schema into fields and generates them in parallel, which it reports as up to ten times faster than generating the whole object in one pass.[20] In an August 2026 exchange on output formats, I pointed out that YAML can be streamed and agreed that JSONL, one JSON object per line, works well.[21][22]
Costs and criticism
Strict formats can make a model worse at the task itself. Tam et al. found a significant drop in reasoning when models had to answer in formats such as JSON or XML, and the stricter the format, the larger the drop.[14]
Grammars and types guarantee only the shape of a reply. A reply that fits the schema can still hold a wrong value, and a classifier that always returns a valid label can still pick the wrong one. Constrained decoding also depends on access to the model's probabilities, which hosted models expose only as far as their providers choose.
Prompt optimizers have a cost of their own. An optimized prompt is tuned to one model and one set of examples, so it has to be optimized again when either changes, and it needs a scored set of examples to optimize against.
My position
I treat prompting as part of fitting a system to a model. Once I pick a model, I try optimizing the prompts and the harness for it, because models often respond to their own specific tweaks.[13] That is why prompt optimizers interest me. I have pointed people to GEPA on X since August 2026,[11] and in November 2026 I asked whether anyone had used it to make GPT 6.2 Sol, OpenAI's model, behave more like Gemini Neon or Claude Opus.[12] Some behaviors still resist prompting, such as getting a model to write plainly (Writing for people and for agents).[26]
For agents, the prompts that matter most are now long and spoken, and by June 2026 I dictated most of mine (Writing for people and for agents covers how).[25] Some go further and argue that people should stop prompting coding agents by hand and design loops that prompt them instead.[27]
When a program needs a decision instead of prose, I reach for a judgment model before a prompt that asks for JSON. Asking a large model to classify is slow and expensive, and its output is text that has to be coaxed into structure. A judgment model returns machine-readable answers without training, though a classifier trained for a fixed, high-volume task is still cheaper.[23][24] I used one to decide when a message should interrupt a busy agent. It answered much faster than an agent session did, but it was too cautious at first and I had to retune it (A small model decides when to interrupt).
Open questions
- Will hosted models expose enough of their decoding for grammar and type constraints to work as well as they do on local models?
- How often does an optimized prompt need to be redone as models change, and is that cheaper than fine-tuning?
- Which formats keep the parsing benefits of structure while losing the least reasoning accuracy?
History and timeline
- 2021: Zhao et al. show that few-shot prompts are unstable and propose calibrating for answer bias.[3]
- 2022: Wei et al. publish chain-of-thought prompting.[2]
- 2023: Skeleton-of-Thought[7] and EmotionPrompt[4] appear. llama.cpp adds grammar-based sampling, and tools generate its grammars from types.[17]
- 2024: The Prompt Report surveys the field[1] and Tam et al. measure the reasoning cost of strict formats.[14]
- 2025: GEPA is published[8] and Meincke et al. find prompting effects contingent.[5] Type-constrained decoding is published.[15]
- Jun 2026: I dictate most of my prompts.[25]
- Oct 2026: I write about judgment models as an alternative to prompting for structured decisions.[23]
- Nov 2026: I ask about using GEPA to change a model's style.[12]
See also
Change log
- 2026-12-03: First written, from my posts on X about prompts, dictation and GEPA, my post on system one models, and papers on prompting and constrained decoding.
Reading
References
- ^ Schulhoff et al., The Prompt Report: A Systematic Survey of Prompting Techniques
- ^ Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- ^ Zhao et al., Calibrate Before Use: Improving Few-Shot Performance of Language Models
- ^ Li et al., Large Language Models Understand and Can be Enhanced by Emotional Stimuli
- ^ Meincke et al., Prompting Science Report 1: Prompt Engineering is Complicated and Contingent
- ^ Zhou et al., Self-Discover: Large Language Models Self-Compose Reasoning Structures
- ^ Ning et al., Skeleton-of-Thought: Prompting LLMs for Efficient Parallel Generation
- ^ Agrawal et al., GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
- ^ Hermes agents improve their own skills and prompts with GEPA, no GPU training (@RajaPatnaik, Apr 2026)
- ^ A fork of Pi that gives each model its own GEPA-optimized prompt (@anthonyronning, Apr 2026)
- ^ Wait till you learn what GEPA is (@trashpandaemoji, Aug 2026), since deleted
@unclebobmartin Wait till you learn what GEPA is
- ^ Has anyone tried to GEPA Sol 6.2 to be more like Neon or Opus? (@trashpandaemoji, Nov 2026)
- ^ Once you pick a model, optimize the prompts and harness for it (@trashpandaemoji, Jul 2026), since deleted
@jamonholmgren I’ve been doing this for Deepseek v4 Flash. Once you pick a model, you can try optimizing the prompts and harness for better results. Often models have specific tweaks to get better perf out of them.
- ^ Tam et al., Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Models
- ^ Mündler et al., Type-Constrained Code Generation with Language Models
- ^ Kanyuka and Mahfoud, Domain-Specific Shorthand for Generation Based on Context-Free Grammar
- ^ Intrinsic Labs, Grammar-guided generation with open source models (Aug 2023)
- ^ Microsoft, TypeChat
- ^ Okuda and Amarasinghe, AskIt: Unified Programming Interface for Programming with Large Language Models
- ^ Varun Shenoy, Super JSON Mode
- ^ You can stream YAML (@trashpandaemoji, Aug 2026), since deleted
@rickasaurus You can stream YAML
- ^ JSONL is quite nice (@trashpandaemoji, Aug 2026), since deleted
@rickasaurus Fair, jsonl is quite nice
- ^ Are system one models worth the hype? (post, Oct 2026)
- ^ System one models: a cheap classifier you don't have to train (@trashpandaemoji, Oct 2026)
- ^ From zero dictation to dictating 80% of my prompts (@trashpandaemoji, Jun 2026), since deleted
I went from zero dictation to dictating like 80% of my prompts. Its crazy.
- ^ The hoops we jump through to get superintelligence to write like a stupid ape (@trashpandaemoji, Oct 2026), since deleted
the hoops we need to jump through to get super intelligence to write like a stupid ape
- ^ Design loops that prompt your agents (@steipete, Jun 2026)