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.
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 ClassesModifier and TypeInterfaceDescriptionstatic final classHolder for the stateless default renderer. -
Method Summary
Modifier and TypeMethodDescriptionstatic ActivityRendererA sensible built-in renderer: a short header followed by one bullet per event, each showing the time, the action (the event'sverb, or a humanised category if none), the labels of any entities it touched, and any authored text.render(List<UserActivityEvent> events) Render the given events into prompt text.
-
Method Details
-
render
Render the given events into prompt text.- Parameters:
events- the matching events, oldest first; nevernull, possibly empty- Returns:
- the text to inject, or an empty string if
eventsis empty
-
compactDefault
A sensible built-in renderer: a short header followed by one bullet per event, each showing the time, the action (the event'sverb, 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
-