mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 19:02:10 +00:00
mom: fix duplicate logging
- Remove user message logging from agent.ts (Slack handler already logs it) - Add excludeTimestamp param to syncFromLog to skip current @mention - Sync happens once before each prompt with current message excluded
This commit is contained in:
parent
5a231abe4c
commit
cc71c0a49e
2 changed files with 14 additions and 18 deletions
|
|
@ -70,9 +70,7 @@ export class MomSessionManager {
|
|||
} else {
|
||||
this.sessionId = uuidv4();
|
||||
}
|
||||
|
||||
// Sync missing messages from log.jsonl to context.jsonl
|
||||
this.syncFromLog();
|
||||
// Note: syncFromLog() is called explicitly from agent.ts with excludeTimestamp
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,8 +85,10 @@ export class MomSessionManager {
|
|||
* Channel chatter is formatted as "[username]: message" to distinguish from direct @mentions.
|
||||
*
|
||||
* Called automatically on construction and should be called before each agent run.
|
||||
*
|
||||
* @param excludeTimestamp Optional timestamp to exclude (for the current @mention being processed)
|
||||
*/
|
||||
syncFromLog(): void {
|
||||
syncFromLog(excludeTimestamp?: string): void {
|
||||
if (!existsSync(this.logFile)) return;
|
||||
|
||||
// Get timestamps of messages already in context
|
||||
|
|
@ -118,12 +118,17 @@ export class MomSessionManager {
|
|||
try {
|
||||
const logMsg: LogMessage = JSON.parse(line);
|
||||
|
||||
// Use date for context timestamp (consistent key)
|
||||
const ts = logMsg.date || logMsg.ts;
|
||||
if (!ts) continue;
|
||||
|
||||
// Skip if already in context
|
||||
if (contextTimestamps.has(ts)) continue;
|
||||
|
||||
// Skip the current message being processed (will be added via prompt())
|
||||
// Compare against Slack ts since that's what ctx.message.ts provides
|
||||
if (excludeTimestamp && logMsg.ts === excludeTimestamp) continue;
|
||||
|
||||
// Skip bot messages - added through agent flow
|
||||
if (logMsg.isBot) continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue