Repository navigation
feat(hooks): run configured shell commands at agent hook points - #676
Merged
Merged
Conversation
Command hooks are the executable sibling of #669's system reminders: shell commands listed in a dedicated hooks.yaml run at the pre-defined agent-loop hook points (primarily post_session) for deterministic post-processing such as gofmt, lint, or notify. Off by default. Each command is gated on the existing per-mode bash allow-list, so hooks open no new bypass of secure-by-default; an off-list command is skipped and reported, never run. A single shared runner, agent.RunCommandHooks, is the one chokepoint both the event-driven chat agent and the headless infer agent call, so the gate and observability cannot drift between them. v1 is fire-and-observe: each run emits a hook_command stream event and is logged, but output is not fed back into the conversation.
edenreich
force-pushed
the
feat/270-command-hooks
branch
from
June 28, 2026 10:47
304d190 to
7d43dbd
Compare
edenreich
marked this pull request as ready for review
June 28, 2026 10:48
infer drives any project, not just Go ones, so a default gofmt hook (even disabled) is inappropriate. DefaultHooksConfig now ships empty; the generated hooks.yaml carries the example commented out so the shape stays discoverable without anything running until the user opts in and allow-lists a command.
inference-gateway-releaser Bot
added a commit
that referenced
this pull request
Jun 28, 2026
## [0.125.0](v0.124.1...v0.125.0) (2026-06-28) ### 🚀 Features * **reminders:** configurable reminders on a shared hook-point catalog ([#675](#675)) ([179cad1](179cad1)), closes [#270](#270) [#669](#669) [#270](#270) [#525](#525) [#270](#270) * **channels:** retain inbound voice/audio recordings with bounded cleanup ([#671](#671)) ([8fd29ce](8fd29ce)) * **hooks:** run configured shell commands at agent hook points ([#676](#676)) ([990f2c0](990f2c0)), closes [#270](#270) [#675](#675) [#675](#675) [#270](#270) [#675](#675) [#675](#675) [#669](#669) [#270](#270) ### 🐛 Bug Fixes * **agent:** keep the internal completion check out of channel replies ([#672](#672)) ([96b166c](96b166c)) * **docs:** replace em dashes with hyphens for consistency in SKILL.md and configuration-reference.md ([1c9196d](1c9196d)) ### ♻️ Code Refactoring * dead-code cleanup, Go 1.26 modernization, width-aware truncation, race testing ([#667](#667)) ([7a97f3b](7a97f3b)) * interfaces, fix context propagation, and reduce delays ([#666](#666)) ([1a93ff8](1a93ff8)) ### 📚 Documentation * **skills:** add charm v2 skills (bubbletea, lipgloss, bubbles) ([#664](#664)) ([c7242c7](c7242c7)), closes [#657](#657) [#663](#663) * **skills:** add Go skills adapted from spf13/go-skills ([#665](#665)) ([971ac23](971ac23)) * **skills:** add go-concurrency skill ([#663](#663)) ([c77ac33](c77ac33)), closes [#657](#657) ### ✅ Tests * relax TestSessionID_Age_Recent upper bound to tolerate slow CI ([#673](#673)) ([9cfe203](9cfe203)), closes [#671](#671)
Contributor
|
🎉 This PR is included in version 0.125.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds command hooks (#270): the executable sibling of #669's system reminders. Shell commands listed in a dedicated
.infer/hooks.yamlrun at the pre-defined agent-loop hook points (primarilypost_session, "agent finished generating") for deterministic post-processing —gofmt, lint, test, notify. Feature-flagged, off by default.Stacked on #675 — merge order matters
This branch is stacked on
feat/669-flexible-system-reminders(PR #675), so the base of this PR is that branch, notmain— the diff here is only #270's additive changes. #270 builds directly on #669'sdomain.HookPointcatalog +dispatchHooksseam, which are not onmainyet.Merge #675 (reminders) first, then this. Once #675 lands on
main, this PR retargets tomain(or rebase--onto main) and merges. Kept as a draft until then. Zero conflicts at every step — every change is additive at the existing seam.What it does
dispatchHooksgains aRunCommandHooks(...)call next toinjectDueReminders, in both the event-driven chat agent (internal/agent/agent_utils.go) and the headlessinfer agentloop (cmd/agent.go). Nothing [FEATURE] Flexible system reminders: multiple reminders across the agent loop #669 wrote is modified.config.IsBashCommandAllowed) — the same matcher a model-proposed command faces, so hooks open no new bypass. An off-list command is skipped and reported (hook_command_skipped+ the rejection hint), never run. Authorize a command viatools.bash.mode.*.alloworINFER_TOOLS_BASH_ALLOW_APPEND.agent.RunCommandHooks, so the gate and observability cannot drift between chat and headless.timeout, receive a JSON context on stdin (hook, turn, session id), and emit ahook_commandstream event (exit code, duration, truncated output). Output is not fed back into the conversation; stdout/exit-code feedback is a later iteration.hooks.yamlmirroringreminders.yaml(split-by-concern),INFER_HOOKS_ENABLEDmaster-switch override, generated byinfer init, validated inConfig.Validate.Verification
task build, fulltask test(no failures),go test -race ./internal/agent/... ./cmd/... ./config/...(clean),task lint(0 issues)effective/CommandsDue/Validate/round-trip), the shared runner (allow-listed exec, off-list skip + hint, disabled no-op, timeout), and a headless security test proving an off-list command does not run unattendedgo run . initgenerates.infer/hooks.yamlin the documented shape;task mocks:generateadds onlyFakeHookCommandProvider; [FEATURE] Flexible system reminders: multiple reminders across the agent loop #669's reminder tests still passCloses #270