Skip to content

Implement Longitudinal Context Retrieval for Journal-wide AI Reflection #118

Description

@Sonmale25

[RFC] Longitudinal Memory Layer for AI-Assisted Reflection

Overview
Currently, sugar-ai operates in a stateless manner regarding reflective practice. While the existing widgets allow a child to reflect on a single session, the system lacks a "memory" of the child's cognitive growth over time. I propose implementing a longitudinal context retrieval system that allows the AI to analyze past journal entries and provide more meaningful, growth-oriented prompts.

The Problem
Reflection is a core part of Constructionist pedagogy, but "stateless" reflection can feel repetitive or disconnected. Without context from previous days or projects, the AI cannot track a learner's evolving goals, recurring struggles, or breakthroughs.

Proposed Feature: User Story
Imagine a student named Leo who has been working on a music project for three days.

  • Day 1: Leo struggled with the tempo.
  • Day 2: Leo successfully used a loop to fix the tempo.
  • Day 3: Instead of asking a generic "What did you do?", the AI retrieves the history and says: "I noticed you solved the tempo issue yesterday using loops! How are you building on that today to make your melody more complex?"

Technical Implementation Sketch
I am proposing the addition of a GET /history/summary/{activity_id} endpoint in the sugar-ai backend to serve as a "Pedagogical Memory Layer."

  • Summarization Engine: Logic in ai.py will use the existing LLM integration to generate a "Growth Summary" based on past JSON metadata from the Sugar Journal/Datastore.
  • Context Injection: This summary can then be injected into the System Prompt of future reflection sessions to drive more targeted questioning.
  • Mock Interface: For the initial Proof of Concept (PoC), I will implement a flexible interface that accepts past reflection strings, allowing for future seamless integration with the sugar-datastore.

Privacy & Safety

  • Data Minimization: Only text-based reflections will be processed; no PII (Personally Identifiable Information) or system secrets will be stored or transmitted.
  • Predictability: The system will gracefully fall back to "Standard Reflection Mode" if no historical data is available for a specific activity or user.

Request for Comments
I am beginning work on a Proof of Concept (PoC) for this feature. I would appreciate feedback on:

  1. Whether the summary should be generated on-the-fly or if a caching mechanism is preferred.
  2. The ideal length for the historical context window to ensure LLM efficiency.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions