Skip to content

feat(agent): add pre_verify hook and coding guidance config - #55413

Merged
OutThisLife merged 2 commits into
mainfrom
bb/pre-stop-hook
Jun 30, 2026
Merged

feat(agent): add pre_verify hook and coding guidance config#55413
OutThisLife merged 2 commits into
mainfrom
bb/pre-stop-hook

Conversation

@OutThisLife

@OutThisLife OutThisLife commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds two related coding-agent controls while keeping verification closure owned by the existing verify-on-stop evidence gate.

1. pre_verify hook

Adds a pre_verify event 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 receive coding, attempt, final_response, and sorted changed_paths so they can self-scope and self-throttle. The hook path is bounded by agent.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_verify is 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:

[Coding] Before you run tests/linters or call this done: if this is creative UI/visual work, hold off on tests and linters until the user says they like the result or you're about to commit. And before every commit, clean your work: keep it KISS/DRY, match the surrounding code style, and be elitist, shorthand, clever, concise, efficient, and elegant.

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_verify continuation. That puts the workflow rule at the exact verification decision point without creating a second default extra model turn.

3. agent.coding_instructions

Adds agent.coding_instructions as 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

  • verify-on-stop: remains the only built-in verification closure path; it decides when missing evidence requires another turn.
  • 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 under agent (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 -q
  • scripts/run_tests.sh tests/agent/test_verify_hooks.py tests/agent/test_verification_stop.py tests/agent/test_coding_context.py -q
  • Linter check on edited Python files
  • Manual diff review for stale default-pre_verify wording and local-only /clean references

@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) labels Jun 30, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@OutThisLife OutThisLife changed the title feat(agent): pre_stop round-end hook + configurable coding instructions feat(agent): add pre_verify verification hook + configurable coding instructions Jun 30, 2026
austinpickett
austinpickett previously approved these changes Jun 30, 2026
@OutThisLife OutThisLife changed the title feat(agent): add pre_verify verification hook + configurable coding instructions feat(agent): add pre_verify hook and coding guidance config Jun 30, 2026
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.
@OutThisLife
OutThisLife merged commit a81c592 into main Jun 30, 2026
31 checks passed
@OutThisLife
OutThisLife deleted the bb/pre-stop-hook branch June 30, 2026 06:10
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
feat(agent): add pre_verify hook and coding guidance config
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
feat(agent): add pre_verify hook and coding guidance config
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
feat(agent): add pre_verify hook and coding guidance config
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
feat(agent): add pre_verify hook and coding guidance config
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
feat(agent): add pre_verify hook and coding guidance config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants