fix(gateway): use canonical session key in chat.send

Fixes session key mismatch where chat.send used raw key (e.g. "main")
but chat.history used canonical key (e.g. "agent:main:main"), causing
messages to be written to one session but read from another.

Fixes #2493
This commit is contained in:
Chris Herold 2026-01-27 22:51:26 -08:00
parent 6044bf3637
commit dd2aac40fa
No known key found for this signature in database
GPG Key ID: CF64BFBB6D4A3FCC

View File

@ -362,7 +362,7 @@ export const chatHandlers: GatewayRequestHandlers = {
return;
}
}
const { cfg, entry } = loadSessionEntry(p.sessionKey);
const { cfg, entry, canonicalKey } = loadSessionEntry(p.sessionKey);
const timeoutMs = resolveAgentTimeoutMs({
cfg,
overrideMs: p.timeoutMs,
@ -449,7 +449,7 @@ export const chatHandlers: GatewayRequestHandlers = {
BodyForCommands: commandBody,
RawBody: parsedMessage,
CommandBody: commandBody,
SessionKey: p.sessionKey,
SessionKey: canonicalKey,
Provider: INTERNAL_MESSAGE_CHANNEL,
Surface: INTERNAL_MESSAGE_CHANNEL,
OriginatingChannel: INTERNAL_MESSAGE_CHANNEL,