fix: dedupe message tool replies (#659) (thanks @mickahouan)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
- CLI: `clawdbot sessions` now includes `elev:*` + `usage:*` flags in the table output.
|
||||
- Branding: normalize user-facing “ClawdBot”/“CLAWDBOT” → “Clawdbot” (CLI, status, docs).
|
||||
- Models/Auth: allow MiniMax API configs without `models.providers.minimax.apiKey` (auth profiles / `MINIMAX_API_KEY`). (#656) — thanks @mneves75.
|
||||
- Agents: avoid duplicate replies when the message tool sends. (#659) — thanks @mickahouan.
|
||||
|
||||
## 2026.1.9
|
||||
|
||||
|
||||
@@ -456,6 +456,53 @@ describe("subscribeEmbeddedPiSession", () => {
|
||||
expect(subscription.assistantTexts).toEqual(["Hello block"]);
|
||||
});
|
||||
|
||||
it("suppresses message_end block replies when the message tool already sent", () => {
|
||||
let handler: ((evt: unknown) => void) | undefined;
|
||||
const session: StubSession = {
|
||||
subscribe: (fn) => {
|
||||
handler = fn;
|
||||
return () => {};
|
||||
},
|
||||
};
|
||||
|
||||
const onBlockReply = vi.fn();
|
||||
|
||||
subscribeEmbeddedPiSession({
|
||||
session: session as unknown as Parameters<
|
||||
typeof subscribeEmbeddedPiSession
|
||||
>[0]["session"],
|
||||
runId: "run",
|
||||
onBlockReply,
|
||||
blockReplyBreak: "message_end",
|
||||
});
|
||||
|
||||
const messageText = "This is the answer.";
|
||||
|
||||
handler?.({
|
||||
type: "tool_execution_start",
|
||||
toolName: "message",
|
||||
toolCallId: "tool-message-1",
|
||||
args: { action: "send", to: "+1555", message: messageText },
|
||||
});
|
||||
|
||||
handler?.({
|
||||
type: "tool_execution_end",
|
||||
toolName: "message",
|
||||
toolCallId: "tool-message-1",
|
||||
isError: false,
|
||||
result: "ok",
|
||||
});
|
||||
|
||||
const assistantMessage = {
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: messageText }],
|
||||
} as AssistantMessage;
|
||||
|
||||
handler?.({ type: "message_end", message: assistantMessage });
|
||||
|
||||
expect(onBlockReply).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("clears block reply state on message_start", () => {
|
||||
let handler: ((evt: unknown) => void) | undefined;
|
||||
const session: StubSession = {
|
||||
|
||||
@@ -558,7 +558,9 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
? (args as Record<string, unknown>)
|
||||
: {};
|
||||
const action =
|
||||
typeof argsRecord.action === "string" ? argsRecord.action : "";
|
||||
typeof argsRecord.action === "string"
|
||||
? argsRecord.action.trim()
|
||||
: "";
|
||||
// Track send actions: sendMessage/threadReply for Discord/Slack, sessions_send (no action field),
|
||||
// and message/send or message/thread-reply for the generic message tool.
|
||||
const isMessagingSend =
|
||||
|
||||
Reference in New Issue
Block a user