Interface ActivityRenderer

All Known Implementing Classes:
ActivityRenderer.CompactDefault
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ActivityRenderer
Turns a slice of the activity timeline into the plain text that gets injected into an AI prompt — the bridge between structured UserActivityEvents and the words the model actually reads.

What this interface is for

The store keeps activity as typed objects, but a language model consumes text. An ActivityRenderer decides how those objects become a short, readable briefing: which fields to show, in what order, how terse. Keeping this swappable means you can tune the wording for your model or domain without touching capture or storage.

Familiar analogy: a chief-of-staff writing the one-paragraph morning brief from a stack of memos. The memos (events) are structured and complete; the brief is a deliberately compact prose summary tuned for the person who has to read it in ten seconds. The renderer is that chief-of-staff.

Contract for implementations

  • Empty in, empty out. Given an empty list, return an empty string — that signals the caller to inject nothing rather than an awkward "no activity" line.
  • Assume chronological input. The store hands events oldest-first; a renderer should preserve that order so the model reads a natural timeline.
  • Stay compact. This text spends prompt tokens on every AI call, so favour labels over blobs (one line per event is the intended scale).

This is a FunctionalInterface, so a custom renderer is typically a lambda; for the common case use the ready-made compactDefault().

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Holder for the stateless default renderer.
  • Method Summary

    Modifier and Type
    Method
    Description
    A sensible built-in renderer: a short header followed by one bullet per event, each showing the time, the action (the event's verb, or a humanised category if none), the labels of any entities it touched, and any authored text.
    Render the given events into prompt text.
  • Method Details

    • render

      String render(List<UserActivityEvent> events)
      Render the given events into prompt text.
      Parameters:
      events - the matching events, oldest first; never null, possibly empty
      Returns:
      the text to inject, or an empty string if events is empty
    • compactDefault

      static ActivityRenderer compactDefault()
      A sensible built-in renderer: a short header followed by one bullet per event, each showing the time, the action (the event's verb, or a humanised category if none), the labels of any entities it touched, and any authored text.

      Example output:

       Recent user activity in this tab (oldest first):
       - 14:03 opened Order #4711 — ACME
       - 14:04 searched "unpaid invoices"
       - 14:05 approved Order #4711 — ACME
       

      Analogy: the default brief format — clean bullets, newest at the bottom, just enough for the reader to say "ah, 'this' must be order 4711".

      Returns:
      a reusable, stateless ActivityRenderer