mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 21:23:23 +00:00
fix(regression): canonicalize chat final session routing
This commit is contained in:
@@ -554,6 +554,36 @@ describe("chat directive tag stripping for non-streaming final payloads", () =>
|
||||
expect(extractFirstTextBlock(payload)).toBe("hello");
|
||||
});
|
||||
|
||||
it("chat.send non-streaming final broadcasts and routes on the canonical session key", async () => {
|
||||
createTranscriptFixture("openclaw-chat-send-canonical-key-");
|
||||
mockState.sessionEntry = {
|
||||
canonicalKey: "agent:main:canon",
|
||||
};
|
||||
mockState.finalText = "hello";
|
||||
const respond = vi.fn();
|
||||
const context = createChatContext();
|
||||
|
||||
const payload = await runNonStreamingChatSend({
|
||||
context,
|
||||
respond,
|
||||
idempotencyKey: "idem-canonical-key",
|
||||
sessionKey: "legacy-key",
|
||||
});
|
||||
|
||||
expect(payload).toEqual(
|
||||
expect.objectContaining({
|
||||
sessionKey: "agent:main:canon",
|
||||
}),
|
||||
);
|
||||
expect(context.nodeSendToSession).toHaveBeenCalledWith(
|
||||
"agent:main:canon",
|
||||
"chat",
|
||||
expect.objectContaining({
|
||||
sessionKey: "agent:main:canon",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("chat.send keeps explicit delivery routes for channel-scoped sessions", async () => {
|
||||
createTranscriptFixture("openclaw-chat-send-origin-routing-");
|
||||
mockState.finalText = "ok";
|
||||
|
||||
@@ -1591,7 +1591,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
||||
payload: {
|
||||
kind: "btw",
|
||||
runId: clientRunId,
|
||||
sessionKey: rawSessionKey,
|
||||
sessionKey,
|
||||
question: btwReplies[0].btw.question.trim(),
|
||||
text: btwText,
|
||||
isError: btwReplies.some((payload) => payload.isError),
|
||||
@@ -1601,7 +1601,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
||||
broadcastChatFinal({
|
||||
context,
|
||||
runId: clientRunId,
|
||||
sessionKey: rawSessionKey,
|
||||
sessionKey,
|
||||
});
|
||||
} else {
|
||||
const combinedReply = deliveredReplies
|
||||
@@ -1645,7 +1645,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
||||
broadcastChatFinal({
|
||||
context,
|
||||
runId: clientRunId,
|
||||
sessionKey: rawSessionKey,
|
||||
sessionKey,
|
||||
message,
|
||||
});
|
||||
}
|
||||
@@ -1681,7 +1681,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
||||
broadcastChatError({
|
||||
context,
|
||||
runId: clientRunId,
|
||||
sessionKey: rawSessionKey,
|
||||
sessionKey,
|
||||
errorMessage: String(err),
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user