91799405aa
Salvaged from PR #36220, ported onto the current SessionStore (SQLite- backed get_or_create_session; activity check is last_prompt_tokens) and the sidecar-note reset path (context notes now ride turn_sidecar_notes instead of prepending to context_prompt). Long-lived Slack/Discord channels/threads lose their context on daily/idle session resets, and the agent can bind a new request to an unrelated recent session (observed: a Discord thread reset caused a PR in the wrong repository). Record prev_session_id when an auto-reset replaces a session with real activity, persist it, and append a deterministic one-line hint to the auto-reset context note pointing the agent at session_search for that specific prior session. No LLM calls, no channel-history APIs, no extra DB lookups; other platforms and activity-free resets are untouched. Refs #36220. Co-authored-by: metamon <269728612+metamon-p@users.noreply.github.com>