Urgent.News

What's breaking now, across thousands of outlets.

AI

Your local LLM app needs guardrails before it needs prompts

Most local-LLM tutorials start with the fun part: the prompt. After running a fleet of autonomous agents on local models 24/7 and logging every failure — the ledger now holds over eight thousand entries — we start somewhere else. Here is the single most important thing that ledger taught us: the call succeeding tells you nothing. The majority of our contract violations were outputs that were too…

Most tutorials on local-LLM apps start with the exciting part: crafting prompts. However, after running autonomous agents on local models around the clock and logging every failure, we discovered a crucial lesson from the ledger, which now holds over 8,000 entries: a successful API call doesn't guarantee proper results. The majority of contract violations stemmed from outputs that were too short or empty, despite the API returning a success status.

This realization led us to create a scaffold for a local-LLM app that can be set up in just one command: `npx create-local-llm-app my-app`. This scaffold includes five files containing approximately 180 lines of plain Node and Express code, without any framework dependencies.

The scaffold consists of four key components:

1. An output contract that declares what "done" looks like and verifies the output itself. This contract has three types of clauses:

- `minChars`: a simple check with the highest value

- `must`: required patterns that must appear

- `mustNot`: patterns to avoid, such as unfinished markers or refusal leakage

2. A retry mechanism that feeds failures back into the next prompt. If an output is rejected, the failure reason is incorporated into the subsequent prompt. If an item is rejected three times, it is permanently discarded without any warning messages.

3. An approval queue that ensures no output leaves the app without a human approving it. If no approval is received, the output is automatically denied. This rule is based on experience, as an unattended script once sent a request to a real company without consent.

4. Two watchdogs: a heartbeat to check if the process is alive and a silent-zero check to determine if anything is actually being produced. These are distinct concerns; a system can be fully operational but produce no output.

The guardrails serve as the foundation of the app, while the underlying model can be easily swapped out. By modifying the `.env` file and replacing the prompts with your own business tasks, the guardrails and watchdog system remain intact. Additionally, the production checker, called `honto-contract`, is available for free under the MIT license.

You can view the failure ledger behind this system on Hugging Face. Start with the scaffold, intentionally break each guardrail to test its effectiveness, and witness its robustness in ensuring reliable, unattended operation.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Beyond the Prompt: Why the Hermes Agent Is the Self-Improving AI We Actually Needed

We have all hit the "chatbot wall." You open a clean UI, paste a massive block of context, get a decent response, and then close the tab. The next day? You start completely from scratch.

  • Hermes Agent is self-improving AI developed by Nous Research
  • Unlike traditional chatbots, Hermes learns, plans, and adapts to user's work style
  • Hermes' persistent memory system retains context across sessions and platforms

More from Thursday 27 August →