Skip to content

feat(core): add file-based memory, persona, and tools (ENG-381) - #4

Merged
folathecoder merged 2 commits into
mainfrom
eng-381-5-memory-and-persona
Oct 18, 2026
Merged

folathecoder merged 2 commits into
mainfrom
eng-381-5-memory-and-persona

Conversation

@folathecoder

Copy link
Copy Markdown
Contributor

Summary

Adds Aldwin's local file-based memory (memory/profile.md and memory/notes/YYYY-MM-DD.md) and user-controlled persona (persona.md), along with the remember, recall, and set_persona Agentling tools. Anything that sits permanently in the prompt (profile.md and persona.md) is written or explicitly approved by the user (y/n), while agent-written daily notes are sanitized, locked with fcntl.flock, and fade from the system prompt after 7 days.

Ticket

ENG-381 (Dev plan: ENG-392, Test plan: ENG-395).
Closes ENG-381.

Changes

  • Memory (src/aldwin/core/memory.py):
    • Implement sanitize_note_text, _notes_lock (fcntl.flock on memory/.lock), remember_note, and recall_notes (1–300 chars, marker/comment stripping, 7-day normalised duplicate detection, and word search across up to 92 days).
    • Implement read_profile, pop_profile_truncation_warning, memory_block (<memory> wrapper, ## Profile capped at 4,000 chars, ## Recent notes capped at 4,000 chars keeping whole lines newest-first), and memory_summary.
  • Persona (src/aldwin/core/persona.py):
    • Implement read_persona (shipped default fallback, 2,000-char prompt cap with one-time log warning), write_persona, persona_text, and persona_summary.
  • Agentling tools (src/aldwin/core/tools/):
    • Add RememberTool (remember), RecallTool (recall), and SetPersonaTool (set_persona, gated by ask("Update persona?", detail=...)).
  • Context, agent, and client bridge (src/aldwin/core/context.py, src/aldwin/core/agent.py, src/aldwin/host/in_process.py, src/aldwin/client/):
    • Wire read_persona and memory_block into build_context and default tools into build_agent.
    • Expose get_memory_summary, get_persona_text, get_persona_summary, and pop_profile_truncation_warning through aldwin.host and aldwin.client so aldwin.cli never imports aldwin.core.
  • Tests (tests/test_memory.py, tests/test_persona.py):
    • Add 20 unit, concurrency, and host/client integration tests covering TC-01–TC-12 and TC-14–TC-21.

How it was tested

  • Automated: uv run pytest --cov=aldwin — 138 passed (95% total coverage; 95% on core/memory.py, 96% on core/persona.py, 100% on core/tools/*, < 10 ms on 30 days of notes).
  • Static checks: uv run ruff check src tests, uv run ruff format --check src tests, and uv run mypy --strict on new modules — all passed with 0 errors.

Notes for reviewers

  • Interactive CLI rendering of /memory, /persona, and the approval panel is scoped to ENG-383.

Folarin Akinloye added 2 commits October 18, 2026 01:11
Add memory/profile.md and memory/notes/YYYY-MM-DD.md handling with fcntl.flock locking, persona.md read/write with y/n approval, RememberTool, RecallTool, SetPersonaTool, context integration, and client inspection helpers.
@folathecoder
folathecoder merged commit 5cab250 into main Oct 18, 2026
4 checks passed
@folathecoder
folathecoder deleted the eng-381-5-memory-and-persona branch October 18, 2026 00:28
@folathecoder folathecoder self-assigned this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant