← All posts
Frameworks··8 min read

AI Agent Guardrails: Monitor and Lint the Logic You Hand to Agents

More business logic is moving out of backends and into agents. That makes monitoring and code checks your first line of defense. Here is how we use two free open source tools to keep agents honest, and what to build this quarter.

AI Agent Guardrails: Monitor and Lint the Logic You Hand to Agents
Answer

AI agent guardrails are the checks that make delegated business logic safe to run unattended. Start with two free open source tools: Prometheus to measure what your agents do, and Ruff to lint the code they write. Add an owner, an alert, and a kill switch to every agent before you add another one.

The business logic in your company is moving. It used to live in backends, spreadsheets and the heads of your best people. Now it is moving into agents. That shift makes AI agent guardrails the most important thing you can build this quarter.

We run a 40-person real estate group. We also build AI systems for other operators. Over the last months we have watched the same pattern at both. An agent gets a job. It does the job well for two weeks. Then something drifts and nobody notices for days.

This post is about fixing that. We will use two free, open source tools as the backbone: Prometheus for monitoring and Ruff for code checks. Neither is glamorous. Both are what make delegation safe.

Why the logic is moving to agents

Think about how a lead gets handled in a typical 10-50 person company. A form fires. Someone checks it. Someone decides who gets it. Someone writes the reply. Each step is a small piece of business logic held together by people and tabs.

An agent can now hold all of those steps in one place. It reads the inbound message, checks your rules, and drafts the answer. Tools like Claude Code also let agents write and run scripts to do the work. The logic stops being a screen your team clicks through. It becomes a set of instructions an agent follows.

That is good news for speed. Our automation work is built on it. Agents work 24/7, and the first system goes live in days to weeks.

It is bad news for visibility. When logic sits in a person, you can ask them what they did. When logic sits in an agent, you need instruments.

The three failure modes we see

Every agent failure we have cleaned up falls into one of three buckets.

  • Silent stop. The agent quits and nothing tells you.
  • Silent drift. The agent keeps running but its output slowly gets worse.
  • Silent damage. The agent runs fine but does something you never approved.

Notice the word silent. The fix for all three is the same idea. Make the agent loud. Give it numbers you can watch, alerts that wake someone up, and checks that run before anything ships.

Layer one: measure with Prometheus

Prometheus is a free, open source monitoring tool. The official overview describes it as a system that collects metrics as time series data. It tracks server performance, app metrics and system health in real time. It was built for engineers, but the model fits agents well.

Here is the three-step setup, as we use it:

  • Install. Download Prometheus from its official site or GitHub releases.
  • Connect. Point it at a small endpoint that your agent runner exposes.
  • Monitor. Write rules that watch the numbers and alert on change.

The endpoint is the part that matters. Your agent runner needs to publish a handful of counters. Keep them boring and few.

The agent metrics we publish

MetricWhat it tells you
Tasks started.Is the agent alive and getting work.
Tasks failed.Is something breaking.
Time to first response.Are we inside our speed-to-lead target.
Approvals pending.Is a human queue backing up.
Actions blocked by policy.Is the agent trying things it should not.

Time to first response deserves a note. For inbound leads, the threshold we hold ourselves to is 5 minutes. If the agent that handles new leads drifts past that, you are losing deals. You can see the full cost of that leak with our revenue leak heatmap.

Alert on silence, not just errors

Most people alert on errors. That catches only one failure mode. The better rule is to alert when a number that should move stops moving.

If tasks started is flat for an hour during business hours, something is wrong. Maybe the queue is empty. Maybe the agent died. Either way, a human should look. Prometheus supports this kind of rule, and its Alertmanager handles routing the alert to email or chat. Send it to a named person. An alert that goes to everyone goes to no one.

Layer two: lint what the agent writes with Ruff

Many agents now write code. They write small scripts that clean data, call an API, or reformat a report. That code runs with real access to your systems. Nobody on your team reads every line.

This is where Ruff earns its place. The Ruff documentation describes it as an extremely fast Python linter and formatter. It is free and open source. It catches mistakes and cleans up code in seconds.

The setup is short:

  • Install. Run pip install ruff.
  • Check. Run ruff check . to find issues.
  • Fix. Run ruff check --fix . to apply safe fixes automatically.

For us, the key is where we run it. We run Ruff as a gate. Any script an agent writes must pass the check before it is saved to the live folder. If it fails, the agent gets the error back and tries again. A human never sees the broken version.

A linter will not tell you if the logic is right. It will not catch a wrong business rule. It does catch undefined names, unused imports and a long list of common slips. Those are the exact errors that cause a script to die at 2 a.m. and trigger a silent stop.

Claude Code also supports hooks, which run your own commands at set points in the agent loop. That is a clean place to wire in a lint check. The agent writes. The hook lints. The result goes back to the agent. No human in the loop for the easy stuff.

Layer three: approvals and the kill switch

Metrics and linting cover the technical side. The third layer covers authority.

Every agent we build has three things written down before it goes live:

  • An owner. One named human who gets the alerts.
  • An approval list. Actions that need a yes before they happen, like sending money or deleting records.
  • A kill switch. One step that stops the agent, reachable in under a minute.

The kill switch sounds dramatic. It is not. It is a flag the runner checks before each task. We test it the same way you test a fire drill. If you have never used it, you do not know that it works.

This ties to the idea we wrote about in our earlier posts on agent teams: one job per agent, clear limits, and approval cards for anything risky. Guardrails are what make that design real instead of a diagram.

What to do this quarter

You do not need a platform team. You need one afternoon per agent and a short list.

  • List every agent and automation that touches customers, money or data.
  • Name an owner for each one.
  • Add the five metrics above to the runner.
  • Install Prometheus and write two alerts: one for errors, one for silence.
  • Put Ruff in front of any code an agent writes.
  • Write the approval list and test the kill switch.

Do this in order. Do not skip to alerts before you have owners. An alert with no owner is noise.

What it costs you

Prometheus and Ruff are free. Your cost is setup time and a small server to run Prometheus. The cost of skipping it is higher. The typical admin leak we find in a 10-50 person company is 10+ hours a week. If an agent quietly breaks, that leak comes straight back, and you do not see it return.

How this maps to what we build

Guardrails are not an add-on for us. They ship inside every system. Here is how they show up across the products we sell.

  • AI Operations Agent. Metrics, silence alerts and approval cards for every workflow it runs.
  • AI Chief of Staff. Approval rules on anything that sends mail or books time on your behalf.
  • Voice agents. Response time and handoff counters, built into our voice agent setups.
  • Second Brain. Checks that keep the wiki consistent while agents edit it.

You also own what we build. Clients own 100% of code and files. That includes the dashboards, the alert rules and the Ruff config. If you leave us, the guardrails stay with you.

You can see how this plays out in real builds in our case studies.

The operator take

The loud debate is about which model is smartest. That is not your bottleneck. Your bottleneck is trust. Can you hand a job to an agent and sleep?

Trust does not come from the model. It comes from instruments. A small team with a well-watched agent beats a big team that has to check everything by hand. That is the real promise of moving logic into agents. It only holds if you can see what the agents are doing.

Start small. Pick the one agent whose failure would hurt most. Put the three layers around it. Then copy the pattern.

Where to start

If you are not sure which agent to guard first, start with a map of where your business leaks time and money. Our assessment does exactly that. It costs €999, and that fee is credited to the build if you move forward. You leave with a ranked list of what to automate and what guardrails each piece needs.

// Next move

See where AI pays you back first.

A free 10-minute assessment. Your top AI quick win plus the hours and money it returns. No cost, no pitch.