Why Your OpenClaw Agent Ignores Config Rules (and How to Fix It)
Your OpenClaw agent skips rules in AGENTS.md. Fix it with three layers: identity framing in SOUL.md, instruction positioning, and automated heartbeat verification.
OpenClaw agents read AGENTS.md every session. Every instruction in that file gets processed. But not every instruction gets followed. Directives in the first 25 lines have near-perfect compliance, while directives past line 100 are skipped more often than not.
This is an attention problem, not a configuration problem, and three changes fix it.
Why this happens
Large language models read instruction files the way you read terms of service. The top 20 lines get full attention. By line 80, the model is skimming. By line 139, a procedural directive barely registers, especially during a busy session where the agent is burning context on its primary task. The agent did not refuse what you wrote. It processed the file, reached your line, and treated it as background noise.
The fix: three enforcement layers
A single directive in a single file is not enough. You need three layers working together: identity, position, and automated verification.

1. Add the behavior to SOUL.md
SOUL.md defines who the agent is, not what it is told to do. Statements here carry identity weight: the agent treats them as core to its character rather than as one task among many.
Open SOUL.md and frame the behavior as self-concept rather than procedure:
# If the behavior is "log learnings after debug sessions":
I capture operational learnings after every debug session.
This is part of who I am, not a task I sometimes skip.
# If the behavior is "run tests before pushing":
I verify the test suite before every push.
Shipping untested code is not something I do.The framing matters. "Part of who I am" activates differently than "you must do X after Y." An identity statement makes the agent check whether the current situation matches its self-concept. A procedural instruction only fires when the agent scans to that specific line and connects it to the moment.
2. Move the directive to the top of AGENTS.md
Take the directive out of wherever it lives and place it in the first 25 lines, before section headers and conventions. With Pazi, you tell your agent "move this to the top of AGENTS.md, right after the startup block" and it restructures the file for you.
The wording stays identical. Only the position changes. But position determines whether the instruction gets full attention or disappears among neighboring paragraphs that the model deprioritizes under context pressure. Here is what the change looks like:

3. Add an automated heartbeat check
The first two layers reduce misses. This layer catches whatever still slips through. Write a script that verifies whether the expected output of your behavior exists, then reference it in HEARTBEAT.md so it executes every polling cycle:
# Adapt the file path and time window to your situation
#!/bin/bash
FILE="path/to/expected-output"
LAST_MOD=$(stat -c %Y "$FILE" 2>/dev/null)
NOW=$(date +%s)
AGE_HOURS=$(( (NOW - LAST_MOD) / 3600 ))
if [ "$AGE_HOURS" -ge 4 ]; then
echo "COMPLIANCE CHECK FAILED - output is stale"
exit 1
fiThen add this to HEARTBEAT.md:
## Compliance Check (EVERY heartbeat)
Run bash scripts/check-compliance.sh first.
If the expected output is stale: STOP all other work and comply NOW.The heartbeat check does not fix the gap. It blocks all other work until the agent complies, turning the behavior from a suggestion into a prerequisite. The full decision loop looks like this:

How to verify
Trigger a situation where the behavior should fire. Check whether the agent followed through before moving on to its next task. If it did, the three layers are working. If it skipped, diagnose which layer failed: is the SOUL.md statement still present? Is the AGENTS.md directive still in the first 25 lines? Is the heartbeat script running on schedule?
Monitor over the following week. Consistent compliance across sessions means the pattern is holding.
This pattern came from running production agents at Pazi, powered by OpenClaw.