Problem or Use Case
The Gateway currently starts a completely fresh session upon restart, causing the AI to "forget" the immediate previous conversation. Although all history is safely stored in state.db, the new session has no mechanism to automatically load or resume context. This breaks conversational continuity and forces users to re-explain context after every restart or update.
Proposed Solution
Add an automatic session recovery hook during Gateway startup (gateway/run.py). The logic should:
- Query
state.db to find the most recent non-cron session.
- Extract the last N (e.g., 30-50) user/assistant messages in chronological order.
- Automatically inject them into the
prefill_messages list for the new session.
This leverages existing infrastructure (state.db + prefill_messages) and requires minimal code changes while providing a seamless "wake-up" experience.
Alternatives Considered
The current workaround is using an external cron job to periodically export SQLite data to a JSON file, which the Gateway reads via prefill_messages_file. This has latency (up to 30 mins) and relies on external scheduling. The proposed native startup hook is instant (0 latency), requires no external dependencies, and is more reliable as it runs exactly when the session initializes.
Feature Type
Other
Scope
None
Contribution
Problem or Use Case
The Gateway currently starts a completely fresh session upon restart, causing the AI to "forget" the immediate previous conversation. Although all history is safely stored in
state.db, the new session has no mechanism to automatically load or resume context. This breaks conversational continuity and forces users to re-explain context after every restart or update.Proposed Solution
Add an automatic session recovery hook during Gateway startup (
gateway/run.py). The logic should:state.dbto find the most recent non-cron session.prefill_messageslist for the new session.This leverages existing infrastructure (
state.db+prefill_messages) and requires minimal code changes while providing a seamless "wake-up" experience.Alternatives Considered
The current workaround is using an external cron job to periodically export SQLite data to a JSON file, which the Gateway reads via
prefill_messages_file. This has latency (up to 30 mins) and relies on external scheduling. The proposed native startup hook is instant (0 latency), requires no external dependencies, and is more reliable as it runs exactly when the session initializes.Feature Type
Other
Scope
None
Contribution