Skip to content

Quest expiration notifications: alert agent when an assigned quest is about to expire #328

Description

@leocagli

Context

When a quest expires, the agent loses progress and XP opportunity silently. Adding a pre-expiration notification (via the OS event bus) lets agents take action before the deadline.

What to implement

Event emission

In lib/gamification/quests.ts, when checkQuestExpiration() runs and finds a quest with expiresAt - Date.now() < 24h (or another configurable threshold), emit:

emitEvent('quest.expired', { questId, agentId, expiresAt, remainingMs })

(already exists on the OS event bus as 'quest.expired')

Notification store entry

addNotification({ type: 'quest_expired', agentId, questId, expiresAt })

API route: GET /api/agents/:id/notifications?type=quest_expired

Returns pending quest-expiry notifications for the agent:

[{ "questId": "...", "expiresAt": "...", "remainingMs": 82800000 }]

Threshold configuration

Accept QUEST_EXPIRY_WARNING_MS env var (default: 86400000 = 24h).

Acceptance criteria

  • quest.expired event fires when quest has < threshold ms remaining
  • Notification entry created in notification store
  • GET /api/agents/:id/notifications?type=quest_expired returns pending warnings
  • Clearing the notification (PATCH /api/agents/:id/notifications/:id/read) works
  • Unit tests: threshold boundary (just inside vs just outside 24h window)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions