A complete, zero-LLM pipeline for agents to learn from user feedback. Track what works, catch what doesn't, promote durable rules.
text
User feedback / exec error
↓
detect-feedback.py ←── error-catcher.sh (PostToolUse hook)
↓
log-event.sh ──────────────────────────────────────────→ events.jsonl
↓
analyze-patterns.py (nightly)
↓
patterns.json
(positive + negative patterns)
↓ (≥3 hits, delta test)
genes.json
(structured rules: condition→action)
↓
weekly-report.py (Sundays)
↓
reports/WEEKLY_*.md
SituationActionUser gives positive feedbacklog-event.sh <agent> positive user_nlp "<ctx>" "<signal>"User corrects/complainslog-event.sh <agent> correction user_nlp "<ctx>" "<signal>" "<lesson>"Exec command failedlog-event.sh <agent> error exec_fail "<ctx>" "<stderr>" "<lesson>"Detect feedback from textpython3 detect-feedback.py "переделай это"Run pattern analysis nowpython3 analyze-patterns.pyGenerate report nowpython3 weekly-report.pyCheck active rules (genes)python3 check-genes.pyMark gene as resolvedpython3 check-genes.py --resolve <gene_id>
bash
DIR="${FEEDBACK_LEARNING_DIR:-$HOME/.openclaw/shared/learning}"
mkdir -p "$DIR/reports"
cp scripts/* "$DIR/"
chmod +x "$DIR/log-event.sh" "$DIR/error-catcher.sh"
touch "$DIR/events.jsonl"
bash
DIR="${FEEDBACK_LEARNING_DIR:-$HOME/.openclaw/shared/learning}"
[ -f "$DIR/patterns.json" ] || cat > "$DIR/patterns.json" << 'EOF'
{"version": "2.1", "updated": "", "patterns": {"negative": [], "positive": []}}
EOF
[ -f "$DIR/genes.json" ] || cat > "$DIR/genes.json" << 'EOF'
{"version": "2.1", "rules": []}
EOF
[ -f "$DIR/capsules.json" ] || cat > "$DIR/capsules.json" << 'EOF'
{"version": "2.1", "capsules": []}
EOF
markdown
## Feedback Learning
Before tasks: check `$FEEDBACK_LEARNING_DIR/genes.json` for applicable rules.
Auto-detect and log signals:
- Positive words/emoji → `bash $DIR/log-event.sh <agent> positive user_nlp "<ctx>" "<signal>"`
- Negative/correction → `bash $DIR/log-event.sh <agent> correction user_nlp "<ctx>" "<signal>" "<lesson>"`
- Exec fail (exit≠0) → `bash $DIR/log-event.sh <agent> error exec_fail "<ctx>" "<stderr[:200]>" "<lesson>"`
text
# Pattern analysis (nightly 3:30 AM)
schedule: cron 30 3 * * * @ Europe/Moscow
payload: python3 ~/.openclaw/shared/learning/analyze-patterns.py
# Weekly report (Sundays 4:00 AM)
schedule: cron 0 4 * * 0 @ Europe/Moscow
payload: python3 ~/.openclaw/shared/learning/weekly-report.py
For Claude Code / Codex hooks:
json
{
"hooks": {
"PostToolUse": [{
"matcher": "Bash",
"hooks": [{"type": "command", "command": "bash ~/.openclaw/shared/learning/error-catcher.sh"}]
}]
}
}
bash
DIR="${FEEDBACK_LEARNING_DIR:-$HOME/.openclaw/shared/learning}"
# Error
bash "$DIR/log-event.sh" anton error exec_fail \
"updating openclaw.json" "SyntaxError: trailing comma" \
"Always validate JSON with python3 -c before writing"
# Positive
bash "$DIR/log-event.sh" anton positive user_nlp \
"generated weekly report" "🔥 огонь!"
# Correction
bash "$DIR/log-event.sh" anton correction user_nlp \
"sent message in wrong format" "не так, в маркдауне давай" \
"Confirm output format before sending to Telegram"
bash
echo "круто, зашло!" | python3 detect-feedback.py
# → {"type": "positive", "source": "user_nlp", "signal": "круто", "confidence": 0.8}
python3 detect-feedback.py "переделай это, не тот формат"
# → {"type": "correction", "source": "user_nlp", "signal": "переделай", "confidence": 0.8}
# Pipe mode for hook usage
echo "$TOOL_OUTPUT" | python3 detect-feedback.py --pipe | bash log-event.sh auto
bash
python3 check-genes.py
# Lists active rules, signals stale ones
python3 check-genes.py --filter exec_fail
# Filter by type
python3 check-genes.py --resolve gene_20260310_120000_0
# Mark a resolved rule as inactive
FilePurposeevents.jsonlAppend-only event log (all feedback), deduped by content hashpatterns.jsonGrouped patterns: BOTH positive and negative, with countsgenes.jsonPromoted structured rules (condition → action → context)capsules.jsonSuccessful reasoning paths to avoid re-computationreports/Weekly synthesis reports
json
{
"ts": "2026-03-20T12:00:00Z",
"id": "sha256_first8",
"agent": "anton",
"type": "error|correction|positive|requery",
"source": "exec_fail|user_nlp|user_emoji|requery|auto",
"context": "what agent was doing",
"signal": "the trigger text or emoji",
"hint": "suggested fix or rule",
"heat": 1
}
json
{
"id": "gene_20260310_120000_0",
"status": "active|stale|resolved|wont-fix",
"origin": "original signal/pattern text",
"type": "error|correction|positive",
"condition": "When doing X",
"action": "Do Y instead of Z",
"context": "Additional context",
"agents": ["anton"],
"occurrences": 3,
"last_seen": "2026-03-20T...",
"promoted_at": "2026-03-20T...",
"expires": null,
"active": true
}
events.jsonl (deduped by hash)analyze-patterns.py groups similar events (both positive AND negative)condition, action, contextstale and escalateweekly-report.py includes gene health: active / stale / resolved countsFeaturev1v2Positive pattern tracking❌ skipped✅ tracked separatelyGene structure"AVOID: key_text"``condition → action → contextGene lifecycleactive onlyactive / stale / resolved / wont-fixBehavioral Delta Test❌✅ promotes only if rule changes future behaviorStagnation detection❌✅ re-occurring genes flagged as stalePath configurationhardcoded$FEEDBACK_LEARNING_DIR env varEvent deduplication❌✅ content hashHook integration❌✅ error-catcher.sh for PostToolUseGene check utility❌✅ check-genes.pyGene expiry❌✅ 90-day inactivity auto-expire