An operating company sits on decades of daily drilling reports, well files, workover histories, inspection reports and procedures. Until recently almost none of it was searchable in a meaningful way. A retrieval-based assistant changes that, and it is one of the more dependable generative AI projects in the sector, because it avoids most of the operational technology work.
It is also easy to build badly. The two usual failures are answering from the wrong document and letting the model do arithmetic it has no business doing. This post describes a design that guards against both. The short version: the LLM is the interface and the orchestrator. It is never the simulator.

Two kinds of question
Engineers ask an assistant two different things, and the system should handle them differently.
Knowledge questions. What happened the last three times this formation was drilled with a given mud weight? What does the procedure say about this isolation? These are answered from documents.
Calculation and data questions. What is the current decline trend on this well? What does nodal analysis say at this tubing size? These are answered by tools.
A language model does not understand multiphase flow. Asked to behave like a simulator, it produces a confident, plausible and wrong answer. So the design principle is that anything numerical is computed by deterministic software, and the model only decides which tool to call and explains the result.
The shape of the system
user question
|
v
auth context (who is asking, what may they see)
|
v
LLM router ---------> retrieval (permission-filtered)
| |
| v
| cited passages
v
tool calls ---------> historian query
decline curve routine
nodal analysis package
maintenance system (read)
|
v
LLM composes answer: text + citations + tool outputs shown verbatim
Ingestion is where the quality is decided
Retrieval quality matters more than model choice. Most of the effort goes into getting documents into a shape worth retrieving.
-
Parsing. Drilling reports and well files arrive as scans, tables and mixed layouts. Tables need to survive as tables. A flattened table of depths and mud weights is noise.
-
Chunking. Split on the document's own structure, such as a report day or a procedure step, so a retrieved chunk is a complete thought.
-
Metadata. Attach well identifier, field, date, document type, revision and status to every chunk. Many questions are filters before they are searches.
-
Source pointers. Keep the page reference so every answer can link back to the original.
Document revisions
An assistant that answers from a superseded procedure is worse than no assistant at all. Treat revision as a first-class field.
Store the revision and a current or superseded status with each chunk. Filter to current revisions by default for procedures and standards. Keep older revisions retrievable only when the user explicitly asks about history. And show the revision in the citation, so the reader can see what the answer rests on.
Historical records work the other way round. A drilling report from years ago is not superseded. It is the evidence. Your metadata needs to distinguish controlled documents from records.
Tool calling with deterministic engineering tools
Expose each tool to the model with a narrow, typed contract. A tool definition for a decline routine might take a well identifier and a date range and return fitted parameters with units and a fit-quality measure.
A few rules keep this safe:
-
Validate arguments in code. Check that the well exists, the user may see it and the ranges are sane before the tool runs.
-
Return structured results with units. Do not let the model infer units.
-
Display tool outputs verbatim. The model may explain a number. It should not restate one from memory.
-
Keep tools read-only at first. Drafting a work order for human approval is a reasonable later step. Writing to a control system is out of scope for this kind of assistant.
-
Log everything. Question, retrieved chunks, tool calls, arguments, results and model version.
When the model cannot find a suitable tool or passage, the correct behaviour is to say so.

Permissions
The assistant must not become a way around existing access rules. Restrict what it can retrieve according to the user's existing permissions, and apply that filter at retrieval time, inside the query. Filtering after generation is too late, because the restricted content has already influenced the answer.
Apply the same identity to tool calls. If a user cannot see a well in the source system, the historian tool should refuse it.
Think carefully about where the model runs. Be deliberate about which documents are ever sent to an external model provider. Many operators require private deployment for anything touching subsurface data or commercial terms.
Evaluation
You cannot improve what you do not measure, and for this system the measurements are mostly about retrieval and grounding.
Build a test set with the engineers who will use it: real questions, the documents that should answer them and what a correct answer contains. Then track:
-
Retrieval hit rate. Did the right passage come back?
-
Groundedness. Is every claim supported by a cited passage or a tool result?
-
Revision correctness. Was the current revision used where it should be?
-
Tool routing. Did numerical questions go to a tool?
-
Refusal behaviour. Does the system decline when the answer is not in the corpus?
Rerun the set on every change to parsing, chunking, prompts or model. The model is the most replaceable part of the stack, and a good evaluation set is what lets you replace it with confidence.
Rollout
Start with one asset's documents and a small group of engineers. Keep a feedback control on every answer. Expand the corpus once the evaluation numbers and the users agree.
That is the pattern we follow in our own LLM integration work. For how this assistant fits beside sensor-based use cases, agents and OT architecture, see our complete guide to AI in the oil and gas industry.
Frequently Asked Questions
Why should an LLM not perform engineering calculations directly?
Language models generate plausible text and do not model physical behaviour such as multiphase flow. They can return confident wrong numbers. Calculations should run in validated engineering tools that the model calls.
What makes retrieval over well files difficult?
The documents are scans, tables and mixed layouts spanning decades. Good parsing, structure-aware chunking and rich metadata such as well, date, document type and revision matter more than the choice of model.
How should the assistant handle superseded procedures?
Store revision and status with every chunk, default to current revisions for controlled documents, and show the revision in each citation. Older revisions should appear only when the user asks about history.
How are user permissions enforced in a RAG system?
By filtering at retrieval time using the user's existing access rights, so restricted content never reaches the model. The same identity should govern tool calls to historians and other systems.
How do you evaluate a well-file assistant?
With a test set of real questions built with engineers, scored for retrieval hit rate, groundedness, revision correctness, tool routing and refusal behaviour, and rerun whenever parsing, prompts or the model change.