mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
fix (webchat): omit direct conversation labels from inbound metadata context
This commit is contained in:
24
src/auto-reply/reply/inbound-meta.test.ts
Normal file
24
src/auto-reply/reply/inbound-meta.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { TemplateContext } from "../templating.js";
|
||||
import { buildInboundUserContextPrefix } from "./inbound-meta.js";
|
||||
|
||||
describe("buildInboundUserContextPrefix", () => {
|
||||
it("omits conversation label block for direct chats", () => {
|
||||
const text = buildInboundUserContextPrefix({
|
||||
ChatType: "direct",
|
||||
ConversationLabel: "openclaw-tui",
|
||||
} as TemplateContext);
|
||||
|
||||
expect(text).toBe("");
|
||||
});
|
||||
|
||||
it("keeps conversation label for group chats", () => {
|
||||
const text = buildInboundUserContextPrefix({
|
||||
ChatType: "group",
|
||||
ConversationLabel: "ops-room",
|
||||
} as TemplateContext);
|
||||
|
||||
expect(text).toContain("Conversation info (untrusted metadata):");
|
||||
expect(text).toContain('"conversation_label": "ops-room"');
|
||||
});
|
||||
});
|
||||
@@ -52,7 +52,7 @@ export function buildInboundUserContextPrefix(ctx: TemplateContext): string {
|
||||
const isDirect = !chatType || chatType === "direct";
|
||||
|
||||
const conversationInfo = {
|
||||
conversation_label: safeTrim(ctx.ConversationLabel),
|
||||
conversation_label: isDirect ? undefined : safeTrim(ctx.ConversationLabel),
|
||||
group_subject: safeTrim(ctx.GroupSubject),
|
||||
group_channel: safeTrim(ctx.GroupChannel),
|
||||
group_space: safeTrim(ctx.GroupSpace),
|
||||
|
||||
Reference in New Issue
Block a user