mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:32:44 +00:00
fix(reply): auto-inject replyToCurrent for reply threading
replyToMode "first"/"all" only filters replyToId but never generates it — that required the LLM to emit [[reply_to_current]] tags. Inject replyToCurrent:true on all payloads so applyReplyTagsToPayload sets replyToId=currentMessageId, then let the existing mode filter decide which replies keep threading (first only, all, or off). Covers both final reply path (reply-payloads.ts) and block streaming path (agent-runner-execution.ts).
This commit is contained in:
committed by
Peter Steinberger
parent
39ee708df6
commit
3d89f0f14a
50
src/auto-reply/reply/reply-payloads.auto-threading.test.ts
Normal file
50
src/auto-reply/reply/reply-payloads.auto-threading.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyReplyThreading } from "./reply-payloads.js";
|
||||
|
||||
describe("applyReplyThreading auto-injects replyToCurrent", () => {
|
||||
it("sets replyToId to currentMessageId even without [[reply_to_current]] tag", () => {
|
||||
const result = applyReplyThreading({
|
||||
payloads: [{ text: "Hello" }],
|
||||
replyToMode: "first",
|
||||
currentMessageId: "42",
|
||||
});
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].replyToId).toBe("42");
|
||||
});
|
||||
|
||||
it("threads only first payload when mode is 'first'", () => {
|
||||
const result = applyReplyThreading({
|
||||
payloads: [{ text: "A" }, { text: "B" }],
|
||||
replyToMode: "first",
|
||||
currentMessageId: "42",
|
||||
});
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].replyToId).toBe("42");
|
||||
expect(result[1].replyToId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("threads all payloads when mode is 'all'", () => {
|
||||
const result = applyReplyThreading({
|
||||
payloads: [{ text: "A" }, { text: "B" }],
|
||||
replyToMode: "all",
|
||||
currentMessageId: "42",
|
||||
});
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].replyToId).toBe("42");
|
||||
expect(result[1].replyToId).toBe("42");
|
||||
});
|
||||
|
||||
it("strips replyToId when mode is 'off'", () => {
|
||||
const result = applyReplyThreading({
|
||||
payloads: [{ text: "A" }],
|
||||
replyToMode: "off",
|
||||
currentMessageId: "42",
|
||||
});
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].replyToId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user