Skip to content

feat(reminders): configurable reminders on a shared hook-point catalog - #675

Merged
edenreich merged 5 commits into
mainfrom
feat/669-flexible-system-reminders
Jun 28, 2026
Merged

edenreich merged 5 commits into
mainfrom
feat/669-flexible-system-reminders

Conversation

@edenreich

@edenreich edenreich commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

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 headless infer agent loop) 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 post
pre_session post_session
pre_stream post_stream
pre_tool post_tool
pre_queue_drain post_queue_drain

What changed

  • internal/domain/hooks.go (new): the HookPoint catalog + SystemReminder value type.
  • domain.SystemReminderProvider (new interface, counterfeiter-mocked): the agent depends on the interface, not the concrete config.
  • config/reminders.go (new): a dedicated reminders.yaml config (top-level RemindersConfig with its own loader/default/env-override), the ReminderConfig type, the pure RemindersDue(...) evaluator implementing the provider interface, and validation (Config.Validate rejects unknown hooks/triggers).
  • Event-driven agent: one dispatchHooks seam 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 the once trigger.
  • Headless 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).
  • Correctness guard: a reminder (a user message) is never injected between an assistant turn's tool_calls and 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:

# before — prompts.yaml
agent:
  system_reminders:
    enabled: false
    interval: 4
    reminder_text: "..."
    wrap_up_text: "..."
    wrap_up_threshold: 0

# after — reminders.yaml
enabled: false
reminders:
  - name: todo-hygiene
    text: "..."
    hook: pre_stream
    trigger: interval
    interval: 4

infer init seeds reminders.yaml; the default ships one disabled todo-hygiene reminder (preserving the off-by-default posture from #525). The master switch also takes INFER_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 own hooks.yaml, keeping "inject text" and "run code" as separate concerns.

Test plan

  • task build — passes
  • task test (full suite) — passes
  • go test -race ./internal/agent/... ./cmd/... ./config/... — clean (validates the fired-set across goroutines)
  • task lint — 0 issues
  • config/reminders_test.go: trigger truth table, hook filtering, stacking, once suppression, validation, default config, and a save/load round-trip
  • Rewritten agent_reminder_emission_test.go: per-hook dispatch, emission tagged with hook+name, the orphan-tool-call guard, and the provider interface via the generated fake
  • Headless TestDispatchHooks_Reminders in cmd/agent_test.go
  • Config regenerated via infer init --overwrite; user-curated .infer/*.yaml restored

Not run: a live infer chat --verbose smoke 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 for inference-gateway/docs is warranted for the new reminders.yaml surface and the hook-point catalog.

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
edenreich requested a review from a team as a code owner June 28, 2026 02:07
Comment thread cmd/agent_test.go Resolved
Comment thread config/prompts.go Resolved
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
edenreich merged commit 179cad1 into main Jun 28, 2026
1 check passed
@edenreich
edenreich deleted the feat/669-flexible-system-reminders branch June 28, 2026 10:44
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)
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.125.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Flexible system reminders: multiple reminders across the agent loop

1 participant