fix(gateway): use last_prompt_tokens for session-reset activity check

reset_had_activity gated on entry.total_tokens, which is never written
(token counts migrated to agent-direct persistence) so it was always 0.
That suppressed session-reset notifications for sessions that genuinely
had activity. Switch to last_prompt_tokens, which is updated on every
turn.
This commit is contained in:
Mibayy 2026-06-29 04:07:16 -07:00 committed by Teknium
parent 9e490138a0
commit 0fe9755016

View file

@ -1217,8 +1217,11 @@ class SessionStore:
# Session is being auto-reset.
was_auto_reset = True
auto_reset_reason = reset_reason
# Track whether the expired session had any real conversation
reset_had_activity = entry.total_tokens > 0
# Track whether the expired session had any real conversation.
# total_tokens is never written (token counts migrated to
# agent-direct persistence) so it is always 0 — use
# last_prompt_tokens, which is updated on every turn.
reset_had_activity = entry.last_prompt_tokens > 0
db_end_session_id = entry.session_id
else:
was_auto_reset = False