---
title: "Runtime guardrails that halt runaway agents — Retrace"
description: "Runtime guardrails for AI agents: cost budgets, loop detection, context-overflow and latency caps. Cross a limit and the agent receives a HALT."
canonical: "https://retraceai.tech/features/guardrails"
last-updated: 2026-08-26
format: text/markdown
---

# Runtime guardrails that halt runaway agents

Set limits on cost, loops, context size, and latency. While your agent runs, Retrace watches every step and sends a HALT the moment a limit is crossed, so a runaway loop or budget blow-out stops at the limit instead of running up your bill.

## What it does

- **Policy types** — Cost budgets, loop detection, context-overflow limits, and latency caps, defined per project and switched on or off as you need them.
- **HALT in real time** — Each running agent is watched step by step; when a policy is violated the agent receives a HALT immediately, instead of burning more budget.
- **Accurate accounting** — Cost, tokens, step counts, and errors are accumulated reliably even when many steps arrive at once, so guardrails fire exactly when they should, not late.
- **Loop detection** — Repeated identical tool calls, runaway step counts, and 'spinning' with no progress are caught and reported as a single, clear finding.
- **Trigger history** — Every fired guardrail is recorded so you can audit what stopped, when, and why.
- **Plan-aware limits** — Active guardrail counts scale with your plan, from a few on Free to unlimited on higher tiers.

## Examples

Create a cost cap, then review what it caught.

```terminal
retrace guardrails create --name "Cost Cap" --type cost_budget --action halt --threshold 1.0
retrace guardrails list --json
retrace guardrails triggers --limit 10
```


## REST API

- `POST/GET/PATCH/DELETE /api/v1/guardrails: manage policies`
- `GET /api/v1/guardrails/triggers: fired-guardrail history`

## Related

- HTML page: https://retraceai.tech/features/guardrails
- Documentation: https://docs.retraceai.tech
- OpenAPI specification: https://retraceai.tech/openapi.json
- Authentication for agents: https://retraceai.tech/auth.md
