Problem
Config.js defines MAX_MESSAGE_CONTEXT, but messageAI calls getRecentHistory(jid) without a limit. MessageDatabase.getRecentHistory defaults to 999999999, so every message in a chat can be loaded and sent through the response flow as the conversation grows.
This can increase memory use, model input size, and API cost over time. It also makes the configured context limit misleading.
Expected behavior
The AI response path should load only a bounded number of recent messages, while preserving chronological order for the messages that are retained.
Suggested direction
Pass MAX_MESSAGE_CONTEXT into getRecentHistory (or make the database helper use the configured default), then verify that the selected rows remain ordered from oldest to newest.
Acceptance criteria
- The response path no longer loads unbounded history.
MAX_MESSAGE_CONTEXT is the single visible limit used for normal AI context.
- The retained messages are still returned in chronological order.
- A focused test or reproducible verification demonstrates that older messages are excluded.
Problem
Config.jsdefinesMAX_MESSAGE_CONTEXT, butmessageAIcallsgetRecentHistory(jid)without a limit.MessageDatabase.getRecentHistorydefaults to999999999, so every message in a chat can be loaded and sent through the response flow as the conversation grows.This can increase memory use, model input size, and API cost over time. It also makes the configured context limit misleading.
Expected behavior
The AI response path should load only a bounded number of recent messages, while preserving chronological order for the messages that are retained.
Suggested direction
Pass
MAX_MESSAGE_CONTEXTintogetRecentHistory(or make the database helper use the configured default), then verify that the selected rows remain ordered from oldest to newest.Acceptance criteria
MAX_MESSAGE_CONTEXTis the single visible limit used for normal AI context.