mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 18:31:26 +00:00
fix(gateway): preserve agentId through gateway send path
Landed from #23249 by @Sid-Qin. Includes extra regression tests for agentId precedence + blank fallback. Co-authored-by: Sid <201593046+Sid-Qin@users.noreply.github.com>
This commit is contained in:
@@ -194,6 +194,35 @@ describe("gateway url override hardening", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("forwards explicit agentId in gateway send params", async () => {
|
||||
setRegistry(
|
||||
createTestRegistry([
|
||||
{
|
||||
pluginId: "mattermost",
|
||||
source: "test",
|
||||
plugin: {
|
||||
...createMattermostLikePlugin({ onSendText: () => {} }),
|
||||
outbound: { deliveryMode: "gateway" },
|
||||
},
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
callGatewayMock.mockResolvedValueOnce({ messageId: "m-agent" });
|
||||
await sendMessage({
|
||||
cfg: {},
|
||||
to: "channel:town-square",
|
||||
content: "hi",
|
||||
channel: "mattermost",
|
||||
agentId: "work",
|
||||
});
|
||||
|
||||
const call = callGatewayMock.mock.calls[0]?.[0] as {
|
||||
params?: Record<string, unknown>;
|
||||
};
|
||||
expect(call.params?.agentId).toBe("work");
|
||||
});
|
||||
});
|
||||
|
||||
const emptyRegistry = createTestRegistry([]);
|
||||
|
||||
@@ -251,6 +251,7 @@ export async function sendMessage(params: MessageSendParams): Promise<MessageSen
|
||||
mediaUrls: mirrorMediaUrls.length ? mirrorMediaUrls : params.mediaUrls,
|
||||
gifPlayback: params.gifPlayback,
|
||||
accountId: params.accountId,
|
||||
agentId: params.agentId,
|
||||
channel,
|
||||
sessionKey: params.mirror?.sessionKey,
|
||||
idempotencyKey: params.idempotencyKey ?? randomIdempotencyKey(),
|
||||
|
||||
Reference in New Issue
Block a user