Skip to content

Commit a313282

Browse files
committed
fix: fetch participants in processAgentCompletion for Gmail context
Previously participants was empty, so interaction agent had no Gmail integration context when processing agent completions (like Gmail connected notifications).
1 parent 9bf7246 commit a313282

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

apps/interaction-worker/src/services/process-message/process-agent-completion.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { agents, messages as messagesTable, parts } from "@poppy/db";
1+
import {
2+
agents,
3+
conversationParticipants,
4+
messages as messagesTable,
5+
parts,
6+
users,
7+
} from "@poppy/db";
28
import { logger } from "@poppy/hono-helpers";
39
import { formatAgentConversation } from "@poppy/lib";
410
import { generateId } from "ai";
@@ -143,6 +149,15 @@ export const processAgentCompletion = async (
143149
throw new Error(`Conversation not found: ${conversationId}`);
144150
}
145151

152+
// Fetch participants for this conversation
153+
const participantRows = await db
154+
.select({ user: users })
155+
.from(conversationParticipants)
156+
.innerJoin(users, eq(users.id, conversationParticipants.userId))
157+
.where(eq(conversationParticipants.conversationId, conversationId));
158+
159+
const participants = participantRows.map((row) => row.user);
160+
146161
// Fetch the newly inserted message with its parts
147162
const newMessage = await db.query.messages.findFirst({
148163
where: eq(messagesTable.id, messageId),
@@ -190,7 +205,7 @@ export const processAgentCompletion = async (
190205
message: msg,
191206
parts: msg.parts,
192207
})),
193-
participants: [],
208+
participants,
194209
env,
195210
db,
196211
interactionAgentId: interactionAgent.id,

0 commit comments

Comments
 (0)