mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-02 00:03:37 +00:00
fix(agents): keep fallback routes account-bound
This commit is contained in:
committed by
Ayaan Zaidi
parent
dc9ad35bda
commit
1ed8592467
@@ -243,17 +243,20 @@ export function mergeDeliveryContext(
|
||||
normalizedPrimary?.channel &&
|
||||
normalizedFallback?.channel &&
|
||||
normalizedPrimary.channel !== normalizedFallback.channel;
|
||||
const accountsConflict =
|
||||
normalizedPrimary?.accountId &&
|
||||
normalizedFallback?.accountId &&
|
||||
normalizedPrimary.accountId !== normalizedFallback.accountId;
|
||||
const routesConflict = channelsConflict || accountsConflict;
|
||||
return normalizeDeliveryContext({
|
||||
channel: normalizedPrimary?.channel ?? normalizedFallback?.channel,
|
||||
// Keep route fields paired to their channel; avoid crossing fields between
|
||||
// unrelated channels during session context merges.
|
||||
to: channelsConflict
|
||||
? normalizedPrimary?.to
|
||||
: (normalizedPrimary?.to ?? normalizedFallback?.to),
|
||||
accountId: channelsConflict
|
||||
to: routesConflict ? normalizedPrimary?.to : (normalizedPrimary?.to ?? normalizedFallback?.to),
|
||||
accountId: routesConflict
|
||||
? normalizedPrimary?.accountId
|
||||
: (normalizedPrimary?.accountId ?? normalizedFallback?.accountId),
|
||||
threadId: channelsConflict
|
||||
threadId: routesConflict
|
||||
? normalizedPrimary?.threadId
|
||||
: (normalizedPrimary?.threadId ?? normalizedFallback?.threadId),
|
||||
});
|
||||
|
||||
@@ -53,6 +53,20 @@ describe("delivery context helpers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not inherit route fields from a different account on the same channel", () => {
|
||||
const merged = mergeDeliveryContext(
|
||||
{ channel: "telegram", accountId: "bot-a" },
|
||||
{ channel: "telegram", to: "123", accountId: "bot-b", threadId: "99" },
|
||||
);
|
||||
|
||||
expect(merged).toEqual({
|
||||
channel: "telegram",
|
||||
to: undefined,
|
||||
accountId: "bot-a",
|
||||
});
|
||||
expect(merged?.threadId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("uses fallback route fields when fallback has no channel", () => {
|
||||
const merged = mergeDeliveryContext(
|
||||
{ channel: "demo-channel" },
|
||||
|
||||
Reference in New Issue
Block a user