Skip to content

Commit 5fa72a7

Browse files
test(gateway): cover automatic source projection
1 parent 0b82253 commit 5fa72a7

2 files changed

Lines changed: 51 additions & 4 deletions

File tree

‎src/auto-reply/reply/agent-runner-result-payloads.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ export async function prepareReplyAgentPayloads(state: {
175175
});
176176
return recovery.kind === "diagnostic" ? recovery.payload : undefined;
177177
};
178-
// Route-aware message-tool delivery attests observed delivery in every mode:
179-
// an automatic-mode turn answered via the message tool plus NO_REPLY must not
180-
// draw the no-visible-reply fallback into the source conversation. The dedupe
181-
// route matcher keeps unrelated-target tool sends from counting as the reply.
178+
// Structured source-reply delivery evidence is the canonical owner for current
179+
// runtimes. The route matcher remains only for legacy results that recorded
180+
// successful target/text/media aggregates before structured receipts existed.
181+
// It still keeps unrelated-target tool sends from counting as the source reply.
182182
const sourceRoutedMessagingToolDelivery =
183183
completedSourceReplyDelivery ||
184184
((runResult.messagingToolSentTargets?.length ?? 0) > 0 &&

‎src/gateway/chat-display-projection.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
import { describe, expect, it } from "vitest";
22
import { sanitizeChatHistoryMessages } from "./chat-display-projection.js";
3+
import { mirrorMessageToolVisibleReplies } from "./chat-display-projection.message-tool.js";
4+
5+
describe("chat display message-tool projection", () => {
6+
it("mirrors an automatic-mode send confirmed for the current source", () => {
7+
const sourceReply = "Visible reply delivered to Slack.";
8+
const projected = mirrorMessageToolVisibleReplies([
9+
{
10+
role: "assistant",
11+
content: [
12+
{
13+
type: "toolCall",
14+
id: "call-message-current-source",
15+
name: "message",
16+
arguments: {
17+
action: "send",
18+
channel: "slack",
19+
target: "channel:C123",
20+
message: sourceReply,
21+
},
22+
},
23+
],
24+
},
25+
{
26+
role: "toolResult",
27+
toolName: "message",
28+
toolCallId: "call-message-current-source",
29+
content: { ok: true, messageId: "slack-242" },
30+
details: {
31+
ok: true,
32+
messageId: "slack-242",
33+
sourceReplyRoute: "current-source",
34+
},
35+
},
36+
{ role: "assistant", content: [{ type: "text", text: "NO_REPLY" }] },
37+
]);
38+
39+
expect(projected).toContainEqual(
40+
expect.objectContaining({
41+
role: "assistant",
42+
content: [{ type: "text", text: sourceReply }],
43+
openclawMessageToolMirror: expect.objectContaining({
44+
toolCallId: "call-message-current-source",
45+
}),
46+
}),
47+
);
48+
});
49+
});
350

451
describe("chat display tool-result detail projection", () => {
552
it("keeps authoritative write booleans and strips unrelated details", () => {

0 commit comments

Comments
 (0)