Paths/AI Engineer/Agent Engineering / Agent Guardrails
Bound an Agent Loop
An agent without limits will retry a failing tool call forever. Write an agent config that caps the loop at 10 iterations, plus a separate file declaring the error policy.
Validator
IDLE — checks run live as you type commands; submit when done
01Requirements
live checks- Directory ~/agent-lab exists○
- File ~/agent-lab/agent.yaml exists with max_iterations=10○
- File ~/agent-lab/fallback.txt exists with an error policy○
02Walkthrough
6 steps- 01
Create the agent-lab directory
mkdir makes a new directory. Your agent's configuration will live here — one place to look when you ask "why did the agent do that?".
mkdir ~/agent-lab - 02
Cap the loop length
echo with the > redirect writes the setting into agent.yaml. max_iterations is the hard stop on the think-act-observe loop — after 10 rounds the agent gives up instead of looping forever on a problem it cannot solve.
echo max_iterations=10 > ~/agent-lab/agent.yaml - 03
Read the config back
cat prints the file. A one-line config is normal — the value is not its size but the fact that the limit is written down and versioned, not hardcoded somewhere in the code.
cat ~/agent-lab/agent.yaml - 04
Declare the error policy
This setting goes into its own file, fallback.txt — one file per decision keeps each rule easy to find and swap. on_error=retry_once means a failed tool call gets exactly one second chance before the agent reports failure, instead of retrying silently forever.
echo on_error=retry_once > ~/agent-lab/fallback.txt - 05
Review the full setup
ls lists the directory so you can see both config files in place. Together they bound the agent in time (max_iterations) and in behavior (retry policy).
ls ~/agent-lab - 06
Submit for validation
The validator checks that agent.yaml and fallback.txt exist, that agent.yaml contains max_iterations=10, and that fallback.txt declares the retry policy.
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — ubuntu:24.04
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list