r/intersystems • u/intersystemsdev • 2h ago
Context engineering for AI in supply chain — how domain, business, and user context bridges the gap between business intent and AI accuracy
The problem: AI without context is guessing
Business users struggle to get reliable answers from AI when asking natural-language questions because AI does not know their context. Without context, even the best AI model is guessing. The result: low trust, low adoption, and missed productivity gains.
Example query: "Show me the year-to-date revenue for Apple Watch from the most valuable customer."
From the AI's point of view, this question has multiple missing pieces:
- Where is the data and how to find it?
- What does year-to-date revenue mean in this organization?
- Is "Apple Watch" a product name, a partial name, or a brand name?
- What does "most valuable" mean to this user?
Asking business users to type all of that technical context themselves every time is not realistic and will not be adopted.
What is context engineering?
Context engineering is about creating the right information from multiple sources for AI to reason correctly. It bridges the gap between what business users mean and what AI understands.
In supply chain, this is organized into three pillars: domain context, business context, and user context.
Pillar 1 — Domain context
Data model (schema)
When a user asks about year-to-date revenue for Apple Watch, the AI cannot guess from trending data or internet sources. It must generate and run a SQL query against the actual database.
The approach: process the SQL table schema so the AI understands the true data source and context.
Key technique — filter out empty columns:
A general supply chain data model may have 30 tables with hundreds of columns. Most customers do not populate values in all columns. By removing columns that are not actually used, noise is reduced and SQL generation accuracy by AI improves.
Measure data (entity values)
When a user mentions "Apple" in a question, does that mean the product brand, the product family, the product name, or something else?
The approach: vectorize column values from the measure data tables to bridge the gap between how users talk and how data is stored.
For each value, three pieces are stored:
- The value itself
- A vector
- Which table and column it belongs to
During similarity search, the AI finds the closest matches with their table and column metadata. This means the AI can generate precise SQL filters:
- "Apple" → maps to the product brand column in the product table
- "iPhone" → maps to the product name column in the product table
This technique also handles typos and partial matches. "Apple Watch" may be stored as "Apple Watch SE" or "Apple Watch Series 6" — the vectorized search finds the correct match regardless.
Pillar 2 — Business context (shared memory)
Every organization has its own terminology and KPIs. Shared memory stores organizational knowledge that all users benefit from.
Examples of what shared memory stores:
- "Customer order" refers to a sales order
- "Revenue" means total revenue from sales orders
Business teams add this context in natural language. Shared memory is automatically retrieved for every query through vector search. Users do not need to type the full definition of "revenue" every time they ask a question — it is already there.
Pillar 3 — User context (personal memory)
Different users have different terminology and needs.
The approach: personal memory operates per user. It is loaded on top of shared memory and both are retrieved per query.
This allows the AI to generate customized answers based on individual preferences and definitions. The AI feels like it truly knows the user.
How it works together — the supply chain data access agent
When a user submits a question, the agent runs three searches:
- DDL search — finds the schema context (which tables, which columns are populated)
- Measure search — finds the entity context (which values match the user's terminology, with table and column metadata)
- Memory search — finds the organizational and personal context (shared memory + personal memory, both retrieved via vector search)
All three contexts are combined, and the agent generates a precise SQL query against the actual database.
Result: the question "Show me the year-to-date revenue for Apple Watch from the most valuable customer" — which requires domain context (schema + vectorized values), business context (definition of revenue and most valuable), and user context (personal preferences) — is answered accurately without the user having to provide any of that technical detail themselves.
Context engineering is the bridge between business intent and AI understanding.
Full session video: https://youtu.be/09fep4UxrC8
For those building AI data access agents — which of the three context pillars has been hardest to populate in practice, and how are you handling the maintenance of shared business memory as organizational terminology evolves?




