feat(agent): add pre_verify hook and coding guidance config - #55413
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
COMMENT: Well-structured feature adding pre_stop round-end hook and configurable coding instructions. 14 files (just under the 15-file threshold) with 413 additions. The coding_instructions config is cache-safe and properly isolated as a separate system block. The pre_stop hook integrates cleanly with the existing hook system. However, the surface area spans agent core (coding_context, conversation_loop, stop_hooks), config, plugins, and 4 test files. Recommend verifying: (1) the coding_instructions block doesn't break prompt caching when empty, (2) the pre_stop hook fires reliably across all exit paths (cancel, error, normal stop), (3) the hook registration in plugins.py doesn't conflict with existing hooks. Test coverage looks solid.
edc1a09 to
e2770d7
Compare
e2770d7 to
8f27891
Compare
4cd8b73 to
56688dc
Compare
Add a `pre_verify` user/plugin/shell hook fired once per turn when the agent
edited code and is about to finish, after the existing verify-on-stop guard. A
hook can keep the agent going one more turn (run a check, defer it, tidy the
diff) by returning {"action":"continue","message":...} (the Claude-Code Stop
shape {"decision":"block","reason":...} is accepted too). Hooks receive coding,
attempt, final_response, and sorted changed_paths so they can self-scope and
self-throttle; the path is bounded by agent.max_verify_nudges and preserves
message-role alternation.
Hermes still ships its default coding guidance (agent.verify_guidance, on by
default), but it now rides the evidence-based verify-on-stop missing-evidence
nudge instead of a separate default pre_verify continuation, so it costs no
extra model turn of its own. Guidance reuses the shared utils.is_truthy_value
parser rather than a local copy.
agent.coding_instructions (a string or list) is appended to the coding brief as its own stable system block, so users can pin project-wide workflow rules without editing the shipped brief. Coding-posture only and cache-safe (resolved once per session; takes effect next session). Empty by default.
56688dc to
821d9f7
Compare
feat(agent): add pre_verify hook and coding guidance config
feat(agent): add pre_verify hook and coding guidance config
feat(agent): add pre_verify hook and coding guidance config
feat(agent): add pre_verify hook and coding guidance config
feat(agent): add pre_verify hook and coding guidance config
Summary
Adds two related coding-agent controls while keeping verification closure owned by the existing verify-on-stop evidence gate.
1.
pre_verifyhookAdds a
pre_verifyevent fired when the agent edited files and is about to accept a final answer, immediately after the existing verify-on-stop guard. A plugin or shell hook can keep the agent going one more turn — run a check, defer it, tidy the diff — by returning:{"action": "continue", "message": "<follow-up for the model>"}The Claude-Code Stop shape (
{"decision": "block", "reason": "..."}) is accepted too. Hooks receivecoding,attempt,final_response, and sortedchanged_pathsso they can self-scope and self-throttle. The hook path is bounded byagent.max_verify_nudges(default 3), preserves message-role alternation, and is silent to the user while it nudges.Important: Hermes does not add a second built-in verification decision through
pre_verify. The built-in decision remains owned by verify-on-stop and the passive verification evidence ledger.pre_verifyis for user/plugin/shell policy.2. Default verify-on-stop guidance
Hermes still ships the default coding guidance, enabled by
agent.verify_guidance: true. The default text is preserved:The behavior change is where it lives: this guidance is appended to the existing verify-on-stop missing-evidence nudge, rather than emitted as an independent default
pre_verifycontinuation. That puts the workflow rule at the exact verification decision point without creating a second default extra model turn.3.
agent.coding_instructionsAdds
agent.coding_instructionsas a string or list appended to the coding brief as its own stable system block. It is coding-posture only, cache-safe, and takes effect next session.Scoping
agent.verify_guidance: default-on shipped guidance appended to that missing-evidence nudge; set false to keep the nudge terse.pre_verify: user/plugin/shell hook mechanism with no separate shipped default continuation.agent.coding_instructions: stable cached standing guidance for coding sessions.Footprint
One new hook event, one small helper module (
agent/verify_hooks.py), three config keys underagent(coding_instructions,verify_guidance,max_verify_nudges), no env vars, and no new model tools.Test plan
scripts/run_tests.sh tests/agent/test_verify_hooks.py tests/agent/test_verification_stop.py tests/hermes_cli/test_plugins.py tests/agent/test_shell_hooks.py -qscripts/run_tests.sh tests/agent/test_verify_hooks.py tests/agent/test_verification_stop.py tests/agent/test_coding_context.py -qpre_verifywording and local-only/cleanreferences