Repository navigation
feat(reminders): configurable reminders on a shared hook-point catalog - #675
Merged
Merged
Conversation
Replace the two hard-coded system reminders (periodic + wrap-up, injected only pre-stream) with a configurable list of named reminders attached to a fixed, validated catalog of 8 pre/post agent-loop hook points (domain.HookPoint). A reminder = hook point + trigger (always | interval | turns_before_max | once); multiple reminders stack on a single point. Both the event-driven chat agent and the headless `infer agent` now share one domain.SystemReminderProvider and a single dispatchHooks() seam, removing the duplicated reminder logic. The catalog + seam are the shared foundation that #270 (executable command hooks) builds on. The flat system_reminders fields (interval, reminder_text, wrap_up_text, wrap_up_threshold) are removed in favour of system_reminders.reminders; the default config ships one disabled todo-hygiene reminder. Closes #669
edenreich
commented
Jun 28, 2026
edenreich
commented
Jun 28, 2026
Co-authored-by: Eden Reich <[email protected]>
Promote the reminder config out of prompts.yaml (agent.system_reminders) into a top-level reminders.yaml with its own loader, default, and env override (INFER_REMINDERS_ENABLED), matching the repo's split-config-by-concern pattern. Reminders aren't prompts; the companion executable hooks (#270) get their own hooks.yaml, keeping "inject text" and "run code" as separate concerns.
…request Reminder cadence was keyed off AgentContext.Turns, which resets to 1 on every user message (a fresh AgentContext is built per RunWithStream). An interval:4 reminder therefore never fired in normal chat - a single-turn reply never advanced the per-request counter past 1 - and a once reminder re-fired on every message. Split the two notions into a domain.ReminderQuery: Turn stays per-request (turns_before_max, relative to MaxTurns) while SessionTurn is a cumulative model-turn counter on the long-lived AgentServiceImpl that interval keys off. The once fired-set moves to the same session scope. Headless infer agent passes SessionTurn == Turn (a run is the session), so its behaviour is unchanged. Adds a regression test asserting interval:4 fires at cumulative turns 4 and 8 across separate single-turn requests.
streamevent emits machine-readable JSON to stdout for headless infer agent observers. In the interactive TUI the Bubble Tea renderer owns stdout, so those lines (system reminders, compaction) corrupted the rendered input line. Redirect the streamevent writer to io.Discard in both infer chat paths; the file logger still records the same moments via logger.*, and headless stdout is untouched.
edenreich
added a commit
that referenced
this pull request
Jun 28, 2026
## Summary Adds **command hooks** (#270): the executable sibling of #669's system reminders. Shell commands listed in a dedicated `.infer/hooks.yaml` run at the pre-defined agent-loop hook points (primarily `post_session`, "agent finished generating") for deterministic post-processing — `gofmt`, lint, test, notify. Feature-flagged, off by default. ```yaml # .infer/hooks.yaml enabled: false hooks: - name: gofmt hook: post_session command: "gofmt -w ." timeout: 30 # seconds; 0 -> default 30 ``` ## 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**, not `main` — the diff here is only #270's additive changes. #270 builds directly on #669's `domain.HookPoint` catalog + `dispatchHooks` seam, which are not on `main` yet. **Merge #675 (reminders) first, then this.** Once #675 lands on `main`, this PR retargets to `main` (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 - **One additive line per agent.** `dispatchHooks` gains a `RunCommandHooks(...)` call next to `injectDueReminders`, in both the event-driven chat agent (`internal/agent/agent_utils.go`) and the headless `infer agent` loop (`cmd/agent.go`). Nothing #669 wrote is modified. - **Allow-list gated, secure-by-default.** Each command runs only if it passes the existing per-mode bash allow-list (`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 via `tools.bash.mode.*.allow` or `INFER_TOOLS_BASH_ALLOW_APPEND`. - **One audited chokepoint.** Both agents call the single shared `agent.RunCommandHooks`, so the gate and observability cannot drift between chat and headless. - **Fire-and-observe (v1).** Commands run synchronously under their `timeout`, receive a JSON context on stdin (hook, turn, session id), and emit a `hook_command` stream event (exit code, duration, truncated output). Output is not fed back into the conversation; stdout/exit-code feedback is a later iteration. - Config: dedicated `hooks.yaml` mirroring `reminders.yaml` (split-by-concern), `INFER_HOOKS_ENABLED` master-switch override, generated by `infer init`, validated in `Config.Validate`. ## Verification - `task build`, full `task test` (no failures), `go test -race ./internal/agent/... ./cmd/... ./config/...` (clean), `task lint` (0 issues) - New tests: config truth-table (`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 unattended** - `go run . init` generates `.infer/hooks.yaml` in the documented shape; `task mocks:generate` adds only `FakeHookCommandProvider`; #669's reminder tests still pass Closes #270
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
Generalizes the two hard-coded system reminders (one periodic every N turns, one wrap-up near
max_turns, both injected only pre-stream — with a duplicate copy in the headlessinfer agentloop) into a configurable list of named reminders attached to a shared, pre-defined catalog of agent-loop hook points, living in their own dedicated config file.Closes #669. Establishes the shared catalog + dispatch seam that #270 (Implement Hooks) builds on.
The model: Hook = point (WHERE) + action (WHAT)
A fixed, validated catalog of 8 symmetric pre/post hook points (
domain.HookPoint):pre_sessionpost_sessionpre_streampost_streampre_toolpost_toolpre_queue_drainpost_queue_draindispatchHooks(point)seam.always(default),interval,turns_before_max(replaces the old wrap-up),once.What changed
internal/domain/hooks.go(new): theHookPointcatalog +SystemRemindervalue type.domain.SystemReminderProvider(new interface, counterfeiter-mocked): the agent depends on the interface, not the concrete config.config/reminders.go(new): a dedicatedreminders.yamlconfig (top-levelRemindersConfigwith its own loader/default/env-override), theReminderConfigtype, the pureRemindersDue(...)evaluator implementing the provider interface, and validation (Config.Validaterejects unknown hooks/triggers).dispatchHooksseam wired at all 8 points across the state executors; a per-run fired-set (mutex-guarded, since pre-stream dispatch runs on a different goroutine than the other points) backs theoncetrigger.infer agent: unified onto the same provider/seam (removing the duplicated reminder logic), wiring the clean-boundary points (pre_session,pre_stream,post_tool,post_session).tool_callsand its results, so the mid-turn hooks can't orphan a tool call.Migration (no backward compatibility)
Reminders move out of
prompts.yaml(agent.system_reminders) into a dedicated.infer/reminders.yaml, and the flat fields are removed:infer initseedsreminders.yaml; the default ships one disabledtodo-hygienereminder (preserving the off-by-default posture from #525). The master switch also takesINFER_REMINDERS_ENABLED. Because reminders ship disabled by default, real-world impact is limited to configs that customized those fields. The companion executable hooks (#270) will get their ownhooks.yaml, keeping "inject text" and "run code" as separate concerns.Test plan
task build— passestask test(full suite) — passesgo test -race ./internal/agent/... ./cmd/... ./config/...— clean (validates the fired-set across goroutines)task lint— 0 issuesconfig/reminders_test.go: trigger truth table, hook filtering, stacking,oncesuppression, validation, default config, and a save/load round-tripagent_reminder_emission_test.go: per-hook dispatch, emission tagged withhook+name, the orphan-tool-call guard, and the provider interface via the generated fakeTestDispatchHooks_Remindersincmd/agent_test.goinfer init --overwrite; user-curated.infer/*.yamlrestoredNot run: a live
infer chat --verbosesmoke test (no gateway/LLM in CI), but the above covers every trigger, hook, the fired-set, the guard, and the emission format.Follow-up
A
[DOCS]ticket forinference-gateway/docsis warranted for the newreminders.yamlsurface and the hook-point catalog.