fix(googlechat): expose sender bot status in context (#97825)

* fix(googlechat): expose sender bot status in context

* fix(googlechat): expose sender bot status in context

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
Masato Hoshino
2026-06-30 10:28:47 -07:00
committed by GitHub
co-authored by Vincent Koc
parent 984f5a51ca
commit 37341a7032
2 changed files with 71 additions and 0 deletions
+70
View File
@@ -255,6 +255,76 @@ describe("googlechat monitor inbound space classification", () => {
});
});
describe("googlechat monitor sender bot status", () => {
function botStatusEvent(senderType: "BOT" | "HUMAN", messageId: string): GoogleChatEvent {
return {
type: "MESSAGE",
space: { name: "spaces/DM", type: "DM" },
message: {
name: `spaces/DM/messages/${messageId}`,
text: "hello",
sender: { name: "users/sender", displayName: "Sender", type: senderType },
},
} satisfies GoogleChatEvent;
}
it("forwards bot sender status to the inbound context when allowBots is true", async () => {
const { buildContext, core } = createInboundClassificationHarness();
accessMocks.applyGoogleChatInboundAccessPolicy.mockResolvedValue({
ok: true,
commandAuthorized: undefined,
effectiveWasMentioned: undefined,
groupBotLoopProtection: undefined,
groupSystemPrompt: undefined,
});
await testing.processMessageWithPipeline({
event: botStatusEvent("BOT", "1"),
account: {
accountId: "work",
config: { allowBots: true },
credentialSource: "inline",
} as ResolvedGoogleChatAccount,
config: {},
runtime: { error: vi.fn(), log: vi.fn() },
core,
mediaMaxMb: 10,
});
expect(buildContext).toHaveBeenCalledWith(
expect.objectContaining({ sender: expect.objectContaining({ isBot: true }) }),
);
});
it("omits bot sender status for human senders", async () => {
const { buildContext, core } = createInboundClassificationHarness();
accessMocks.applyGoogleChatInboundAccessPolicy.mockResolvedValue({
ok: true,
commandAuthorized: undefined,
effectiveWasMentioned: undefined,
groupBotLoopProtection: undefined,
groupSystemPrompt: undefined,
});
await testing.processMessageWithPipeline({
event: botStatusEvent("HUMAN", "2"),
account: {
accountId: "work",
config: {},
credentialSource: "inline",
} as ResolvedGoogleChatAccount,
config: {},
runtime: { error: vi.fn(), log: vi.fn() },
core,
mediaMaxMb: 10,
});
expect(buildContext).toHaveBeenCalledWith(
expect.objectContaining({ sender: expect.objectContaining({ isBot: undefined }) }),
);
});
});
describe("googlechat monitor direct messages", () => {
it("creates typing messages by default", async () => {
const runTurn = vi.fn();
+1
View File
@@ -311,6 +311,7 @@ async function processMessageWithPipeline(params: {
id: senderId,
name: senderName || undefined,
username: senderEmail,
isBot: isBotSender || undefined,
},
conversation: {
kind: isGroup ? "channel" : "direct",