102 lines
2.4 KiB
Markdown
102 lines
2.4 KiB
Markdown
|
|
# Turn-Based Curator
|
||
|
|
|
||
|
|
Extract gems every N turns instead of waiting for daily curation.
|
||
|
|
|
||
|
|
## Files
|
||
|
|
|
||
|
|
| File | Purpose |
|
||
|
|
|------|---------|
|
||
|
|
| `curator_turn_based.py` | Main script - checks turn count, extracts gems |
|
||
|
|
| `curator_cron.sh` | Cron wrapper to run every minute |
|
||
|
|
| `turn-curator.service` | Alternative systemd service (runs on-demand) |
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
### Manual Run
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Check current status
|
||
|
|
python3 curator_turn_based.py --status
|
||
|
|
|
||
|
|
# Preview what would be curated
|
||
|
|
python3 curator_turn_based.py --threshold 10 --dry-run
|
||
|
|
|
||
|
|
# Execute curation
|
||
|
|
python3 curator_turn_based.py --threshold 10 --execute
|
||
|
|
```
|
||
|
|
|
||
|
|
### Automatic (Cron)
|
||
|
|
|
||
|
|
Add to crontab:
|
||
|
|
```bash
|
||
|
|
* * * * * /root/.openclaw/workspace/.projects/true-recall-v2/tr-continuous/curator_cron.sh
|
||
|
|
```
|
||
|
|
|
||
|
|
Or use systemd timer:
|
||
|
|
```bash
|
||
|
|
sudo cp turn-curator.service /etc/systemd/system/
|
||
|
|
sudo systemctl enable turn-curator.timer # If you create a timer
|
||
|
|
```
|
||
|
|
|
||
|
|
### Automatic (Integrated)
|
||
|
|
|
||
|
|
Alternative: Modify `realtime_qdrant_watcher.py` to trigger curation every 10 turns.
|
||
|
|
|
||
|
|
## How It Works
|
||
|
|
|
||
|
|
1. **Tracks turn count** - Stores last curation turn in `/tmp/curator_turn_state.json`
|
||
|
|
2. **Monitors delta** - Compares current turn count vs last curation
|
||
|
|
3. **Triggers at threshold** - When 10+ new turns exist, runs curation
|
||
|
|
4. **Extracts gems** - Sends conversation to qwen3, gets gems
|
||
|
|
5. **Stores results** - Saves gems to `gems_tr` collection
|
||
|
|
|
||
|
|
## State File
|
||
|
|
|
||
|
|
`/tmp/curator_turn_state.json`:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"last_turn": 150,
|
||
|
|
"last_curation": "2026-02-24T17:00:00Z"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Comparison with Daily Curator
|
||
|
|
|
||
|
|
| Feature | Daily Curator | Turn-Based Curator |
|
||
|
|
|---------|--------------|-------------------|
|
||
|
|
| Schedule | 2:45 AM daily | Every 10 turns (dynamic) |
|
||
|
|
| Time window | 24 hours | Variable (depends on chat frequency) |
|
||
|
|
| Trigger | Cron | Turn threshold |
|
||
|
|
| Use case | Nightly batch | Real-time-ish extraction |
|
||
|
|
| Overlap | Low | Possible with daily curator |
|
||
|
|
|
||
|
|
## Recommendation
|
||
|
|
|
||
|
|
Use **BOTH**:
|
||
|
|
- **Turn-based**: Every 10 turns for active conversations
|
||
|
|
- **Daily**: 2:45 AM as backup/catch-all
|
||
|
|
|
||
|
|
They'll deduplicate automatically (same embeddings → skipped).
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Simulate 10 turns
|
||
|
|
for i in {1..10}; do
|
||
|
|
echo "Test message $i" > /dev/null
|
||
|
|
done
|
||
|
|
|
||
|
|
# Check status
|
||
|
|
python3 curator_turn_based.py --status
|
||
|
|
|
||
|
|
# Run manually
|
||
|
|
python3 curator_turn_based.py --threshold 10 --execute
|
||
|
|
```
|
||
|
|
|
||
|
|
## Status
|
||
|
|
|
||
|
|
- ✅ Script created: `curator_turn_based.py`
|
||
|
|
- ✅ Cron wrapper: `curator_cron.sh`
|
||
|
|
- ⏳ Deployment: Optional (manual or cron)
|
||
|
|
- ⏳ Testing: Pending
|