fix: preserve account routing for explicit targets

Co-authored-by: adam91holt <adam91holt@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-17 04:24:47 +00:00
parent 780c811146
commit 3efc5e54fa
3 changed files with 95 additions and 3 deletions

View File

@@ -155,6 +155,7 @@ export const agentHandlers: GatewayRequestHandlers = {
skillsSnapshot: entry?.skillsSnapshot,
lastChannel: entry?.lastChannel,
lastTo: entry?.lastTo,
lastAccountId: entry?.lastAccountId,
modelOverride: entry?.modelOverride,
providerOverride: entry?.providerOverride,
label: labelValue,
@@ -201,8 +202,11 @@ export const agentHandlers: GatewayRequestHandlers = {
const lastChannel = sessionEntry?.lastChannel;
const lastTo = typeof sessionEntry?.lastTo === "string" ? sessionEntry.lastTo.trim() : "";
const explicitTo =
typeof request.to === "string" && request.to.trim() ? request.to.trim() : undefined;
const resolvedAccountId =
normalizeAccountId(request.accountId) ?? normalizeAccountId(sessionEntry?.lastAccountId);
normalizeAccountId(request.accountId) ??
(explicitTo ? undefined : normalizeAccountId(sessionEntry?.lastAccountId));
const wantsDelivery = request.deliver === true;
@@ -224,8 +228,6 @@ export const agentHandlers: GatewayRequestHandlers = {
return wantsDelivery ? DEFAULT_CHAT_CHANNEL : INTERNAL_MESSAGE_CHANNEL;
})();
const explicitTo =
typeof request.to === "string" && request.to.trim() ? request.to.trim() : undefined;
const deliveryTargetMode = explicitTo
? "explicit"
: isDeliverableMessageChannel(resolvedChannel)