Stop adding prompts — fix your ontology first
When an AI agent keeps making mistakes, the instinct is to add more instructions to the prompt. This post argues the real fix is an ontology — a clear, structured map of the concepts and relationships in your domain. Get that right and your prompts get shorter, cheaper, and more reliable.
A common trap when building AI skills (agent modules that handle a specific task) is patch-prompting: every time an edge case breaks something, you bolt on another rule. Prompts balloon, token costs climb, and behavior gets harder to predict.
The post's argument is that most of those edge cases exist because the underlying concepts were never clearly defined. An ontology is a structured definition of what things exist in your domain and how they relate — for example, explicitly stating that an 'order' contains multiple 'products' and belongs to one 'customer'. When that structure is spelled out up front, the LLM doesn't need the same context re-explained in every prompt call. The result is shorter prompts, lower token spend, and more consistent outputs — directly relevant to anyone trying to build cost-efficient AI agents.
Key points
- Adding prompt rules for every edge case inflates prompt length and token costs over time
- An ontology — a structured map of your domain's concepts and relationships — is the more durable fix
- With a clear ontology, the LLM needs less repeated context, so prompts stay short and costs stay low
- Document your domain concepts before building an agent, not after debugging dozens of failures
Quick term guide
- AI agent
- An AI program that can inspect information and suggest what to do next.
- prompting
- Writing instructions or questions to an AI to get a response.
- edge case
- An unusual or unexpected situation that falls outside the normal flow and often causes errors
- token costs
- Token costs are the fees paid for the text an AI model reads and writes.
- token cost
- The money or usage spent when sending text to an AI model and getting text back.
- edge cases
- Unusual or unexpected inputs that fall outside the normal, expected use of a product.
- AI agents
- AI agents are AI tools that can carry out steps toward a goal, not just answer once.
- debugging
- The process of finding and fixing the cause of errors or unexpected behavior in code.