fix: normalize session keys and outbound mirroring

This commit is contained in:
Peter Steinberger
2026-01-24 11:57:04 +00:00
parent eaeb52f70a
commit 4b6cdd1d3c
33 changed files with 1357 additions and 145 deletions

View File

@@ -153,8 +153,8 @@ describe("monitorSlackProvider tool results", () => {
SessionKey?: string;
ParentSessionKey?: string;
};
expect(ctx.SessionKey).toBe("agent:main:slack:channel:C1:thread:111.222");
expect(ctx.ParentSessionKey).toBe("agent:main:slack:channel:C1");
expect(ctx.SessionKey).toBe("agent:main:slack:channel:c1:thread:111.222");
expect(ctx.ParentSessionKey).toBe("agent:main:slack:channel:c1");
});
it("injects starter context for thread replies", async () => {
@@ -216,7 +216,7 @@ describe("monitorSlackProvider tool results", () => {
ThreadStarterBody?: string;
ThreadLabel?: string;
};
expect(ctx.SessionKey).toBe("agent:main:slack:channel:C1:thread:111.222");
expect(ctx.SessionKey).toBe("agent:main:slack:channel:c1:thread:111.222");
expect(ctx.ParentSessionKey).toBeUndefined();
expect(ctx.ThreadStarterBody).toContain("starter message");
expect(ctx.ThreadLabel).toContain("Slack thread #general");
@@ -280,7 +280,7 @@ describe("monitorSlackProvider tool results", () => {
SessionKey?: string;
ParentSessionKey?: string;
};
expect(ctx.SessionKey).toBe("agent:support:slack:channel:C1:thread:111.222");
expect(ctx.SessionKey).toBe("agent:support:slack:channel:c1:thread:111.222");
expect(ctx.ParentSessionKey).toBeUndefined();
});

View File

@@ -56,7 +56,7 @@ describe("resolveSlackSystemEventSessionKey", () => {
it("defaults missing channel_type to channel sessions", () => {
const ctx = createSlackMonitorContext(baseParams());
expect(ctx.resolveSlackSystemEventSessionKey({ channelId: "C123" })).toBe(
"agent:main:slack:channel:C123",
"agent:main:slack:channel:c123",
);
});
});

View File

@@ -48,7 +48,7 @@ describe("prepareSlackMessage sender prefix", () => {
logger: { info: vi.fn() },
markMessageSeen: () => false,
shouldDropMismatchedSlackEvent: () => false,
resolveSlackSystemEventSessionKey: () => "agent:main:slack:channel:C1",
resolveSlackSystemEventSessionKey: () => "agent:main:slack:channel:c1",
isChannelAllowed: () => true,
resolveChannelName: async () => ({
name: "general",

View File

@@ -408,7 +408,8 @@ export function registerSlackMonitorSlashCommands(params: {
WasMentioned: true,
MessageSid: command.trigger_id,
Timestamp: Date.now(),
SessionKey: `agent:${route.agentId}:${slashCommand.sessionPrefix}:${command.user_id}`,
SessionKey:
`agent:${route.agentId}:${slashCommand.sessionPrefix}:${command.user_id}`.toLowerCase(),
CommandTargetSessionKey: route.sessionKey,
AccountId: route.accountId,
CommandSource: "native" as const,