fix: merge accountId when preferring live delivery context for restart sentinel

When liveContext (gateway-tool.ts) or paramsDeliveryContext (config.ts) is
present but lacks an accountId, fall back to the accountId from the extracted
session store rather than dropping it entirely. This prevents restart follow-up
notices from being misrouted on multi-account channels when callers supply
channel/to without an explicit accountId.

Addresses CR comments on PR #34580.
This commit is contained in:
Bryan Marty 2026-03-10 01:44:44 +00:00
parent 645def7535
commit fd1dd6fa80
No known key found for this signature in database
2 changed files with 14 additions and 2 deletions

View File

@ -157,7 +157,13 @@ export function createGatewayTool(opts?: {
}
: undefined;
const extracted = extractDeliveryInfo(sessionKey);
const deliveryContext = liveContext ?? extracted.deliveryContext;
const deliveryContext =
liveContext != null
? {
...liveContext,
accountId: liveContext.accountId ?? extracted.deliveryContext?.accountId,
}
: extracted.deliveryContext;
// Guard threadId with the same session check as deliveryContext. When
// targeting another session, opts.agentThreadId belongs to the current
// session's thread and must not be written into the sentinel — it would

View File

@ -205,7 +205,13 @@ function resolveConfigRestartRequest(params: unknown): {
const { deliveryContext: extractedDeliveryContext, threadId: extractedThreadId } =
extractDeliveryInfo(sessionKey);
const paramsDeliveryContext = parseDeliveryContextFromParams(params);
const deliveryContext = paramsDeliveryContext ?? extractedDeliveryContext;
const deliveryContext =
paramsDeliveryContext != null
? {
...paramsDeliveryContext,
accountId: paramsDeliveryContext.accountId ?? extractedDeliveryContext?.accountId,
}
: extractedDeliveryContext;
const threadId = paramsDeliveryContext?.threadId ?? extractedThreadId;
return {