openshift / openshift/ocm-agent-operator
Stop hook should skip validation for read-only agent roles
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3
- Forks
- 59
- Avg merge
- 10h 17m
- Merged PRs (30d)
- 25
Description
What happened
The review agent on PR #356 (run 33465133921) triggered the stop hook (stop-prek-validation.sh) multiple times during its run. The hook runs prek run --all-files on every Claude stop event. Since the review agent does not modify any files, each run found no issues but still consumed tokens processing the hook output and added unnecessary turns to the conversation. The review agent handled it gracefully but the noise was wasteful — the review run cost ~$5.87 and took ~19.5 minutes, some of which was spent on unnecessary validation cycles.
What could go better
The stop hook should detect when it is running inside a read-only agent session (review agent, retro agent) and skip the prek run --all-files validation. The fullsend harness sets environment variables like FULLSEND_AGENT_ROLE or similar identifiers that distinguish agent types. Adding a guard clause at the top of the hook script would eliminate the token waste without affecting the hook's value for code-modifying agents (code agent, fix agent). Confidence: moderate — the exact environment variable name needs verification, and the token savings per run are incremental but compound across frequent review dispatches.
Proposed change
In .claude/hooks/stop-prek-validation.sh, add an early-exit guard for read-only agent roles:
# Skip validation for read-only agents (review, retro) — they don't modify files
case "${FULLSEND_STAGE:-}" in
review|retro) exit 0 ;;
esac
If FULLSEND_STAGE is not set in the hook environment, check for alternative indicators: FULLSEND_AGENT_ROLE, the presence of a review-specific env var, or whether git status --porcelain shows no changes (a cheaper check than running full prek).
Validation criteria
The next 3 review agent runs on this repo should not show prek validation output in their conversation logs. Verify by checking review agent run logs for absence of prek run output lines. The stop hook should still run normally for code and fix agent runs.
Generated by retro agent from https://github.com/openshift/ocm-agent-operator/pull/357
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .claude/hooks/stop-prek-validation.sh and verify which FULLSEND environment variable is available during review and retro runs. Add the read-only role guard while preserving validation for code and fix agents. Confirm the next three review-agent logs contain no prek validation output, and that code and fix runs still validate normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100