feat: context assembler — user signals → structured LLM prompt context #88

Closed
opened 2026-04-17 08:10:50 +00:00 by alvis · 0 comments
Owner

Goal

Build the bridge between the feature store and the LLM. The assembler collects raw signals, normalises them, and returns a structured context object that becomes the LLM prompt.

Inputs

  • Todoist tasks: title, due date, priority, project, age, overdue flag
  • Recent tip reactions: last 5 tips shown + user reaction (done/snooze/dismiss) + dwell time
  • Time context: hour of day, day of week, is_weekend
  • User patterns (from feature store): peak productivity hours, typical snooze patterns, favourite projects

Output

@dataclass
class UserContext:
    tasks: list[TaskSummary]   # top 10 by relevance score
    recent_reactions: list[ReactionSummary]
    time: TimeContext
    patterns: UserPatterns
    
    def to_prompt_text(self) -> str: ...
    def to_system_prompt(self) -> str: ...

Location

ml/features/context.py — import by tip generator endpoint

Notes

  • Keep prompt text under ~800 tokens to leave room for few-shot examples and output schema
  • Content-hash the context for caching (avoid duplicate LLM calls for same context)
  • This is the key input to prompt engineering work (#84)
## Goal Build the bridge between the feature store and the LLM. The assembler collects raw signals, normalises them, and returns a structured context object that becomes the LLM prompt. ## Inputs - Todoist tasks: title, due date, priority, project, age, overdue flag - Recent tip reactions: last 5 tips shown + user reaction (done/snooze/dismiss) + dwell time - Time context: hour of day, day of week, is_weekend - User patterns (from feature store): peak productivity hours, typical snooze patterns, favourite projects ## Output ```python @dataclass class UserContext: tasks: list[TaskSummary] # top 10 by relevance score recent_reactions: list[ReactionSummary] time: TimeContext patterns: UserPatterns def to_prompt_text(self) -> str: ... def to_system_prompt(self) -> str: ... ``` ## Location `ml/features/context.py` — import by tip generator endpoint ## Notes - Keep prompt text under ~800 tokens to leave room for few-shot examples and output schema - Content-hash the context for caching (avoid duplicate LLM calls for same context) - This is the key input to prompt engineering work (#84)
alvis added this to the M2 — AI tips + multi-source signals milestone 2026-04-17 08:10:50 +00:00
alvis closed this issue 2026-04-17 14:22:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alvis/oO#88