Retrieved article excerpt
Open article · Retrieved 2026-11-23T12:23:42.114770+00:00
# L.A.T.E.
**Local AI Tool Engine**
L.A.T.E. takes a local model (or an API model) and turns it into an agent. You give it a goal, and it works through it: it picks a tool, runs it, reads what came back, and keeps going until the job is done. Search the web, read pages and files, do exact maths, save files, remember things between chats.
I built it because models on their own are bad at the boring parts. They get maths wrong, forget everything when the chat ends, and make things up instead of looking them up. Small models are worse: they skip steps, count letters in their head and lose track halfway through a job. So here the tools do the exact work, plain code handles the order of the steps, and the model mostly writes the answer.
It runs with Ollama, LM Studio, or an API key (Groq, OpenAI, OpenRouter, Gemini, anything OpenAI-compatible). No LangChain, no paid API needed, two dependencies.
## What it does
- **Exact answers.** Maths, dates, unit conversion, counting, random numbers and weather come from real tools, not from the model's memory.
- **Multi-step jobs.** "Create a file, read it back, count the characters, save the count, read that file too" runs as exact steps, in order, and the answer lists what really happened. Works even when the model is tiny.
- **Research with sources.** It searches, opens the best pages, answers from what it read, and links them.
- **Your files.** Read a file, search a folder, copy, merge, sort the lines, change case, append text.
- **Memory.** Tell it something once, it remembers in later chats. `forget` really removes it.
- **Saving files.** Only after you say yes, and only into an `ai-output` folder.
- **Terminal or browser.** A terminal chat, or a small web page on your own computer.
- **Rules first, model last.** The plan for a job is made by plain code (the same words give the same plan every time). The model only writes text. A job is never answered with "here's how you could do it": it runs, or it says plainly that it couldn't.
- **It says what really happened.** The answer lists the steps that ran and what the tools returned. If a step failed it says "Partly done" or "I stopped at step N because...". If the last check found a difference it says "NOT a success". It never says "Done" for work that wasn't done.
## Getting started
You need [Node.js](https://nodejs.org/) 18 or newer (I use 22). Then, in the project folder, one command:
```
npm start
```
That's all. The first time it:
1. **installs what it needs** (a minute, one time, you never type `npm install`),
2. **finds your model**: Ollama or LM Studio if one is running (it can even download a small model for you), or you choose "API key" and pick OpenAI, Groq, OpenRouter, Gemini (or any OpenAI-compatible URL) and paste the key. It checks the key and lists the models,
3. **asks if you want PDF reading** (adds one small library, about 1 MB),
4. sends a test message, and opens the chat.
After that, `npm start` just opens the chat. If an update brings a new library, it installs it by itself on the next start.
Prefer a browser? `npm run ui` and open the address it prints. Change the model later: `npm run setup`. Type `exit` to quit.
`npm test` runs the tests (no model needed). `npm run eval` tests how good your model is (see below).
No wizard? Set the variables yourself, e.g. `AI_PROVIDER=lmstudio npm start` (PowerShell: `$env:AI_PROVIDER="lmstudio"` first).
## Multi-step jobs
You don't need `/agent` for these. If one sentence asks for several things, L.A.T.E. splits it into steps by itself. Some examples that work:
```
Create a file called test.txt with "hello123", read it back, count the characters, save the count to result.txt, then read result.txt.
Remember that my favorite number is 777, tell me the number, forget it, then tell me the number again.
Create 5 text files. Each file should contain a unique random number. Then search all files and tell me which file contains the largest number.
Read notes.txt, sort the lines, then save it to sorted.txt
Merge a.txt, b.txt and c.txt into all.txt
Convert 10 km to miles, then save it to d.txt
Create a.txt with HELLO, create b.txt with WORLD, read both files, save their contents into combined.txt, then read combined.txt.
Create a.txt with AAA and b.txt with BBB and c.txt with CCC then merge them into merged.txt.
Create a.txt with 10, create b.txt with 20, add the two numbers and save the sum to sum.txt.
Create alpha.txt with FIRST, create beta.txt with SECOND, combine both contents into final.txt, then verify that FIRST and SECOND are both present in final.txt.
Remember my favorite fruit is mango. Change my favorite fruit to apple. Recall my favorite fruit.
Create s.txt with one two three, count the words, then verify the count is 3.
Create 10 files containing random numbers, find the largest value, save a report, corrupt the report, detect the corruption, repair the report, verify the repair.
```
What the rules understand is a list of shapes, not "anything you can say". See "Not done yet / known limits" below.
How it works, in order:
1. **Rules first.** The request is cut into clauses and turned into tool calls by plain code. Values move from step to step (the count from `text_stats` is what gets saved, nobody guesses it). No model needed.
2. **Model plan second.** If the rules don't understand the request, the model writes a plan as JSON. It is only used if every step is valid (real tool, right arguments, values that exist). Otherwise it's thrown away.
3. **One tool at a time last.** Anything else falls back to the model picking a tool, looking at the result, and picking the next one. It gets a second try if it breaks the JSON.
What you get back is a report built from what actually ran:
```
Done. All 5 steps worked:
1. Saved to ai-output/test.txt (8 bytes), containing: hello123
2. Read test.txt: hello123
3. Counted 8 characters in test.txt.
4. Saved to ai-output/result.txt (1 bytes), containing: 8
5. Read result.txt: 8
Checked: I read back 2 saved files and they match what I meant to write.
```
If you say no to a save, or a step fails, it stops there and tells you what was done and what wasn't. It doesn't carry on with wrong data. If `test.txt` already exists and gets saved as `test-2.txt`, the next steps use the real name.
When the job needs writing, the model writes only the text and everything around it stays exact:
```
Write a two-line poem about the sea and save it to sea.txt
Summarize notes.txt in one sentence
Translate "good morning" to Spanish and save it to es.txt
Research react hooks, then write a short report and save it to report.md
Create a file called fruits.txt with a list of 3 fruits, then read it back
```
The file text goes to the model as data, never as instructions. Every save is read back. In a research report the links come
from the real search, so the model can't make them up. Quoted text is always saved exactly as you typed it.
Want to see the steps first? `/plan <goal>` in the terminal (or `ai.plan(goal)` in code) shows them, says which ones the model
writes and whether it will ask permission, and runs nothing.
When you answer "Allow?", `y` is yes, `a` is yes to everything in this task, anything else is no.
## Tools
| Tool | What it does | Try asking |
| --- | --- | --- |
| calculator | Exact maths. Divide by zero gives a clear error. | `what is 245 * 37?` |
| text\_stats | Exact characters, words and lines of a text or file. | `count the characters in hello123` |
| number\_stats | Largest, smallest, sum, average, sort of a list, with labels like file names. | used in multi-step jobs |
| compare\_numbers | Are these two numbers the same (an answer against a formula)? Says the difference. | `verify the sum using the formula` |
| compare\_text | Is a saved text exactly what it should be? Shows the first line that differs, or which file of a list changed. Can also check that a text contains a word, or list the points of a report that a summary leaves out. | `verify the report` |
| text\_transform | Uppercase, lowercase, title case, reverse, sort lines, remove duplicate lines, number lines, trim. | `read notes.txt and make it uppercase` |
| random\_numbers | Real random numbers, all different. | `give me 5 random numbers between 1 and 100` |
| datetime | Date and time, days until a date, N days from today or ago, weekday of a date. | `what date is 10,000 days from today?` |
| convert | Exact unit conversion: length, weight, speed, temperature, data size and more. | `convert 5 km to miles` |
| weather | Current weather in a city (free service, no key). | `weather in Delhi` |
| wikipedia | A short summary from Wikipedia. | `wikipedia Alan Turing` |
| web\_search | Searches the web, prefers official docs when you ask. | `search for the official docs on React hooks` |
| research | Searches, opens the best pages, pulls out the useful parts, answers with sources. | `research how react hooks work` |
| read\_webpage | Opens a link and reads the text. | `summarize https://example.com/article` |
| read\_file | Reads a text file, a PDF or lists a folder. | `read notes.txt and summarize it` |
| read\_files | Reads every text file in a folder at once. | used in agent mode |
| describe\_image | Looks at a picture (png, jpg, webp, gif) and describes it or reads its text. Needs a model that can see. | `describe photo.png` |
| search\_files | Looks inside your files, names and contents. | `search my files for acme invoice` |
| write\_file | Saves a new file, only after you say yes. | `/agent research React hooks and save a short report` |
| append\_file | Adds text to a file in `ai-output`, after you say yes. If the file does not exist yet, the same text is written to a new file (and the answer says `write_file` ran). | `add " and eggs" to todo.txt` |
| remember / recall / forget | Keeps facts between chats. `remember` can replace an older note about the same thing (`change my favorite fruit to apple`). `recall` returns only the notes that are about **all** the words you asked (newest first). `forget` can remove the latest one. | `remember my sister is called Riya` |
Maths, dates, units, counting, notes and file search never depend on the model getting it right. The tool's answer is the answer. For the rest, the model writes up what the tool found.
## How it decides, and what it never does
1. **Rules plan the job.** A clause like "save the count", "read both files", "change my favorite fruit to apple" or "verify the count is 3" is turned into exact steps by code. No model is asked.
2. **The plan is checked before anything runs.** Does the tool exist? Does every variable exist? Does the field exist (`{{stat.value}}` yes, `{{stat.valu}}` no)? Is a file name being used as text (refused)?
3. **The steps run in order and keep going** until the job is finished, you say no, a step fails, or time runs out. Network steps that don't need each other (research, searches, page reads, weather) run at the same time.
4. **The answer is built from what the tools returned.** Not from the model's words.
If the rules can't plan a request, a model-driven loop may try it. In that loop:
- a request to *do* something (create, save, read, merge, remember, change...) is never answered with instructions;
- if no tool ran, the answer is "I didn't run any tools, so nothing was done";
- if some steps failed, the answer is "Partly done": what worked and what failed, from the tools, not from the model;
- the model's decisions (which tool, what plan) are asked at temperature 0, so the same question gets the same decision.
**What this does not promise.** For prompts the rules can plan, the same words give the same result every time (tested with a fake model that changes its mind on every call). For prompts the rules can't plan, a real model may still pick different tools on different days. It can't claim success or give instructions, but it may do more or less work.
## Small and large models
The engine reads the