An identifier is an arbitrary string. Nothing about the tokens T-4821 makes it more likely than T-4891, so when you ask a model to "return the ticket ID," you are asking it to reproduce a fact it either saw in the prompt or learned in training. If the ID is not in the prompt, the model has two options: say it does not know, or produce a plausible-looking string. Unless you have made a refusal legal, the second option wins.
That behavior is a well-documented failure class rather than a quirk of one model. Surveys of prompting techniques classify this as hallucination, content that is not grounded in the input or reality, and note that prompting changes are the cheapest intervention to test before you reach for retrieval systems or fine-tuning the practical prompt engineering guide. The same reference describes grounding methods such as "according to..." prompting, chain-of-verification and step-back prompting, all of which share one property: they restrict where the model may get an answer from the hallucination reduction overview.
An enum does the same job more tightly for identifiers. Instead of suggesting a source, it defines the entire universe of legal answers. Once the allowed set is closed, "invent an ID" stops being a creative act and becomes a contract violation you can detect with a single membership check.
There is a second reason to fix this at the prompt layer rather than the model layer. Structural failures are not solved by syntactic enforcement alone. An empirical study across four software engineering tasks found that a strict template-driven control nearly eliminated syntax errors, but substantial structural and semantic errors persisted, which the authors read as evidence that the bottleneck lies beyond formatting the structured output control study. In other words, a model that returns valid JSON can still return the wrong ID. Your prompt has to constrain the value, not just the shape.



