Table of Contents
14. When AI Invents Features (How to Prevent Hallucinated Behavior)
How we prevent AI from
fabricating behavior
the system never had
—Part of CSS Primer for the AI Era — Working with Existing Code
AI does not know what is real.
It only knows what is probable.
When the window is ambiguous,
AI may invent things like:
- features the system never supported
- settings that do not exist
- filters that were never implemented
- hooks that sound plausible but are fictional
- configuration options that appear “standard” but aren’t
- behaviors that contradict the actual code
- entire workflows that feel familiar but have no basis in reality
As we know by now,
this is not deception.
It is 'completion without grounding'.
A simple mental model to minimize it:
AI invents features
when the window is vague.
We prevent invention
by grounding the work.
— Collaboration is the act of
keeping the work real.
This page teaches us how to recognize hallucinated behavior
and how to prevent AI from fabricating features the system never had.
1. How We Recognize Hallucinated Features
AI is hallucinating when it:
- references a function that does not exist
- describes a setting that appears nowhere in the codebase
- proposes a filter or hook that sounds plausible but is fictional
- assumes a plugin supports an option it never implemented
- suggests a workflow that contradicts the actual behavior
- “documents” features that were never built
- adds configuration keys that look standard but are imaginary
A simple truth:
Hallucination is not misunderstanding —
it is invention.
This is a different failure mode
from the previous chapters.
2. The First Step: Ask AI to Point to the Source
When AI invents a feature,
the first step is to ask:
“Where in the codebase is this implemented?”
“Show me the file where this feature exists.”
“Which function provides this behavior?”
“Which hook or filter supports this?”
Hallucinated features collapse instantly
under this question.
A simple principle:
Real features have real sources.
Invented features do not.
3. The Second Step: Re‑Anchor AI in the Actual Code
Re-anchoring is a good second step to prevent hallucination.
So, we show AI the real implementation:
- the actual function
- the actual filter
- the actual markup
- the actual configuration
- the actual behavior
And we may say:
“This is the real implementation. Please work only with what exists here.”
A simple reminder:
Grounding prevents invention.
4. The Third Step: State Explicitly What Does Not Exist
AI fills gaps with probability.
So, we remove the gaps.
For example:
“There is no setting for this.”
“This plugin does not support that behavior.”
“There is no filter with that name.”
“This feature has never been implemented.”
“This workflow does not exist in this system.”
A simple truth:
AI cannot invent what
we explicitly rule out.
5. The Fourth Step: Replace the Fiction With the Real Constraint
Once we eliminate the invented feature,
we replace it with 'the real limitation'.
Example of replacements for the hallucination:
“The plugin only supports X.”
“The theme only controls Y.”
“This system only allows Z.”
“The only available hook is this one.”
“The configuration is fixed and cannot be extended.”
This gives AI a real boundary to work within.
A simple principle:
Constraints
prevent hallucination.
6. The Fifth Step: Ask AI to Restate the Real Capabilities
This step ensures we are on the same page.
So, we ask AI to summarize:
“What features actually exist?”
“What does this system support?”
“What are the real constraints?”
“What is not available?”
This reveals whether AI is grounded,
or not.
A simple truth:
Grounding becomes visible
when AI explains it back to us
and we agree.
7. The Sixth Step: Ask AI to Re‑Solve the Task Using Only Real Features
Then, we ask AI to try again:
“Please solve this using only the features that exist.”
“Do not introduce new settings.”
“Use only the available hooks.”
“Stay within the real capabilities.”
This forces the model to operate inside reality.
A simple reminder:
Real solutions come from real constraints.
8. The Seventh Step: Decline and Redirect When Needed
But if AI continues to invent features,
we decline:
“This describes behavior the system does not support.”
“This feature does not exist.”
“This hook is fictional.”
“Let’s stay within the real implementation.”
A three‑line principle:
Declining is part of guiding.
Guidance is part of collaboration.
Collaboration is how we steward
the architecture.
9. The Eighth Step: Shrink the Window to Remove Fictional Patterns
We know that hallucination often comes from
seeing too much:
- too many unrelated examples
- too many modern patterns
- too many similar‑sounding features
- too many plausible but irrelevant structures
So, We shrink the window of exposure to AI:
- show only the real implementation
- remove unrelated code
- remove similar patterns
- remove anything that invites invention
A simple principle:
When AI invents,
we shrink the window of exposure
to return to what is real.
10. Closing Note — Preventing Hallucination Is Preventing Fiction
AI does not know what is real.
It only knows what is 'probable'.
So, we prevent hallucination by:
- asking for sources
- grounding the work
- stating what does not exist
- replacing fiction with real constraints
- asking AI to restate
- asking AI to re‑solve
- declining when needed
- shrinking the window of exposure
A simple closing thought:
AI invents features.
We keep the work real.
— That is how the system stays true.
- Suggested Next Reading: → When AI Misreads Intent (How to Re‑Center the Goal)
Tony de Araujo —New York | Lisbon
