Agent-Guard: Preventing Test Tampering and Unauthorized Actions
Описание и применение
Защита от изменения тестов и небезопасных команд, реализованная через хуки agent-guard, предотвращает ложные успехи и нежелательные действия агентов.
Задача
Agents can modify tests instead of fixing source code, leading to false positives and unsafe actions.
Результат
The guards prevented a test from being altered to pass, blocked a push to a protected branch, and logged all actions, ensuring safer agent operations.
Рабочий процесс
- Install agent-guard-hooks and agent-guard via pip
- Configure denylist/allowlist in ~/.config/agent-guard/config.json
- Start agent session; hook snapshots SHA256 of all test and source files
- During session, agent attempts to modify tests or run risky commands
- Hook intercepts and blocks test changes if no source file changed
- Hook intercepts and blocks Bash commands matching denylist patterns
- Agent receives block notice and must correct its behavior
- Agent completes session only if all checks pass
Доказательства
On SessionStart, the hook snapshots sha256 hashes of every test file and every source file in the project. On Stop, it diffs. If test files were modified or deleted while no source file changed, the stop is blocked:
A PreToolUse hook on Bash matches commands against a denylist of risky patterns and blocks before they run:
- Дата записи: 2026-10-01T19:25:44.007Z