Skip to content

Explore pre-prompt hooks for seamless memory injection #4

@nikomatsakis

Description

@nikomatsakis

Pre-Prompt Hooks for Seamless Memory Injection

Status: Planning - Future Enhancement

Current Understanding

Explore using pre-prompt hooks to automatically inject relevant memories into conversations, making memory retrieval seamless rather than explicit. This would complement the existing MCP tools with ambient context awareness.

Proposed Architecture

Primary: Hook-based ambient memory

  • Pre-prompt hook intercepts user messages
  • Smaller specialized LLM analyzes current context ("debugging Rust async", "project planning", etc.)
  • Hook searches Hippo for relevant memories based on detected context
  • Memories injected into system prompt before main LLM processes user message
  • User gets contextually-aware responses without explicit memory requests

Secondary: Explicit search for power users

  • Keep existing hippo_search_insights for deliberate memory exploration
  • Use MCP tools during consolidation for recording insights and applying feedback
  • Handle edge cases where automatic injection isn't sufficient

Next Steps

  • Research Q CLI pre-prompt hook capabilities and API
  • Design context detection approach (keywords, conversation themes, message analysis)
  • Prototype memory injection format (system context vs conversation history)
  • Evaluate performance impact and latency considerations
  • Design A/B testing framework to measure memory injection effectiveness

Open Questions

  • How should the smaller LLM determine current conversation context?
  • What's the optimal format for injecting memories into prompts?
  • How do we balance relevance vs information overload in auto-injection?
  • Should context detection be stateful across conversation turns?
  • What's the performance/latency trade-off for real-time context analysis?

Context

This builds on the current explicit MCP tool approach (Phase 1) to create a more seamless user experience (Phase 2). The goal is ambient memory that "just works" while preserving explicit control for power users.

Key Innovation: Shift from "user asks for memories" to "system proactively provides relevant context" - making AI collaboration feel more natural and contextually aware.

Current MCP tools provide the foundation for storage, search, and feedback. Pre-prompt hooks would add the missing piece: automatic relevance detection and injection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-managedAI can update OP and add commentsfeatureNew feature developmenttracking-issueOngoing work item tracked across sessions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions