Warning, /swf-testbed/ai_memory/README.md is written in an unsupported language. File is not indexed.
0001 # AI Memory - Cross-Session Context for Claude Code
0002
0003 This component enables AI dialogue persistence across Claude Code sessions.
0004 When enabled, your conversations with Claude are recorded and loaded into
0005 new sessions, providing continuity without manual re-explanation.
0006
0007 ## How It Works
0008
0009 1. **Recording**: Claude Code hooks capture each exchange (user prompt + assistant response)
0010 2. **Storage**: Exchanges are stored in the swf-testbed PostgreSQL database
0011 3. **Loading**: At session start, recent dialogue is loaded into Claude's context
0012
0013 ## Opt-In
0014
0015 Set the `SWF_DIALOGUE_TURNS` environment variable:
0016
0017 ```bash
0018 # Enable with 20 conversation turns (40 messages)
0019 export SWF_DIALOGUE_TURNS=20
0020
0021 # Disable (default)
0022 export SWF_DIALOGUE_TURNS=0
0023 # or unset
0024 ```
0025
0026 Add to your shell profile (`.bashrc`, `.zshrc`) to persist.
0027
0028 ## Setup
0029
0030 The hooks are configured in `.claude/settings.json`. They call the Python
0031 scripts in this directory:
0032
0033 - `load.py` - Called at SessionStart, loads SYSPROMPT.md + recent dialogue
0034 - `record.py` - Called at UserPromptSubmit and Stop, records exchanges
0035
0036 ## Requirements
0037
0038 - swf-monitor must be running (provides the REST API)
0039 - `SWF_MONITOR_HTTP_URL` environment variable (default: http://pandaserver02.sdcc.bnl.gov/swf-monitor)
0040
0041 ## Privacy Notes
0042
0043 - Dialogue is stored in the shared swf-testbed database
0044 - Only your username's dialogue is loaded into your sessions
0045 - This is for swf-testbed project development only
0046 - Don't enable for sensitive/private conversations
0047
0048 ## Files
0049
0050 ```
0051 ai_memory/
0052 ├── __init__.py # Package init
0053 ├── load.py # SessionStart hook - loads context
0054 ├── record.py # UserPromptSubmit/Stop hook - records exchanges
0055 └── README.md # This file
0056 ```
0057
0058 ## Troubleshooting
0059
0060 **No dialogue loading?**
0061 - Check `SWF_DIALOGUE_TURNS` is set and > 0
0062 - Check swf-monitor is running
0063 - Check hooks are configured in `.claude/settings.json`
0064
0065 **Errors in hooks?**
0066 - Hooks run silently - check swf-monitor logs for API errors
0067 - Test manually: `echo '{}' | python ai_memory/load.py`