Skip to content

Add safe prompt framing for retrieved conversation memory #421

@lbedner

Description

@lbedner

Summary

Ensure retrieved memory is framed, timestamped, and has instructions to prefer recent conversation if conflicts exist.

Acceptance Criteria

  • Retrieved hits inserted in concise, framed block with role and timestamp
  • System prompt contains explicit instructions about precedence and uncertainty handling
  • Config values for characters-per-hit cap (trim long hits)
  • Document the prompt format and an example in repo docs

Implementation Notes

  • Add constants for prompt snippet formatting in AI service or prompts module
  • Example framing:
    Retrieved memory (may be incomplete):
    - [2026-01-02 12:34] USER: ...
    - [2026-01-02 12:35] ASSISTANT: ...
    
  • System prompt rules:
    • "If retrieved memory conflicts with recent conversation, prefer recent."
    • "If memory is unclear, ask a clarifying question."

Files to Change

  • app/services/ai/prompts.py - New/edited prompt templates
  • app/cli/docs or README.md - Documentation
  • Tests for prompt formatting

Dependencies

Estimate

4-8 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions