Skip to content

Add SystemReminders capability#181

Draft
DouweM wants to merge 2 commits intomainfrom
capability/system-reminders
Draft

Add SystemReminders capability#181
DouweM wants to merge 2 commits intomainfrom
capability/system-reminders

Conversation

@DouweM
Copy link
Copy Markdown
Contributor

@DouweM DouweM commented Apr 10, 2026

Summary

  • Adds SystemReminders capability that injects periodic system messages into model conversations to counteract instruction fade-out in long-running agent sessions
  • Supports static Reminder(content, interval) for fixed-interval injection and dynamic callables (RunContext) -> str | None for conditional injection
  • Per-run state isolation via for_run() ensures concurrent runs don't interfere

Closes #83

Implementation

  • SystemReminders subclasses AbstractCapability and uses the before_model_request hook
  • Static reminders fire every N model requests (configurable interval)
  • Dynamic reminders (sync or async) are called every request and return str to inject or None to skip
  • Reminders are injected as SystemPromptPart entries appended to the last ModelRequest in message history
  • for_run() returns a fresh instance with reset request counter for per-run isolation

Test plan

  • Reminder validation (interval >= 1)
  • SystemReminders requires at least one reminder
  • for_run() returns fresh instance with reset counter
  • Static reminders fire at correct intervals (interval=1, interval=3, multiple different intervals)
  • Sync and async dynamic reminders (returning string and None)
  • Dynamic reminders receive and can use RunContext
  • Mixed static + dynamic reminders
  • Injection appends to last ModelRequest, preserves existing parts, skips ModelResponse messages
  • Creates new ModelRequest when none exists
  • No injection when no reminders fire
  • All checks pass: ruff lint, ruff format, pyright strict, 28 tests, 100% coverage

🤖 Generated with Claude Code

DouweM and others added 2 commits April 2, 2026 05:28
Implements a capability that injects periodic system messages into model
conversations to counteract instruction fade-out in long-running agent
sessions. Supports static interval-based reminders and dynamic callables,
with per-run state isolation via for_run().

Closes #83

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Implements the three audit findings from PR review:

- `trigger: Callable[[RunContext], bool] | None` -- when set, the
  reminder only fires when the predicate returns True (in addition to
  the interval check)
- `max_fires: int | None` -- caps how many times a reminder fires per
  run, tracked via per-reminder counters reset in `for_run()`
- `tag: str | None` -- wraps content in XML tags (e.g.
  `<system-reminder>content</system-reminder>`)

Also adds `render_content()` helper on Reminder and comprehensive tests
for each feature individually and in combination.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@DouweM
Copy link
Copy Markdown
Contributor Author

DouweM commented Apr 10, 2026

Originally posted by @DouweM in #135 comment (PR was recreated)

Audit vs prior art: SystemReminders

Worth adding now:

  • Condition-triggered reminders: trigger: Callable[[RunContext], bool] on Reminder
  • max_fires: int | None to limit how many times a reminder fires
  • Content wrapping in XML tags (Claude Code uses <system-reminder> tags)

Follow-up opportunities:

  • Priority ordering, cooldown periods, template substitution

@DouweM DouweM marked this pull request as draft April 10, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System Reminders / Mid-Session Behavioral Steering

1 participant