Back to selected work

Staff assistant case study

IREE Solar staff need exact figures from manufacturer datasheets and manuals. I built a staff assistant that answers from 118 manufacturer documents and a reviewed file of company facts, names its source, and declines when the documents don't have the answer. It runs on a self-hosted chat server with xAI's Grok. Measured on a fixed question set, it went from 44 of 51 on the first Grok run to 62 of 62 on a larger set.

A problem I had to debug

In 2026 I tested letting the bot run its own document searches as tools. It should search a file, open the right lines and answer in seconds. Most did, but about 2% never finished: staff would see an answer that never completes.

My first guess was a stalled model request, since the chat server set no timeout on it. I set timeouts, and the next run still hung. So I read the bot's tool calls. It was opening a three-language catalog 20 to 100 characters at a time. Search returned line numbers, but the file reader took a character offset, so every read missed. The chat server allowed 256 tool rounds per answer.

I capped tool rounds at 60, above the heaviest real answer, and told the bot to read in large pieces. The question still hit the cap in 2 of 3 repeats. The fix was a prompt rule: read around a search match by line number, never by character offset, and answer after about ten tool calls. As a safety net, I patched the chat server so an offset read returns at least 2,000 characters.

The question then passed 5 times out of 5, with one file read each. After the live switch, the first live run had no answer over 40 seconds and none hit the cap.

The problem

Staff ask things like a battery's weight, an inverter's IP rating, or the current limit of one model in a table that lists three. The answers sit in PDFs, often in multi-column tables, graphics or long manuals. A general chatbot guesses, and on a solar job a wrong figure is worse than no answer.

Constraints

  • Product answers must come from a document on file and name it.
  • One small cloud server, shared with other services, with search running on its CPU.
  • Each answer is a paid model call, so usage has hourly and daily limits.

What I built (design)

  • Clean document text. The chat server's PDF reader lost table structure, so I re-extracted the text with the layout kept. I transcribed facts that lived only in graphics.
  • Search. Hybrid keyword and meaning-based search, reranked, with each passage labeled by file name. Keyword search split text on spaces only, so "protection grade" never matched "Protection Grade". I patched it to match lowercase words.
  • Tools. The model searches the documents itself. A filter adds the datasheet of any product the question names.
  • Reasoning per question. Quick questions use low reasoning. A question with a file, or one that asks to check or calculate, uses high.
  • Answer rules. The bold headline figure must match the source row quoted below it. For start-up, shutdown or wiring steps, the bot copies every WARNING, DANGER and CAUTION line word for word.

Where AI helped

I use AI coding agents (Claude Code, Codex and Grok) for much of the implementation. I set the scope of each change and review each pull request.

How it is tested

  • A fixed question set, grown from 51 to 62 questions. Each has the expected value and its source document. Refusal questions list figures the bot must not invent, and two paste in text that tells the bot to ignore its rules.
  • One change at a time. A change goes live only if my by-hand score is at least as good, source hits stay within 2, and no new question fails. Two prompt changes missed that bar and stayed off.
  • Reading by hand. Over runs 26 to 32 the automatic checker agreed with me on 460 of 478 answers. Three were passes whose headline contradicted the source.
  • Upgrade gate. After a chat server upgrade, 4 questions go to the live bot. Fewer than 3 right rolls the upgrade back.
  • Offline tests. 78 evaluation code tests, with no model calls, passed in 2026.

What a person controls

  • I decide what goes live. Each change has a restore point and a rollback step.
  • New documents go in through a written procedure and two test questions. A nightly check compares the live set with a register of each document's source and revision.
  • I review staff thumbs-down answers weekly and trace each to its cause.
  • The bot does nothing on equipment, and every step answer says so.

Results

  • 2026: 44 of 51 on the first Grok run.
  • 2026: average reply down from 41 s to 18.8 s after search tuning, on an earlier model.
  • 2026: right answer in the top 10 for 90.7% of 75 search questions, MRR 0.687.
  • 2026: 51 of 51 on the live bot, read by hand.
  • 2026: 0 made-up answers in 51.
  • 2026: 62 of 62, read by hand, with a 10.4 s average reply.
  • 2026, baseline: the same 62 questions asked to plain Grok with no documents, tools or rules got 25 right and gave made-up figures in 18 answers.

Limits and what's next

  • A figure taken from a single search match, without opening the file, shows no source to staff.
  • Facts in graphics or flattened tables still need hand transcriptions.
  • Answers slowed on the newest chat server version: 8.2 s on average before, 14.3 s in the first full run after.
  • In one step answer the headline named the first numbered step, while a copied warning said to do something else first. That needs another prompt change and run.

What I'd do differently

  • Label every passage with its file name in the first index. Two weight questions failed because a passage like "Weight | 130 kg" didn't say which product it described.
  • Test through the same path as the app from the start. When the bot started searching with tools, a plain API call got no documents at all. I had to add a test mode that asks like the chat app.
  • Turn real staff chats into test questions early. A review of all saved chats in 2026 found failures the question set had missed, such as lost follow-ups and one wrong figure. They became 10 new test questions.

Sources: evaluation log, bot records and operations records, 2026.

Back to selected work