Prompts are instructions. What AI systems actually need are contracts.
When you talk to a modern AI system, you are not really talking to a machine. You are talking to a boundary: a thin, poorly defined seam between two fundamentally different kinds of computation. On one side sits a neural network, a vast statistical engine that has learned to predict plausible sequences of words. On the other side sits a symbolic system, a rule-following processor that needs discrete, well-formed, unambiguous inputs to function. The seam between them is where most of the real engineering happens, and today, that seam is held together with words. With prompts. And that turns out to be a serious problem.
Every major AI system in production today is, at some level, a hybrid. A neural component does the heavy lifting of perception, language, or pattern recognition, and a symbolic component handles the parts that require explicit logic: searching a database, verifying a mathematical step, executing code, enforcing a policy. What gets far less attention than either component is the interface between them: the moment when neural output has to become symbolic input.
That handoff is extraordinarily difficult to specify. Neural networks speak in probabilities and high-dimensional vectors; symbolic systems need discrete tokens, typed structures, and well-formed logical expressions. When a language model generates text that a downstream system will parse and act on, the system cannot tolerate approximation the way a human reader can. A misplaced comma, an unexpected field name, or a hallucinated key in a JSON object can cascade through an entire pipeline and produce failures that are both catastrophic and silent. The seam, in other words, has to be exact, and right now, most teams are managing that exactness by asking the model nicely.
The dominant technique for controlling what comes out of a neural network is the natural-language prompt: a paragraph of instructions, examples, and constraints written in plain English and prepended to every query. For many applications this works well enough to ship. But "works well enough to ship" is not the same as "constitutes a reliable interface," and over the past two years a body of empirical research has made the gap between those two things very precise. A study spanning researchers at the University of Washington, AI2, and UC Berkeley found that in few-shot settings, cosmetic formatting changes alone, things as minor as how example answers were arranged on the page, swung one model's accuracy by up to 76 percentage points. The model's underlying capability had not changed at all. The interface had.
The field of programming languages solved this class of problem a long time ago, and the solution has a name: a grammar. When Backus–Naur Form was introduced to specify the syntax of ALGOL 60 in the early 1960s, it gave compilers something they had previously lacked: a formal contract between human intent and machine execution that was independent of any particular implementation. The grammar was not a comment in a file or a convention that developers were expected to honor. It was a machine-readable specification that could be mechanically checked, automatically enforced, and evolved according to explicit rules.
The durability of that idea is remarkable. BNF and its extensions remain the standard notation for specifying programming language grammars more than six decades later, long after the hardware those grammars first targeted became obsolete. LLVM's intermediate representation, introduced in 2003, operates on the same principle at a different layer of the stack: it is a formally specified language that acts as the stable contract between compiler frontends, which handle human-readable source code, and compiler backends, which target specific processors. The frontend and the backend can evolve independently because the IR between them has a defined structure and explicit rules governing how that structure can change. Neither side needs to know anything about the other's internals.
Protocol Buffers, Google's schema definition language, extends this logic to distributed systems. A .proto file specifies the types and field numbers of every message that flows between services, and it comes with explicit evolution rules: new fields can be added, but field numbers can never be reused, because that number is the stable identifier that both sides of the wire agree on. This means that a service written years ago can still exchange messages with a service written today, because the contract, not the implementation, is what matters. The lesson that compilers and distributed systems both arrived at independently is the same: what survives is not the code, not the model, and certainly not the wording. What survives is the interface.
The reason prompt brittleness is more than an inconvenience is that in modern AI pipelines, prompts have become structurally load-bearing. They are not just instructions; they are the only specification that many systems have for what the neural component is supposed to produce. When the model is upgraded, the prompt has to be rewritten. When the task changes, the prompt has to change. When a downstream system needs a slightly different output format, the prompt has to change. There is no versioned artifact, no compatibility guarantee, and no machine-checkable contract. There is only text.
A 2026 study that the field is calling Brittlebench made the structural fragility measurable in a new way. Researchers found that semantics-preserving perturbations (changes that do not alter the meaning of a question but alter its phrasing, punctuation, or structure) degraded frontier model performance by as much as 12 percent and, more troublingly, shifted relative rankings between models in 63 percent of cases. That last finding has significant implications for anyone relying on benchmarks to choose between AI systems: the leaderboard is partly a measure of prompt sensitivity, not just capability. What looks like a difference in intelligence is sometimes a difference in how gracefully a model handles the specific words used to interrogate it.
The contrast with typed interfaces is not subtle. A typed function signature in a programming language specifies not just what a function should do but what it is allowed to receive and what it is required to return. If the input does not match the declared type, the compiler rejects it before any execution happens. If the output does not match, the same. There is no ambiguity about whether the interface was honored, and there is no runtime surprise when it was not. Prompts have none of these properties. They are not composable in the way function signatures are; they do not version-contract the way APIs do; and their effect on a model's output distribution is neither deterministic nor auditable. Engineers building production systems on top of language models have begun to describe this situation in terms that would be familiar to any systems architect: they are building load-bearing structures on foundations that have no spec.
The most direct engineering response to this problem draws explicitly on the compiler analogy. Grammar-constrained decoding works by restricting a language model's output to strings that conform to a formal grammar, whether a context-free grammar, a JSON schema, or a regular expression, enforced at the token level as the model generates. At each decoding step, any token that would produce a string not accepted by the grammar is masked out, making it impossible for the model to emit malformed output regardless of what its unconstrained distribution would have produced. The mechanism is deliberately compiler-like: the model's tokenizer plays the role of the lexer and the grammar plays the role of the parser.
The engineering results have been striking. A constrained-decoding engine called Outlines, developed by the team at dottxt, compiles JSON schemas into finite-state machines so that token masking requires near-constant-time lookup rather than expensive revalidation at every step. According to figures published by the AWS Machine Learning Blog, the approach achieves 98 percent schema adherence compared to 76 percent for post-generation validation, while roughly doubling throughput. XGrammar, a system built at Carnegie Mellon's machine learning group, extends this to general context-free grammars with what the team describes as near-zero overhead, reporting speedups of up to 100 times over prior approaches and token-mask generation times under 40 microseconds. OpenAI integrated a version of the same principle into its Structured Outputs API in 2024: on a benchmark of complex JSON-schema compliance, the constrained model scored 100 percent, compared to under 40 percent for the prior generation of the same model without constraints.
But the researchers working on this have identified a boundary condition that matters. Constrained decoding guarantees structural validity; it does not guarantee semantic quality. A formally compliant JSON object can still contain hallucinated values, logically inconsistent fields, or reasoning that went wrong before the formatting constraints kicked in. Work presented at NeurIPS in 2024 formalized the problem: naive token masking distorts the model's learned probability distribution, so the outputs it is steered toward are not proportional to the outputs it actually assigns high probability to. The result is grammatically perfect but potentially degraded in quality. A subsequent system called CRANE showed that overly tight grammars can suppress reasoning capability, and that augmenting the grammar with rules that preserve reasoning-friendly structure recovers up to 10 percentage points of accuracy on symbolic benchmarks. The grammar is necessary, but it has to be designed with the same care as any other load-bearing component.
Grammar-constrained decoding treats the language model's tokenizer as a lexer and its output grammar as a parser, borrowing directly from compiler architecture to enforce structural validity at the neural-symbolic boundary.
The deepest version of this project is not about output formatting. It is about giving the neural-symbolic boundary the same status in software architecture that type systems and API contracts have always had: a first-class, versioned, machine-enforceable specification that outlives any particular model, any particular prompt, and any particular version of the downstream system.
MIT's probabilistic programming system Gen, whose core design was published at the Programming Language Design and Implementation conference in 2019 and has been actively developed since, approaches this through what its designers call the Generative Function Interface. Any component in a Gen system, whether it is a deep neural network, a hand-coded simulator, or a probabilistic model, must implement the same formal interface: sampling, density evaluation, gradient computation, and trace manipulation. The execution trace, an abstract data type with defined operations and user-addressed random choices, is the artifact that crosses the boundary. A neural network proposing values for a 3D body-pose estimation task and a symbolic model consuming those values can be composed because both sides expose the same interface contract, not because someone wrote a prompt that described what format they should use. IBM Research's Logical Neural Networks take the opposite approach: rather than specifying the boundary, they dissolve it, making each neuron a weighted logical statement so that the network is syntactically a set of logic formulas. Both approaches converge on the same insight: the boundary has to be designed, not described.
The most explicitly programmatic recent effort is a framework called Meaning-Typed Programming, developed at the University of Michigan's Jaseci Labs. It introduces a new type called Meaning, representing the underlying semantic value of a traditional programming type, and argues that a language model should be treated as a meaning-typed code construct at the language level, backed by a compile-time intermediate representation and a type-safe runtime. In a reported evaluation, developers using the framework completed tasks 3.2 times faster with 45 percent fewer lines of code, and inference costs dropped by up to 4.5 times. The framework's diagnosis of the core problem is precise enough to serve as a thesis: there is an "input/output mismatch between symbolic functions and LLMs," and resolving it requires working at the level of the type system, not the level of the prompt. This is, in the end, what the compiler builders of the 1960s understood about natural language and code: the durable thing is never the words. It is the grammar that gives the words their force.
Key references: Khattab, O. et al., "DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines," Stanford University, arXiv:2310.03714, 2023. Dong, Y. et al., "XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models," Carnegie Mellon University, arXiv:2411.15100, 2024. Geng, S. et al., "Grammar-Aligned Decoding," NeurIPS 2024. Wang, Y. et al., "CRANE: Reasoning with Constrained LLM Generation," 2025. MIT Gen: Cusumano-Towner, M. et al., "Gen: A General-Purpose Probabilistic Programming System with Programmable Inference," PLDI 2019. IBM Research Logical Neural Networks: Riegel, R. et al., arXiv:2006.13155, 2020. Meaning-Typed Programming: Jaseci Labs / University of Michigan, arXiv:2405.08965, OOPSLA 2025. Agent Behavioral Contracts: arXiv:2602.22302, 2026. SymbolicAI Design-by-Contract: ExtensityAI, arXiv:2508.03665, 2025. Prompt brittleness: University of Washington / AI2 / UC Berkeley, arXiv:2310.11324, ICLR 2024. Brittlebench: arXiv:2603.13285, 2026. Outlines / dottxt: AWS Machine Learning Blog, 2024. AlphaGeometry: Google DeepMind, Nature, January 2024.
Daice Labs Inc.
Brookline, MA, USA
Roll the "daice"–exploration & programmable adaptation.