Skip to content

API Reference parrot.tools.reminder

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.reminder

View source

One-time reminder tooling for agents — FEAT-115.

Exposes three LLM-facing tools via :class:ReminderToolkit:

  • schedule_reminder — arms a one-shot reminder persisted in APScheduler's Redis jobstore (db=6) so it survives process restarts.
  • list_my_reminders — lists pending reminders owned by the current user.
  • cancel_reminder — cancels a pending reminder owned by the current user.

The top-level coroutine :func:deliver_reminder is the APScheduler-invocable callable. It MUST remain at module scope so APScheduler can serialise its dotted-path reference (parrot.tools.reminder:deliver_reminder).

Alias AbstractToolkit

Re-exported from parrot.tools.toolkit.AbstractToolkit.

Alias NotificationMixin

Re-exported from parrot.notifications.NotificationMixin.

Alias PermissionContext

Re-exported from parrot.auth.permission.PermissionContext.

Class ReminderToolkit

LLM-facing tools to schedule, list, and cancel one-time reminders.

Reminders are stored as APScheduler jobs with trigger="date" in the "redis" jobstore, keyed as reminder-<uuid4>. All per-reminder data (channel, recipients, message, owner) is serialised inside the job's kwargs payload — no new database schema is introduced.

Ownership is enforced server-side via :class:~parrot.auth.permission.PermissionContext injected through the _pre_execute lifecycle hook. The LLM cannot spoof the requested_by field.

Parameter Type Default Description
scheduler_manager Any An :class:~parrot.scheduler.AgentSchedulerManager instance (or any object exposing a .scheduler attribute that implements the APScheduler AsyncIOScheduler API).
**kwargs Any {} Forwarded to :class:~parrot.tools.toolkit.AbstractToolkit.

Method ReminderToolkit.schedule_reminder

Schedule a one-time reminder delivered to the current user.

Exactly one of delay_seconds or remind_at must be supplied. The reminder is persisted in the Redis jobstore and survives process restarts. After firing, the job is automatically removed by APScheduler's DateTrigger semantics.

schedule_reminder(message: str, delay_seconds: int | None = None, remind_at: str | None = None, channel: str = 'telegram') -> dict[str, Any]

Parameter Type Default Description
message str The reminder text to deliver to the user.
delay_seconds int | None None Number of seconds from now until the reminder fires. Mutually exclusive with remind_at.
remind_at str | None None Absolute ISO-8601 datetime (timezone-aware recommended) at which the reminder fires. Mutually exclusive with delay_seconds.
channel str 'telegram' Notification channel to use. Supported values: "telegram" (default), "email", "slack", "teams".

Returns: dict[str, Any] — A dict with keys reminder_id, fires_at (ISO-8601 UTC), and channel.

Raises:

  • ValueError — If both or neither of delay_seconds / remind_at are provided, if the caller's channel-specific identifier is absent from :attr:PermissionContext.extra, or if scheduler_manager is not connected to a live Redis jobstore.

Method ReminderToolkit.list_my_reminders

List pending reminders owned by the current user.

Filters the Redis jobstore to return only jobs whose id starts with reminder- and whose requested_by field matches the caller's user_id.

list_my_reminders() -> list[dict[str, Any]]

Returns: list[dict[str, Any]] — A list of dicts, each with keys reminder_id, fires_at (ISO-8601 or None if already firing), channel, and message.

Raises:

  • ValueError — If no active :class:~parrot.auth.permission.PermissionContext is available.

Method ReminderToolkit.cancel_reminder

Cancel a pending reminder owned by the current user.

cancel_reminder(reminder_id: str) -> dict[str, Any]

Parameter Type Default Description
reminder_id str The reminder-<uuid> identifier returned by :meth:schedule_reminder.

Returns: dict[str, Any] — A dict with keys status ("cancelled" or "not_found") and reminder_id.

Raises:

  • ValueError — If no active :class:~parrot.auth.permission.PermissionContext is available.
  • PermissionError — If the reminder belongs to a different user.

Function deliver_reminder

Fire a reminder by delivering it through the requested notification channel.

Invoked directly by APScheduler's AsyncIOExecutor when the DateTrigger fires. After execution, APScheduler automatically removes the exhausted job from the jobstore — no manual cleanup is required.

deliver_reminder(*, provider: str, recipients: list, message: str, requested_by: str, requested_at: str, bot_id: str | None = None) -> None

Parameter Type Default Description
provider str Notification channel ("telegram", "email", "slack", "teams").
recipients list List of channel-specific recipient identifiers (e.g. Telegram chat ids, email addresses, Slack user ids, Teams conversation ids).
message str Free-form reminder text provided by the user at schedule time.
requested_by str user_id of the user who scheduled the reminder. Stored for audit purposes; not used for delivery logic here.
requested_at str ISO-8601 UTC timestamp of when the reminder was scheduled. Included in the delivered message prefix.
bot_id str | None None For Telegram reminders, the non-secret numeric id of the bot that scheduled the reminder. Used to resolve the matching token from :data:_TELEGRAM_BOT_TOKENS so delivery goes through the originating bot. When None or unregistered, the provider falls back to the global TELEGRAM_BOT_TOKEN env default (legacy behaviour).

Attribute logger

Function register_telegram_bot

Register a Telegram bot token under its non-secret numeric id.

Called by the Telegram integration when a bot starts so that :func:deliver_reminder can deliver through the same bot the user interacted with.

register_telegram_bot(bot_id: str | int, bot_token: str) -> None

Parameter Type Default Description
bot_id str | int The bot's Telegram numeric id (token prefix before :).
bot_token str The full <id>:<secret> bot token.

Function unregister_telegram_bot

Remove a previously registered Telegram bot token.

unregister_telegram_bot(bot_id: str | int) -> None

Parameter Type Default Description
bot_id str | int The bot's Telegram numeric id used at registration time.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally