Files
memoryweave/skills/zhiyi/scripts/hermes-memory/memory-sync-check.py
T
xiaowei 2a350cf781 fix(distill): max_tokens 800→1200 — Agnes推理token预算不足
Agnes 2.0-flash是推理模型,推理token占大量预算。
800仍不够→JSON截断(parse error: unexpected end of JSON input)。
1200确保推理+正文都够用。
2026-08-20 01:13:06 +08:00

48 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""hermes-memory 实时同步验证脚本。
直接查 FTS + LanceDB,不依赖 memory_stats 缓存。
用法:
cd /home/muc/.hermes/hermes-agent && source venv/bin/activate && python3 scripts/memory-sync-check.py
"""
import sqlite3, lancedb, sys, importlib
sys.path.insert(0, '/home/muc/.hermes/hermes-agent')
m = importlib.import_module('plugins.memory.hermes-lance')
# FTS 实时
fts_path = '/home/muc/.hermes/memory_db/memory.fts.db'
conn = sqlite3.connect(fts_path)
cur = conn.cursor()
cur.execute("SELECT agent_id, COUNT(*) FROM memory GROUP BY agent_id")
fts_rows = cur.fetchall()
conn.close()
fts_counts = dict(fts_rows)
# LanceDB 实时
db = lancedb.connect(str(m.LANCEDB_PATH))
lance_counts = {}
for name in ['hermes_memory_default', 'hermes_memory_muc', 'hermes_memory_hermes']:
try:
tbl = db.open_table(name)
except Exception:
continue
emb = m._embed_text('的')
results = tbl.search(emb, vector_column_name='vector').limit(1000).to_list()
lance_counts[name] = len(results)
total_fts = sum(fts_counts.values())
total_lance = sum(lance_counts.values())
print(f"FTS: {fts_counts}, total={total_fts}")
print(f"LanceDB: {lance_counts}, total={total_lance}")
print(f"同步: {'✅' if total_fts == total_lance else '❌'} (FTS={total_fts} LanceDB={total_lance})")
# 对比 memory_stats 缓存
try:
stats = m.memory_stats()
print(f"\nmemory_stats (cached): {stats}")
except Exception as e:
print(f"\nmemory_stats error: {e}")
sys.exit(0 if total_fts == total_lance else 1)