mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 14:03:49 +00:00
fix(mom): include triggering message in context
Fix race condition where app_mention event fires before message event logs to log.jsonl, causing the user's triggering message to be missing from the agent's context. Now append the current message directly from ctx.message to recentMessages.
This commit is contained in:
parent
dd9decb9e1
commit
75bb14cc4d
1 changed files with 10 additions and 1 deletions
|
|
@ -364,7 +364,16 @@ export function createAgentRunner(sandboxConfig: SandboxConfig): AgentRunner {
|
|||
|
||||
const channelId = ctx.message.channel;
|
||||
const workspacePath = executor.getWorkspacePath(channelDir.replace(`/${channelId}`, ""));
|
||||
const recentMessages = getRecentMessages(channelDir, 50);
|
||||
const recentMessagesFromLog = getRecentMessages(channelDir, 50);
|
||||
|
||||
// Append the current message (may not be in log yet due to race condition
|
||||
// between app_mention and message events)
|
||||
const currentMsgDate = new Date(parseFloat(ctx.message.ts) * 1000).toISOString().substring(0, 19);
|
||||
const currentMsgUser = ctx.message.userName || ctx.message.user;
|
||||
const currentMsgAttachments = ctx.message.attachments.map((a) => a.local).join(",");
|
||||
const currentMsgLine = `${currentMsgDate}\t${currentMsgUser}\t${ctx.message.rawText}\t${currentMsgAttachments}`;
|
||||
const recentMessages = recentMessagesFromLog + "\n" + currentMsgLine;
|
||||
|
||||
const memory = getMemory(channelDir);
|
||||
const systemPrompt = buildSystemPrompt(
|
||||
workspacePath,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue