Rename sessions by targeting the correct session_history.displayName record.
sessions.renamesession_history.displayNamesessionKey unless the user explicitly wants that.The canonical storage is the SQLite table:
session_historysessionIddisplayNameBackend implementation:
src/gateway/server-methods/sessions.ts → sessions.renamesrc/config/sessions/history-db.ts → updateSessionName(db, sessionId, name)The backend ultimately runs SQL equivalent to:
UPDATE session_history
SET displayName = ?, updatedAt = ?
WHERE sessionId = ?;
history.db.sessionKeystatus='active'updatedAtdisplayName to the requested title.Use a surgical SQLite update against the target instance's session history DB.
Typical query flow:
python3 - <<'PY'
import sqlite3, time
p='/path/to/history.db'
conn=sqlite3.connect(p)
cur=conn.cursor()
row=cur.execute("select sessionId from session_history where sessionKey=? and status='active' order by updatedAt desc limit 1", ('agent:main:main',)).fetchone()
if not row:
row=cur.execute("select sessionId from session_history where sessionKey=? order by updatedAt desc limit 1", ('agent:main:main',)).fetchone()
if not row:
raise SystemExit('No session row found')
cur.execute(
"update session_history set displayName=?, updatedAt=? where sessionId=?",
('New Session Title', int(time.time()*1000), row[0]),
)
conn.commit()
print(cur.execute("select sessionId, sessionKey, displayName, status from session_history where sessionId=?", (row[0],)).fetchone())
conn.close()
PY
Typical path shape:
~/.openclaw/agents/<agent-id>/sessions/history.db
If the location is unknown, search for SQLite DBs containing a session_history table before writing.
sessionId; only change displayName and updatedAt.A successful DB write may still require a UI refresh to show the new title. If the rename does not appear immediately, refresh the Sessions view or reconnect the UI.
共 1 个版本