fix(slack): ignore stale thread sessions when gating thread-context reseed

A session key that exists in the store but would be rolled to a fresh
session by the reset policy (daily/idle/suspended) is not an active
session. Treating it as active suppressed the first-turn Slack
thread-history reseed after reset (#55239).

_has_active_session_for_thread() now consults SessionStore._should_reset
so a stale entry gates like a missing one, letting _fetch_thread_context
reseed the fresh session with recent thread history.

Fixes #55239.

Salvaged from #55240 by @ooiuuii.
This commit is contained in:
luyifan 2026-07-22 04:15:37 -07:00 committed by Teknium
parent 40c3b62b30
commit 2d71e9e9bc
2 changed files with 42 additions and 1 deletions

View file

@ -5357,7 +5357,20 @@ class SlackAdapter(BasePlatformAdapter):
)
session_store._ensure_loaded()
return session_key in session_store._entries
entry = session_store._entries.get(session_key)
if entry is None:
return False
# A key that exists but would be rolled to a fresh session by the
# reset policy (daily/idle/suspended) is NOT an active session:
# get_or_create_session() will reset it on the next real message,
# so treating it as active here would suppress the first-turn
# thread-history reseed (#55239).
should_reset = getattr(type(session_store), "_should_reset", None)
if callable(should_reset) and should_reset(session_store, entry, source):
return False
return True
except Exception:
return False