reminders

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package reminders provides conditional mid-conversation prompt injection.

Reminders are user-authored prompts with trigger conditions. When a trigger evaluates to true, the reminder content is injected into the model context (either as a system message or a user message with [SYSTEM REMINDER] prefix, depending on model capabilities).

Each reminder fires at most once per trigger event: it fires when the condition transitions from false → true, then re-arms when the condition becomes false again.

All evaluation is deterministic — no LLM calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithState

func WithState(ctx context.Context, s *State) context.Context

WithState returns a context carrying reminder state.

Types

type EvalContext

type EvalContext struct {
	ContextUsage       float64 // 0.0–1.0
	LastResponseTokens int64
	LastToolFailed     bool
	TurnCount          int
	LastToolName       string
}

EvalContext carries runtime metrics for trigger evaluation.

type Reminder

type Reminder struct {
	Name    string
	Trigger Trigger
	Content string
}

Reminder is a parsed, ready-to-evaluate conditional injection.

type State

type State struct {
	// contains filtered or unexported fields
}

State tracks per-reminder armed/fired status for fire-once semantics.

func NewState

func NewState(reminders []Reminder) *State

NewState creates a State that tracks the given reminders.

func StateFromContext

func StateFromContext(ctx context.Context) *State

StateFromContext retrieves reminder state from ctx. Returns nil when absent.

func (*State) Evaluate

func (s *State) Evaluate(ec EvalContext) []Reminder

Evaluate checks all reminders against the current eval context and returns those that should fire (false→true transition). Manual reminders never fire from Evaluate — use FireManual instead.

func (*State) FireManual

func (s *State) FireManual(name string) (Reminder, bool)

FireManual returns the reminder with the given name (for /remind command), regardless of trigger state. Returns (Reminder{}, false) if not found.

func (*State) ReminderNames

func (s *State) ReminderNames() []string

ReminderNames returns the names of all tracked reminders.

type Trigger

type Trigger struct {
	Kind     string // "context_usage", "turn_count", "last_response_tokens", "last_tool_call_failed", "tool_used", "manual"
	Operator string // ">", ">=", "==", "<", "<=" (unused for bool/string triggers)
	Value    string // numeric threshold, tool name, or "true"/"false"
}

Trigger describes a condition that causes a reminder to fire.

func ParseTrigger

func ParseTrigger(s string) (Trigger, error)

ParseTrigger parses a trigger expression string.

Supported formats:

"context_usage > 0.75"
"turn_count >= 10"
"last_response_tokens > 4000"
"last_tool_call_failed"           → implied "== true"
"tool_used == bash"
"manual"                          → only fires via explicit /remind

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL