This commit is contained in:
Timothy Jaeryang Baek
2026-04-01 06:00:53 -05:00
parent 0e5696de74
commit 15883e5229
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -169,7 +169,10 @@ class ChatMessageTable:
info = data.get('info', {})
usage = info.get('usage') if info else None
if usage:
existing.usage = usage
# Deep-merge: preserve existing keys not present in new data
# This prevents background tasks (follow-ups, title, tags)
# from accidentally clearing the primary response's token counts
existing.usage = {**(existing.usage or {}), **usage}
existing.updated_at = now
db.commit()
db.refresh(existing)