Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(bot): give a bot a reply style per channel and a list of emoji it may use (#21757)

Arvin Xucfd882d0da36
diff --git a/apps/server/src/services/bot/AgentBridgeService/execute.ts b/apps/server/src/services/bot/AgentBridgeService/execute.ts
index eb11b82bf29..995d697e50b 100644
--- a/apps/server/src/services/bot/AgentBridgeService/execute.ts
+++ b/apps/server/src/services/bot/AgentBridgeService/execute.ts
@@ -63,6 +63,10 @@ export async function executeWithCallback(
duty?: { matched?: string };
/** The bot woke only because its name is in the text; told to the agent with a `followup`. */
named?: boolean;
+ /** Emoji the owner lets the bot use in this conversation. */
+ replyEmojis?: { emoji: string; usage?: string }[];
+ /** How the bot talks in this conversation, as the owner wrote it. */
+ replyStyle?: string;
/** Acknowledgement posted before the run; the agent is told not to repeat it. */
openingReply?: string;
reactionMode?: BotReactionMode;
@@ -300,6 +304,10 @@ export async function executeWithCallback(
if (opts.named) botPlatformContext.named = true;
}
if (opts.openingReply && botPlatformContext) botPlatformContext.openingReply = opts.openingReply;
+ if (botPlatformContext) {
+ if (opts.replyStyle) botPlatformContext.replyStyle = opts.replyStyle;
+ if (opts.replyEmojis?.length) botPlatformContext.replyEmojis = opts.replyEmojis;
+ }
// Attach file warnings to botPlatformContext for injection via context engine
if (fileWarnings?.length && botPlatformContext) {
diff --git a/apps/server/src/services/bot/AgentBridgeService/index.ts b/apps/server/src/services/bot/AgentBridgeService/index.ts
index 12738134b29..9bf7ed43327 100644
--- a/apps/server/src/services/bot/AgentBridgeService/index.ts
+++ b/apps/server/src/services/bot/AgentBridgeService/index.ts
@@ -396,6 +396,8 @@ export class AgentBridgeService {
displayToolCalls,
duty: opts.duty,
named: opts.named,
+ replyEmojis: opts.replyEmojis,
+ replyStyle: opts.replyStyle,
openingReply: opts.openingReply,
reactionMode,
replyLocale,
@@ -590,6 +592,8 @@ export class AgentBridgeService {
reactionMode,
duty: opts.duty,
named: opts.named,
+ replyEmojis: opts.replyEmojis,
+ replyStyle: opts.replyStyle,
openingReply: opts.openingReply,
replyLocale,
topicId,
diff --git a/apps/server/src/services/bot/AgentBridgeService/types.ts b/apps/server/src/services/bot/AgentBridgeService/types.ts
index e9ecf2688f9..af0f9f16d64 100644
--- a/apps/server/src/services/bot/AgentBridgeService/types.ts
+++ b/apps/server/src/services/bot/AgentBridgeService/types.ts
@@ -49,12 +49,16 @@ export interface BridgeHandlerOpts {
* `DEFAULT_BOT_REACTION_MODE` for callers that predate the setting.
*/
reactionMode?: BotReactionMode;
+ /** Emoji the owner lets the bot use; told to the agent. See `formatBotPlatformContext`. */
+ replyEmojis?: { emoji: string; usage?: string }[];
/**
* Locale for system-generated reply text (errors, stopped notice, etc.).
* Picked per platform — see `getBotReplyLocale`. When omitted we fall back
* to inferring from `botContext.platform`, then to English.
*/
replyLocale?: BotReplyLocale;
+ /** How the bot talks in this conversation, as the owner wrote it. See `formatBotPlatformContext`. */
+ replyStyle?: string;
/**
* How the bot was woken. `followup` lets the agent end in silence and holds back every visible
* side effect (reaction, typing, progress message) until it decides to speak; `mention`
diff --git a/apps/server/src/services/bot/BotMessageRouter/catchAll.ts b/apps/server/src/services/bot/BotMessageRouter/catchAll.ts
index 33d3bb22b95..c765a682fbe 100644
--- a/apps/server/src/services/bot/BotMessageRouter/catchAll.ts
+++ b/apps/server/src/services/bot/BotMessageRouter/catchAll.ts
@@ -38,6 +38,7 @@ export const registerCatchAllHandler = (bot: Chat<any>, ctx: BotHandlerContext):
observe,
observeBurst,
operatorUserId,
+ replyVoiceFor,
passGatesOrNotify,
platform,
reactionMode,
@@ -290,6 +291,7 @@ export const registerCatchAllHandler = (bot: Chat<any>, ctx: BotHandlerContext):
replyLocale,
duty: initiation?.reason === 'in-duty' ? { matched: initiation.duty } : undefined,
named: wakeReason === 'named-in-text',
+ ...replyVoiceFor(thread.id),
wakeKind,
});
} catch (error) {
diff --git a/apps/server/src/services/bot/BotMessageRouter/handlers.ts b/apps/server/src/services/bot/BotMessageRouter/handlers.ts
index 743a3d19519..d21c00989fb 100644
--- a/apps/server/src/services/bot/BotMessageRouter/handlers.ts
+++ b/apps/server/src/services/bot/BotMessageRouter/handlers.ts
@@ -5,6 +5,7 @@ import { getBotFeatureAccessState } from '@/business/server/bot/featureAccess';
import type { LobeChatDatabase } from '@/database/type';
import { emitAgentSignalSourceEvent } from '@/server/services/agentSignal';
import { parseBotWakeSettings } from '@/server/services/agentSignal/scenarios/botWake/config';
+import { resolveChannelKeys } from '@/server/services/agentSignal/scenarios/botWake/facts';
import { isBotWakeEnabled } from '@/server/services/agentSignal/scenarios/botWake/gate';
import { AgentBridgeService } from '../AgentBridgeService';
@@ -17,6 +18,7 @@ import {
extractDmSettings,
extractGroupSettings,
extractGuestSettings,
+ extractReplyEmojis,
extractUserAllowlist,
extractWatchKeywordEntries,
getBotReplyLocale,
@@ -26,6 +28,7 @@ import {
normalizeBotReplyLocale,
normalizeBotReplyPlacementMode,
type PlatformClient,
+ resolveReplyStyle,
type UserAllowlist,
} from '../platforms';
import { renderThrownAgentError } from '../renderThrownError';
@@ -46,7 +49,7 @@ import {
PARTICIPANTS_TTL_MS,
} from './participants';
import { createReplyOpening } from './replyOpening';
-import type { BotCommand, BotHandlerContext, ResolvedAgentInfo } from './types';
+import type { BotCommand, BotHandlerContext, BotReplyVoice, ResolvedAgentInfo } from './types';
import {
applyWatchKeywordInstructions,
burstMatchesWatchKeyword,
@@ -89,6 +92,14 @@ export function registerHandlers(
const { agentId, applicationId, platform, userId, workspaceId } = info;
const bridge = new AgentBridgeService(serverDB, userId, workspaceId);
const charLimit = (info.settings?.charLimit as number) || undefined;
+ const replyEmojis = extractReplyEmojis(info.settings);
+ const replyVoiceFor = (platformThreadId: string): BotReplyVoice => ({
+ replyEmojis: replyEmojis.length > 0 ? replyEmojis : undefined,
+ replyStyle: resolveReplyStyle(
+ info.settings,
+ resolveChannelKeys(platform, applicationId, platformThreadId).ids,
+ ),
+ });
const displayToolCalls = info.settings?.displayToolCalls === true;
const reactionMode = normalizeBotReactionMode(info.settings?.reactionMode);
const dmSettings: DmSettings = extractDmSettings(info.settings);
@@ -540,6 +551,7 @@ export function registerHandlers(
openingReply,
reactionMode,
replyLocale,
+ ...replyVoiceFor(thread.id),
});
} catch (error) {
const operationId = AgentBridgeService.getActiveOperationId(thread.id);
@@ -844,6 +856,7 @@ export function registerHandlers(
openingReply,
reactionMode,
replyLocale,
+ ...replyVoiceFor(thread.id),
wakeKind,
});
} catch (error) {
@@ -882,6 +895,7 @@ export function registerHandlers(
agentId,
applicationId,
botWakeEnabled: isBotWakeEnabled(parseBotWakeSettings(info.settings).config),
+ replyVoiceFor,
bridge,
charLimit,
client,
diff --git a/apps/server/src/services/bot/BotMessageRouter/testUtils.ts b/apps/server/src/services/bot/BotMessageRouter/testUtils.ts
index 9555e928257..2e1709129d6 100644
--- a/apps/server/src/services/bot/BotMessageRouter/testUtils.ts
+++ b/apps/server/src/services/bot/BotMessageRouter/testUtils.ts
@@ -7,6 +7,7 @@
*/
import { vi } from 'vitest';
+import type * as ReplyStyle from '../platforms/replyStyle';
import type * as PlatformUtils from '../platforms/utils';
// ==================== Hoisted mocks ====================
@@ -311,6 +312,11 @@ export const platformsModule = async () => ({
// mocked because it instantiates every platform definition, `utils` does not.
resolveBotConcurrency: (await vi.importActual<typeof PlatformUtils>('../platforms/utils'))
.resolveBotConcurrency,
+ // Pure parsers, safe to import for real like `utils`.
+ extractReplyEmojis: (await vi.importActual<typeof ReplyStyle>('../platforms/replyStyle'))
+ .extractReplyEmojis,
+ resolveReplyStyle: (await vi.importActual<typeof ReplyStyle>('../platforms/replyStyle'))
+ .resolveReplyStyle,
getBotReplyLocale: (platform: string | undefined): string => {
if (platform === 'feishu' || platform === 'qq' || platform === 'wechat') return 'zh-CN';
return 'en-US';
diff --git a/apps/server/src/services/bot/BotMessageRouter/types.ts b/apps/server/src/services/bot/BotMessageRouter/types.ts
index 3f5a12dffab..f13c1225246 100644
--- a/apps/server/src/services/bot/BotMessageRouter/types.ts
+++ b/apps/server/src/services/bot/BotMessageRouter/types.ts
@@ -8,6 +8,7 @@ import type {
BotReplyLocale,
DmSettings,
PlatformClient,
+ ReplyEmojiEntry,
WatchKeywordEntry,
} from '../platforms';
import type { WakeMessageLike } from '../wake/signal';
@@ -116,6 +117,12 @@ export type BotAccessGate = (
caller: string,
) => Promise<boolean>;
+/** The owner's reply style for one conversation and the emoji the bot may use there. */
+export interface BotReplyVoice {
+ replyEmojis?: ReplyEmojiEntry[];
+ replyStyle?: string;
+}
+
/** Per-bot values `registerHandlers` hands to the DM / keyword catch-all. */
export interface BotHandlerContext {
agentId: string;
@@ -176,6 +183,8 @@ export interface BotHandlerContext {
messages: WakeMessageLike[],
thread: { id: string },
) => void;
+ /** How the bot talks in a conversation: the owner's reply style for it and the emoji it may use. */
+ replyVoiceFor: (platformThreadId: string) => BotReplyVoice;
serverDB: LobeChatDatabase;
/**
* Opens the reply to a message that woke the bot (an acknowledgement, and the channel or a new
diff --git a/apps/server/src/services/bot/platforms/discord/schema.ts b/apps/server/src/services/bot/platforms/discord/schema.ts
index c82e2261aa6..f39c653ba27 100644
--- a/apps/server/src/services/bot/platforms/discord/schema.ts
+++ b/apps/server/src/services/bot/platforms/discord/schema.ts
@@ -17,6 +17,7 @@ import {
replyPlacementField,
watchKeywordsField,
} from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
import {
DISCORD_APPLICATION_ID_PATTERN,
@@ -129,6 +130,7 @@ export const schema: FieldSchema[] = [
...makeGroupPolicyFields({ policy: 'open' }),
allowFromField,
watchKeywordsField,
+ ...replyStyleFields,
...botWakeFields,
],
type: 'object',
diff --git a/apps/server/src/services/bot/platforms/feishu/definitions/schema.ts b/apps/server/src/services/bot/platforms/feishu/definitions/schema.ts
index e978e8a1aad..34bda1799cb 100644
--- a/apps/server/src/services/bot/platforms/feishu/definitions/schema.ts
+++ b/apps/server/src/services/bot/platforms/feishu/definitions/schema.ts
@@ -14,6 +14,7 @@ import {
reactionModeField,
watchKeywordsField,
} from '../../const';
+import { replyStyleFields } from '../../replyStyle';
import type { FieldSchema } from '../../types';
import { DEFAULT_FEISHU_CONNECTION_MODE, MAX_FEISHU_HISTORY_LIMIT } from '../const';
@@ -122,6 +123,7 @@ export const sharedSchema: FieldSchema[] = [
...makeGroupPolicyFields({ policy: 'open' }),
allowFromField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/apps/server/src/services/bot/platforms/imessage/schema.ts b/apps/server/src/services/bot/platforms/imessage/schema.ts
index 621b4d948f1..2c91a56ee6d 100644
--- a/apps/server/src/services/bot/platforms/imessage/schema.ts
+++ b/apps/server/src/services/bot/platforms/imessage/schema.ts
@@ -1,6 +1,7 @@
import { DEFAULT_BOT_DEBOUNCE_MS, MAX_BOT_DEBOUNCE_MS } from '@lobechat/const';
import { displayToolCallsField, makeUserIdField, watchKeywordsField } from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
export const schema: FieldSchema[] = [
@@ -66,6 +67,7 @@ export const schema: FieldSchema[] = [
},
displayToolCallsField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/apps/server/src/services/bot/platforms/index.ts b/apps/server/src/services/bot/platforms/index.ts
index d82ebf69f94..5826f79c180 100644
--- a/apps/server/src/services/bot/platforms/index.ts
+++ b/apps/server/src/services/bot/platforms/index.ts
@@ -64,6 +64,12 @@ export {
WORKING_REACTION_EMOJI,
} from './const';
export { PlatformRegistry } from './registry';
+export {
+ extractReplyEmojis,
+ type ReplyEmojiEntry,
+ replyStyleFields,
+ resolveReplyStyle,
+} from './replyStyle';
export type {
BotMessageAttachment,
BotPlatformRedisClient,
diff --git a/apps/server/src/services/bot/platforms/line/schema.ts b/apps/server/src/services/bot/platforms/line/schema.ts
index 3396f729a14..4f06a3a44d6 100644
--- a/apps/server/src/services/bot/platforms/line/schema.ts
+++ b/apps/server/src/services/bot/platforms/line/schema.ts
@@ -1,6 +1,7 @@
import { DEFAULT_BOT_DEBOUNCE_MS, MAX_BOT_DEBOUNCE_MS } from '@lobechat/const';
import { displayToolCallsField, makeUserIdField, watchKeywordsField } from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
export const schema: FieldSchema[] = [
@@ -85,6 +86,7 @@ export const schema: FieldSchema[] = [
},
displayToolCallsField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/apps/server/src/services/bot/platforms/qq/schema.ts b/apps/server/src/services/bot/platforms/qq/schema.ts
index 0d3592d3477..d8826ab5827 100644
--- a/apps/server/src/services/bot/platforms/qq/schema.ts
+++ b/apps/server/src/services/bot/platforms/qq/schema.ts
@@ -8,6 +8,7 @@ import {
makeUserIdField,
watchKeywordsField,
} from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
import { DEFAULT_QQ_CONNECTION_MODE } from './const';
@@ -100,6 +101,7 @@ export const schema: FieldSchema[] = [
...makeGroupPolicyFields({ policy: 'open' }),
allowFromField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/apps/server/src/services/bot/platforms/replyStyle.test.ts b/apps/server/src/services/bot/platforms/replyStyle.test.ts
new file mode 100644
index 00000000000..0c05ed047e7
--- /dev/null
+++ b/apps/server/src/services/bot/platforms/replyStyle.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it } from 'vitest';
+
+import { extractReplyEmojis, MAX_REPLY_STYLE_LENGTH, resolveReplyStyle } from './replyStyle';
+
+describe('resolveReplyStyle', () => {
+ const settings = {
+ channelReplyStyles: [
+ { channelId: 'c1', style: ' 正式一点 ' },
+ { channelId: 't1', style: '这个子区随便聊' },
+ { channelId: 'c1', style: 'ignored duplicate' },
+ { channelId: 'c2', style: ' ' },
+ ],
+ replyStyle: ' 像同事一样随意 ',
+ };
+
+ it('uses the style written for the thread, then its channel, then the default', () => {
+ expect(resolveReplyStyle(settings, ['c1', 't1'])).toBe('这个子区随便聊');
+ expect(resolveReplyStyle(settings, ['c1', 't9'])).toBe('正式一点');
+ expect(resolveReplyStyle(settings, ['c9'])).toBe('像同事一样随意');
+ // A blank channel style is no style: the default applies.
+ expect(resolveReplyStyle(settings, ['c2'])).toBe('像同事一样随意');
+ });
+
+ it('is undefined without a style, and cuts an over-long one', () => {
+ expect(resolveReplyStyle({}, ['c1'])).toBeUndefined();
+ expect(resolveReplyStyle(null, [])).toBeUndefined();
+ expect(resolveReplyStyle({ replyStyle: 'x'.repeat(5000) }, [])).toHaveLength(
+ MAX_REPLY_STYLE_LENGTH,
+ );
+ });
+});
+
+describe('extractReplyEmojis', () => {
+ it('keeps the owner order, dedupes by emoji and drops blanks', () => {
+ expect(
+ extractReplyEmojis({
+ replyEmojis: [
+ { emoji: ' <:doge:123> ' },
+ { emoji: '<:doge:123>', usage: '调侃的时候' },
+ { emoji: '🎉', usage: '有人发布新功能' },
+ { emoji: ' ' },
+ '👍',
+ 42,
+ ],
+ }),
+ ).toEqual([
+ { emoji: '<:doge:123>', usage: '调侃的时候' },
+ { emoji: '🎉', usage: '有人发布新功能' },
+ { emoji: '👍' },
+ ]);
+ expect(extractReplyEmojis({ replyEmojis: 'not a list' })).toEqual([]);
+ });
+});
diff --git a/apps/server/src/services/bot/platforms/replyStyle.ts b/apps/server/src/services/bot/platforms/replyStyle.ts
new file mode 100644
index 00000000000..40fb8d96cc1
--- /dev/null
+++ b/apps/server/src/services/bot/platforms/replyStyle.ts
@@ -0,0 +1,152 @@
+import type { FieldSchema } from './types';
+
+/** Longest reply style handed to the agent; longer text is cut, not rejected. */
+export const MAX_REPLY_STYLE_LENGTH = 2000;
+/** Most channels with a style of their own. */
+export const MAX_CHANNEL_REPLY_STYLES = 200;
+/** Most emoji the agent is offered; a longer list is cut in authoring order. */
+export const MAX_REPLY_EMOJIS = 50;
+
+const REPLY_STYLE_ROWS = 6;
+
+/**
+ * An emoji or sticker the owner lets the bot use in its replies: `emoji` is pasted into the text as
+ * it is (a Unicode emoji, a Discord custom emoji `<:doge:123>`, a Slack `:doge:`), `usage` says when
+ * it fits.
+ */
+export interface ReplyEmojiEntry {
+ emoji: string;
+ usage?: string;
+}
+
+/**
+ * How the bot talks, as the owner wrote it: a default for every channel, a style per channel that
+ * replaces it there, and the emoji it may use. Only how it speaks: what it does belongs to the
+ * duties, and whether it speaks to bot-wake.
+ */
+export const replyStyleFields: FieldSchema[] = [
+ {
+ key: 'replyStyle',
+ description: 'channel.replyStyleHint',
+ label: 'channel.replyStyle',
+ maximum: MAX_REPLY_STYLE_LENGTH,
+ placeholder: 'channel.replyStylePlaceholder',
+ rows: REPLY_STYLE_ROWS,
+ type: 'string',
+ },
+ {
+ key: 'channelReplyStyles',
+ default: [],
+ description: 'channel.channelReplyStylesHint',
+ items: {
+ key: 'item',
+ label: '',
+ properties: [
+ {
+ key: 'channelId',
+ label: 'channel.channelReplyStyleChannelLabel',
+ placeholder: 'channel.channelReplyStyleChannelPlaceholder',
+ required: true,
+ type: 'string',
+ },
+ {
+ key: 'style',
+ label: 'channel.channelReplyStyleStyleLabel',
+ placeholder: 'channel.replyStylePlaceholder',
+ required: true,
+ type: 'string',
+ },
+ ],
+ type: 'object',
+ },
+ label: 'channel.channelReplyStyles',
+ maximum: MAX_CHANNEL_REPLY_STYLES,
+ type: 'array',
+ },
+ {
+ key: 'replyEmojis',
+ default: [],
+ description: 'channel.replyEmojisHint',
+ items: {
+ key: 'item',
+ label: '',
+ properties: [
+ {
+ key: 'emoji',
+ label: 'channel.replyEmojiLabel',
+ placeholder: 'channel.replyEmojiPlaceholder',
+ required: true,
+ type: 'string',
+ },
+ {
+ key: 'usage',
+ label: 'channel.replyEmojiUsageLabel',
+ placeholder: 'channel.replyEmojiUsagePlaceholder',
+ type: 'string',
+ },
+ ],
+ type: 'object',
+ },
+ label: 'channel.replyEmojis',
+ maximum: MAX_REPLY_EMOJIS,
+ type: 'array',
+ },
+];
+
+const text = (value: unknown) => (typeof value === 'string' ? value.trim() : '');
+
+/**
+ * The reply style for one conversation: the style written for its channel or thread when there is
+ * one, otherwise the bot's default.
+ *
+ * Expects:
+ * - `channelIds` from the outermost to the innermost (a Discord channel, then its thread), as
+ * `resolveChannelKeys` lists them; the innermost match wins
+ *
+ * Returns:
+ * - The trimmed style, cut to {@link MAX_REPLY_STYLE_LENGTH}; `undefined` when none applies
+ */
+export const resolveReplyStyle = (
+ settings: Record<string, unknown> | null | undefined,
+ channelIds: readonly string[],
+): string | undefined => {
+ const overrides = Array.isArray(settings?.channelReplyStyles) ? settings.channelReplyStyles : [];
+ const byChannel = new Map<string, string>();
+ for (const entry of overrides) {
+ if (!entry || typeof entry !== 'object') continue;
+ const channelId = text((entry as Record<string, unknown>).channelId);
+ const style = text((entry as Record<string, unknown>).style);
+ if (channelId && style && !byChannel.has(channelId)) byChannel.set(channelId, style);
+ }
+
+ const forChannel = [...channelIds].reverse().find((id) => byChannel.has(id));
+ const style = forChannel ? byChannel.get(forChannel) : text(settings?.replyStyle);
+
+ return style ? style.slice(0, MAX_REPLY_STYLE_LENGTH) : undefined;
+};
+
+/**
+ * The emoji the owner lets the bot use, deduplicated by emoji in authoring order (the first
+ * non-empty usage wins), at most {@link MAX_REPLY_EMOJIS}.
+ */
+export const extractReplyEmojis = (
+ settings: Record<string, unknown> | null | undefined,
+): ReplyEmojiEntry[] => {
+ const raw = Array.isArray(settings?.replyEmojis) ? settings.replyEmojis : [];
+ const byEmoji = new Map<string, ReplyEmojiEntry>();
+ for (const entry of raw) {
+ const fields = typeof entry === 'string' ? { emoji: entry } : entry;
+ if (!fields || typeof fields !== 'object') continue;
+ const emoji = text((fields as Record<string, unknown>).emoji);
+ if (!emoji) continue;
+ const usage = text((fields as Record<string, unknown>).usage) || undefined;
+ const existing = byEmoji.get(emoji);
+ if (existing) {
+ existing.usage ??= usage;
+ continue;
+ }
+ byEmoji.set(emoji, { emoji, ...(usage && { usage }) });
+ }
+
+ return [...byEmoji.values()].slice(0, MAX_REPLY_EMOJIS);
+};
diff --git a/apps/server/src/services/bot/platforms/slack/schema.ts b/apps/server/src/services/bot/platforms/slack/schema.ts
index ddb3239abd9..f40e6a45b82 100644
--- a/apps/server/src/services/bot/platforms/slack/schema.ts
+++ b/apps/server/src/services/bot/platforms/slack/schema.ts
@@ -16,6 +16,7 @@ import {
replyPlacementField,
watchKeywordsField,
} from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
import { DEFAULT_SLACK_CONNECTION_MODE, MAX_SLACK_HISTORY_LIMIT } from './const';
@@ -134,6 +135,7 @@ export const schema: FieldSchema[] = [
...makeGroupPolicyFields({ policy: 'open' }),
allowFromField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/apps/server/src/services/bot/platforms/telegram/schema.ts b/apps/server/src/services/bot/platforms/telegram/schema.ts
index f6ae4f29dbf..0ff2d513386 100644
--- a/apps/server/src/services/bot/platforms/telegram/schema.ts
+++ b/apps/server/src/services/bot/platforms/telegram/schema.ts
@@ -10,6 +10,7 @@ import {
reactionModeField,
watchKeywordsField,
} from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
export const schema: FieldSchema[] = [
@@ -98,6 +99,7 @@ export const schema: FieldSchema[] = [
...makeGroupPolicyFields({ policy: 'open' }),
allowFromField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/apps/server/src/services/bot/platforms/wechat/schema.ts b/apps/server/src/services/bot/platforms/wechat/schema.ts
index 4705d9667a7..159c58ded8a 100644
--- a/apps/server/src/services/bot/platforms/wechat/schema.ts
+++ b/apps/server/src/services/bot/platforms/wechat/schema.ts
@@ -1,6 +1,7 @@
import { DEFAULT_BOT_DEBOUNCE_MS, MAX_BOT_DEBOUNCE_MS } from '@lobechat/const';
import { displayToolCallsField, watchKeywordsField } from '../const';
+import { replyStyleFields } from '../replyStyle';
import type { FieldSchema } from '../types';
export const schema: FieldSchema[] = [
@@ -55,6 +56,7 @@ export const schema: FieldSchema[] = [
},
displayToolCallsField,
watchKeywordsField,
+ ...replyStyleFields,
],
type: 'object',
},
diff --git a/locales/en-US/agent.json b/locales/en-US/agent.json
index 49fe6faf17b..6e2fea8b9fe 100644
--- a/locales/en-US/agent.json
+++ b/locales/en-US/agent.json
@@ -109,6 +109,13 @@
"channel.botWakeWindowSeconds": "Follow-up window (seconds)",
"channel.botWakeWindowSecondsHint": "After the bot speaks, plain messages in the same place within this time count as a follow-up to it.",
"channel.channelListLimit": "Lists hold at most {{max}} entries — remove one first.",
+ "channel.channelReplyStyleChannelLabel": "Channel ID",
+ "channel.channelReplyStyleChannelPlaceholder": "Channel or thread ID",
+ "channel.channelReplyStyleStyleLabel": "Style",
+ "channel.channelReplyStyles": "Reply style per channel",
+ "channel.channelReplyStylesAdd": "Add channel",
+ "channel.channelReplyStylesEmpty": "No channel has its own style. Every channel uses the reply style above.",
+ "channel.channelReplyStylesHint": "A style for one channel or thread, used there instead of the reply style above.",
"channel.charLimit": "Character Limit",
"channel.charLimitHint": "Maximum number of characters per message",
"channel.comingSoon": "Coming Soon",
@@ -428,12 +435,23 @@
"channel.removeFailed": "Failed to remove bot",
"channel.removed": "Bot removed",
"channel.reply.instant": "Changes here take effect as soon as you make them. There is nothing to save.",
+ "channel.replyEmojiLabel": "Emoji",
+ "channel.replyEmojiPlaceholder": "e.g. <:doge:1234567890>",
+ "channel.replyEmojiUsageLabel": "When to use",
+ "channel.replyEmojiUsagePlaceholder": "e.g. when someone ships something",
+ "channel.replyEmojis": "Emoji the bot can use",
+ "channel.replyEmojisAdd": "Add emoji",
+ "channel.replyEmojisEmpty": "No emoji added. The bot uses plain Unicode emoji only when its style calls for it.",
+ "channel.replyEmojisHint": "Emoji and stickers the bot may drop into a reply, and when each fits. Paste the code as it appears in a message: a Discord custom emoji is <:name:id>; send \\:name: in Discord to see it. The bot uses them sparingly and never any custom emoji that isn't listed.",
"channel.replyPlacement": "Where to Reply",
"channel.replyPlacementAgent": "Let the bot decide",
"channel.replyPlacementAgentHint": "Quick answers stay in the channel; longer work moves into a thread under the message. When the work takes a while, it first posts a short note on what it will do.",
"channel.replyPlacementHint": "Where the bot answers a message sent to it in a channel. Messages already in a thread or a DM are answered where they are.",
"channel.replyPlacementThread": "Always open a thread",
"channel.replyPlacementThreadHint": "Every message that wakes the bot in a channel gets its own thread.",
+ "channel.replyStyle": "Reply style",
+ "channel.replyStyleHint": "How the bot talks in every channel, in your own words: tone, length, formatting, language, emoji. It shapes how the bot speaks, not what it does. You can also ask the bot to update this itself. Up to 2000 characters.",
+ "channel.replyStylePlaceholder": "Casual and short, like a teammate. No bullet lists. Reply in the language you were spoken to.",
"channel.resultDetail.hide": "Hide details",
"channel.resultDetail.show": "Show details",
"channel.runtimeDisconnected": "Bot disconnected",
diff --git a/locales/zh-CN/agent.json b/locales/zh-CN/agent.json
index f1d22db68e0..6b843dab408 100644
--- a/locales/zh-CN/agent.json
+++ b/locales/zh-CN/agent.json
@@ -109,6 +109,13 @@
"channel.botWakeWindowSeconds": "跟进窗口(秒)",
"channel.botWakeWindowSecondsHint": "机器人发言后,这段时间内同一位置的普通消息会被视为对它的跟进。",
"channel.channelListLimit": "列表最多包含 {{max}} 个条目 — 请先移除一个。",
+ "channel.channelReplyStyleChannelLabel": "频道 ID",
+ "channel.channelReplyStyleChannelPlaceholder": "频道或子区 ID",
+ "channel.channelReplyStyleStyleLabel": "风格",
+ "channel.channelReplyStyles": "按频道设置回复风格",
+ "channel.channelReplyStylesAdd": "添加频道",
+ "channel.channelReplyStylesEmpty": "还没有单独设置风格的频道,所有频道都用上面的回复风格。",
+ "channel.channelReplyStylesHint": "给某个频道或子区单独设置风格,在那里替代上面的回复风格。",
"channel.charLimit": "字符限制",
"channel.charLimitHint": "单条消息的最大字符数",
"channel.comingSoon": "即将上线",
@@ -428,12 +435,23 @@
"channel.removeFailed": "移除 Bot 失败",
"channel.removed": "Bot 已移除",
"channel.reply.instant": "这里的改动一做就生效,不需要再保存。",
+ "channel.replyEmojiLabel": "表情",
+ "channel.replyEmojiPlaceholder": "如 <:doge:1234567890>",
+ "channel.replyEmojiUsageLabel": "什么时候用",
+ "channel.replyEmojiUsagePlaceholder": "如 有人发布了新功能时",
+ "channel.replyEmojis": "可用表情",
+ "channel.replyEmojisAdd": "添加表情",
+ "channel.replyEmojisEmpty": "还没有添加表情。只有回复风格里要求时,bot 才会用普通的 Unicode 表情。",
+ "channel.replyEmojisHint": "bot 回复时可以用的表情和贴图,以及各自适合的场合。按消息里的原样粘贴代码:Discord 自定义表情是 <:name:id>,在 Discord 里发送 \\:name: 就能看到。bot 会克制使用,也不会用列表之外的自定义表情。",
"channel.replyPlacement": "回复位置",
"channel.replyPlacementAgent": "由 Bot 决定",
"channel.replyPlacementAgentHint": "简单的问题直接在频道里回复,需要较长时间处理的事情会在这条消息下开一个消息串回复。处理需要一段时间时,会先回一句接下来要做什么。",
"channel.replyPlacementHint": "在频道里叫到 Bot 时,它在哪里回复。已经在消息串或私信里的消息,就在原处回复。",
"channel.replyPlacementThread": "总是开消息串",
"channel.replyPlacementThreadHint": "在频道里每次叫到 Bot,都会开一个新的消息串回复。",
+ "channel.replyStyle": "回复风格",
+ "channel.replyStyleHint": "用你自己的话描述 bot 在各个频道里怎么说话:语气、长短、格式、语言、表情。只影响怎么说,不影响做什么。也可以直接让 bot 自己维护。最多 2000 字。",
+ "channel.replyStylePlaceholder": "像同事一样随意、简短。不用列表。别人用什么语言就用什么语言回复。",
"channel.resultDetail.hide": "收起详情",
"channel.resultDetail.show": "查看详情",
"channel.runtimeDisconnected": "机器人已断开连接",
diff --git a/packages/builtin-tool-message/src/manifest.ts b/packages/builtin-tool-message/src/manifest.ts
index d8762e876cf..ac8a4ca8cff 100644
--- a/packages/builtin-tool-message/src/manifest.ts
+++ b/packages/builtin-tool-message/src/manifest.ts
@@ -185,6 +185,25 @@ const botSettingsSchema = {
},
type: 'array',
},
+ replyEmojis: {
+ description:
+ 'Emoji and stickers the bot may use in its replies: `[{ emoji, usage? }]`, where `emoji` is pasted into the text as is (a Unicode emoji, a Discord custom emoji `<:name:id>` or `<a:name:id>`, a Slack `:name:`) and `usage` says when it fits ("someone ships something", "a teasing reply"). Overwrite-replace: read with getBotDetail, edit, write the whole array back. Only change it when the bot\'s owner asks; up to 50.',
+ items: {
+ additionalProperties: false,
+ properties: {
+ emoji: { type: 'string' },
+ usage: { type: 'string' },
+ },
+ required: ['emoji'],
+ type: 'object',
+ },
+ type: 'array',
+ },
+ replyStyle: {
+ description:
+ 'How the bot talks in every channel, as free text: tone, length, formatting, language, emoji use ("casual, short, like a teammate; no bullet lists; reply in the language you were spoken to"). Only how it speaks, not what it does (that is botWakeDuties). channelReplyStyles replaces it for one channel. Empty string clears it. Only change it when the bot\'s owner asks; up to 2000 characters.',
+ type: 'string',
+ },
botWakeDuties: {
description:
'The bot\'s duties (职责边界): free text, one duty per line, saying what the bot is responsible for in its channels (e.g. "When someone describes a feature request, assess it; for easy ones create a task for dario"). When bot-wake is on (botWakeEnabled), a message from anyone that nobody addressed to the bot but that falls within these duties may wake it. Empty string turns this off. Overwrite-replace: to add or change one duty, read the current text with getBotDetail, edit it, and write the whole text back. Only change it when the bot\'s owner asks; up to 4000 characters.',
@@ -197,6 +216,20 @@ const botSettingsSchema = {
minimum: 0,
type: 'number',
},
+ channelReplyStyles: {
+ description:
+ "A reply style for one channel or thread, replacing replyStyle there: `[{ channelId, style }]` (the Discord channel or thread id, the Slack channel id, …). Overwrite-replace like watchKeywords: read with getBotDetail, edit, write the whole array back. Only change it when the bot's owner asks.",
+ items: {
+ additionalProperties: false,
+ properties: {
+ channelId: { type: 'string' },
+ style: { type: 'string' },
+ },
+ required: ['channelId', 'style'],
+ type: 'object',
+ },
+ type: 'array',
+ },
dmPolicy: {
description:
'Direct-message gate. open=accept DMs from anyone (default); allowlist=only users in allowFrom can DM, fails closed if list is empty; pairing=non-listed senders get a one-time code and the owner runs /approve <code> to add them; disabled=ignore all DMs. pairing requires settings.userId (owner platform ID).',
@@ -935,7 +968,7 @@ export const MessageManifest: BuiltinToolManifest = {
settings: {
...botSettingsSchema,
description:
- 'Updated settings (partial update at the key level). See nested field descriptions for the allowed keys (dmPolicy, allowFrom, userId, groupPolicy, groupAllowFrom, serverId, watchKeywords, botWakeDuties, botWakeDutiesThreshold).',
+ 'Updated settings (partial update at the key level). See nested field descriptions for the allowed keys (dmPolicy, allowFrom, userId, groupPolicy, groupAllowFrom, serverId, watchKeywords, botWakeDuties, botWakeDutiesThreshold, replyStyle, channelReplyStyles, replyEmojis).',
},
},
required: ['botId'],
diff --git a/packages/builtin-tool-message/src/systemRole.ts b/packages/builtin-tool-message/src/systemRole.ts
index 2154ba51842..6c4f1ddceb4 100644
--- a/packages/builtin-tool-message/src/systemRole.ts
+++ b/packages/builtin-tool-message/src/systemRole.ts
@@ -133,6 +133,8 @@ Skipping step 1 will silently wipe other entries.
**botWakeDuties** — the bot's duties (职责边界): free text, one duty per line, describing what the bot is responsible for in its channels. With bot-wake on, a message from anyone that nobody addressed to the bot but that falls within these duties may wake it; empty turns this off. \`botWakeDutiesThreshold\` (0..1, default 0.8) is how sure it must be. Only change the duties when the bot's owner asks. The text is written as a whole: \`getBotDetail\` → edit \`settings.botWakeDuties\` (keep every duty you did not mean to touch, in the owner's language) → \`updateBot({ settings: { botWakeDuties: '<full text>' } })\`.
+**replyStyle / channelReplyStyles / replyEmojis** — how the bot talks, not what it does. \`replyStyle\` is free text for every channel (tone, length, formatting, emoji use); \`channelReplyStyles\` (\`[{ channelId, style }]\`) replaces it in one channel or thread; \`replyEmojis\` (\`[{ emoji, usage? }]\`) lists the emoji and stickers it may use, each pasted as is (\`<:name:id>\` on Discord, \`:name:\` on Slack, or a Unicode emoji) with when it fits. To find a Discord custom emoji's code, ask the owner to send it with a backslash in front (\`\\:name:\`). Only change them when the bot's owner asks; same read-modify-write as the arrays above.
+
**Validation behaviour:** the server validates settings before persisting and returns \`updateBot error: <field>: <reason>\` when something fails (e.g. \`userId: Pairing policy requires the owner's Platform User ID.\`). Surface that message to the user and ask for the missing value rather than retrying blindly.
**Owner only:** inside a bot conversation (Discord, Slack, …) only the bot's owner may change a bot or messenger connection (\`updateBot\`, \`toggleBot\`, \`deleteBot\`, \`connectBot\`, \`createBot\`, and the messenger unlink / uninstall / active-agent calls). When anyone else asks, the call fails with "Only the bot's owner can change its settings"; tell them to ask the owner instead of retrying or looking for another way to make the change.
diff --git a/packages/context-engine/src/providers/BotPlatformContextInjector.ts b/packages/context-engine/src/providers/BotPlatformContextInjector.ts
index 684da5f5eb3..cd421dc27b2 100644
--- a/packages/context-engine/src/providers/BotPlatformContextInjector.ts
+++ b/packages/context-engine/src/providers/BotPlatformContextInjector.ts
@@ -21,6 +21,10 @@ export interface BotPlatformContext {
platformName: string;
/** Pre-injected recent same-channel history for platforms without history-read. */
recentChannelHistory?: BotPlatformInfo['recentChannelHistory'];
+ /** Emoji the owner lets the bot use (see `formatBotPlatformContext`). */
+ replyEmojis?: BotPlatformInfo['replyEmojis'];
+ /** How the bot talks in this conversation (see `formatBotPlatformContext`). */
+ replyStyle?: BotPlatformInfo['replyStyle'];
supportsMarkdown: boolean;
/** `followup` tells the agent it may stay silent (see `formatBotPlatformContext`). */
wakeKind?: BotPlatformInfo['wakeKind'];
diff --git a/packages/locales/src/default/agent.ts b/packages/locales/src/default/agent.ts
index 62031163f39..87a72403a2b 100644
--- a/packages/locales/src/default/agent.ts
+++ b/packages/locales/src/default/agent.ts
@@ -441,6 +441,30 @@ export default {
'channel.watchKeywordsAdd': 'Add keyword',
'channel.watchKeywordsEmpty':
'No keywords added yet — bot only wakes on @mention or DM in subscribed channels.',
+ 'channel.replyStyle': 'Reply style',
+ 'channel.replyStyleHint':
+ 'How the bot talks in every channel, in your own words: tone, length, formatting, language, emoji. It shapes how the bot speaks, not what it does. You can also ask the bot to update this itself. Up to 2000 characters.',
+ 'channel.replyStylePlaceholder':
+ 'Casual and short, like a teammate. No bullet lists. Reply in the language you were spoken to.',
+ 'channel.channelReplyStyles': 'Reply style per channel',
+ 'channel.channelReplyStylesHint':
+ 'A style for one channel or thread, used there instead of the reply style above.',
+ 'channel.channelReplyStylesAdd': 'Add channel',
+ 'channel.channelReplyStylesEmpty':
+ 'No channel has its own style. Every channel uses the reply style above.',
+ 'channel.channelReplyStyleChannelLabel': 'Channel ID',
+ 'channel.channelReplyStyleChannelPlaceholder': 'Channel or thread ID',
+ 'channel.channelReplyStyleStyleLabel': 'Style',
+ 'channel.replyEmojis': 'Emoji the bot can use',
+ 'channel.replyEmojisHint':
+ "Emoji and stickers the bot may drop into a reply, and when each fits. Paste the code as it appears in a message: a Discord custom emoji is <:name:id>; send \\:name: in Discord to see it. The bot uses them sparingly and never any custom emoji that isn't listed.",
+ 'channel.replyEmojisAdd': 'Add emoji',
+ 'channel.replyEmojisEmpty':
+ 'No emoji added. The bot uses plain Unicode emoji only when its style calls for it.',
+ 'channel.replyEmojiLabel': 'Emoji',
+ 'channel.replyEmojiPlaceholder': 'e.g. <:doge:1234567890>',
+ 'channel.replyEmojiUsageLabel': 'When to use',
+ 'channel.replyEmojiUsagePlaceholder': 'e.g. when someone ships something',
'channel.botWakeEnabled': 'Judge unprompted follow-ups',
'channel.botWakeEnabledHint':
"Turns on the wake options below. The bot judges messages nobody addressed to it and may join in; off keeps today's behavior, where a watch keyword wakes the bot without any check.",
diff --git a/packages/prompts/src/prompts/botPlatformContext/__snapshots__/index.test.ts.snap b/packages/prompts/src/prompts/botPlatformContext/__snapshots__/index.test.ts.snap
index 581f08d805d..be4b8254d6c 100644
--- a/packages/prompts/src/prompts/botPlatformContext/__snapshots__/index.test.ts.snap
+++ b/packages/prompts/src/prompts/botPlatformContext/__snapshots__/index.test.ts.snap
@@ -15,6 +15,7 @@ You are a participant in a **WeChat** conversation — not an external assistant
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -59,6 +60,7 @@ You are a participant in a **Discord** conversation — not an external assistan
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -90,6 +92,7 @@ You are a participant in a **WeChat** conversation — not an external assistant
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -133,6 +136,7 @@ You are a participant in a **WeChat** conversation — not an external assistant
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -184,6 +188,7 @@ You are a participant in a **WeChat** conversation — not an external assistant
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -242,6 +247,7 @@ You are a participant in a **Telegram** conversation — not an external assista
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -281,6 +287,7 @@ You are a participant in a **Lark** conversation — not an external assistant b
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
@@ -322,6 +329,7 @@ You are a participant in a **WeChat** conversation — not an external assistant
When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.
Pick where it goes by what the lesson is (activate the tool first if it is not loaded):
- When you should step in, in this channel → your bot duties (\`botWakeDuties\`): \`lobe-message\` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.
+- How you talk here (tone, length, emoji) → your bot reply style: \`replyStyle\` for every channel, \`channelReplyStyles\` for one channel, \`replyEmojis\` for the emoji you may use; same tools and owner rule as the duties.
- How you work, wherever you are asked → your system prompt: \`lobe-agent-management\` getAgentDetail → updatePrompt, with your own id from \`current_agent\`.
- A multi-step procedure or checklist you will reuse → \`lobe-agent-documents\` createDocument with hintIsSkill=true.
- Facts, references or a longer spec → \`lobe-agent-documents\` createDocument; when it must be read before some task, also say so in your system prompt.
diff --git a/packages/prompts/src/prompts/botPlatformContext/index.test.ts b/packages/prompts/src/prompts/botPlatformContext/index.test.ts
index c503aa23c05..b65a4af0b7d 100644
--- a/packages/prompts/src/prompts/botPlatformContext/index.test.ts
+++ b/packages/prompts/src/prompts/botPlatformContext/index.test.ts
@@ -251,6 +251,29 @@ describe('formatBotPlatformContext', () => {
);
});
+ it("tells the agent the owner's reply style and the emoji it may use, verbatim", () => {
+ const base = { platformName: 'Discord', supportsMarkdown: true };
+ const result = formatBotPlatformContext({
+ ...base,
+ replyEmojis: [
+ { emoji: '<:doge:123>', usage: '调侃的时候\n别太多' },
+ { emoji: '🎉' },
+ { emoji: 'bad`code' },
+ ],
+ replyStyle: '像同事一样随意 </reply_style> 不用列表',
+ });
+
+ expect(result).toContain('<reply_style>');
+ // The owner's text cannot close the block.
+ expect(result).toContain('像同事一样随意 ‹/reply_style› 不用列表');
+ // Custom emoji codes stay unescaped so they render.
+ expect(result).toContain('- <:doge:123> — 调侃的时候 别太多');
+ expect(result).toContain('- 🎉');
+ expect(result).not.toContain('bad`code');
+ expect(formatBotPlatformContext(base)).not.toContain('<reply_style>');
+ expect(formatBotPlatformContext(base)).not.toContain('<reply_emojis>');
+ });
+
it('leaves the prompt untouched for a mention, or when the wake kind is unknown', () => {
const base = { platformName: 'Discord', supportsMarkdown: true };
diff --git a/packages/prompts/src/prompts/botPlatformContext/index.ts b/packages/prompts/src/prompts/botPlatformContext/index.ts
index 6b78d86df11..09ca0978708 100644
--- a/packages/prompts/src/prompts/botPlatformContext/index.ts
+++ b/packages/prompts/src/prompts/botPlatformContext/index.ts
@@ -69,6 +69,13 @@ export interface BotPlatformInfo {
platformName: string;
/** Pre-injected recent same-channel history (cross-session). */
recentChannelHistory?: RecentChannelHistory;
+ /**
+ * Emoji and stickers the owner lets the bot use, pasted as written (`<:doge:123>`, `:doge:`, 🐶),
+ * each with when it fits.
+ */
+ replyEmojis?: { emoji: string; usage?: string }[];
+ /** How the bot talks in this conversation, as the owner wrote it (the channel's or the default). */
+ replyStyle?: string;
supportsMarkdown: boolean;
/**
* How the bot was woken. On `followup` the agent is told it may stay silent; on `mention` (or
@@ -104,6 +111,8 @@ export const formatBotPlatformContext = ({
openingReply,
platformName,
recentChannelHistory,
+ replyEmojis,
+ replyStyle,
supportsMarkdown,
wakeKind,
warnings,
@@ -137,6 +146,7 @@ export const formatBotPlatformContext = ({
'When someone here tells you how to do better — corrects a mistake, says what to do next time, or gives a standing rule — make the change durable in this same turn. A promise only said in chat ("next time I will…") is lost when this run ends.',
'Pick where it goes by what the lesson is (activate the tool first if it is not loaded):',
"- When you should step in, in this channel → your bot duties (`botWakeDuties`): `lobe-message` getBotDetail → updateBot. Only the bot's owner may change bot settings; if updateBot refuses, put the rule in your system prompt instead.",
+ '- How you talk here (tone, length, emoji) → your bot reply style: `replyStyle` for every channel, `channelReplyStyles` for one channel, `replyEmojis` for the emoji you may use; same tools and owner rule as the duties.',
'- How you work, wherever you are asked → your system prompt: `lobe-agent-management` getAgentDetail → updatePrompt, with your own id from `current_agent`.',
'- A multi-step procedure or checklist you will reuse → `lobe-agent-documents` createDocument with hintIsSkill=true.',
'- Facts, references or a longer spec → `lobe-agent-documents` createDocument; when it must be read before some task, also say so in your system prompt.',
@@ -214,6 +224,34 @@ export const formatBotPlatformContext = ({
);
}
+ // Owner-written; only the tag characters are escaped so the text cannot close the block.
+ const style = replyStyle?.trim().replaceAll('<', '‹').replaceAll('>', '›');
+ if (style) {
+ lines.push(
+ '',
+ '<reply_style>',
+ 'How you talk in this conversation, as your owner wrote it. It shapes your tone and form, not what you do or whether you reply; where it conflicts with the platform rules below, the platform rules win.',
+ style,
+ '</reply_style>',
+ );
+ }
+
+ // Pasted verbatim: a custom emoji code (`<:doge:123>`) only renders unescaped. One line each.
+ const emojis = (replyEmojis ?? []).filter(({ emoji }) => emoji.trim() && !/[\n\r`]/.test(emoji));
+ if (emojis.length > 0) {
+ lines.push(
+ '',
+ '<reply_emojis>',
+ 'Emoji and stickers you may use, one per line: write the code before the dash exactly as listed, without backticks around it. Use one when it fits the moment, the way people in this chat do; most replies need none, and never more than one or two. Do not write any other custom emoji code: one not on this list shows as broken text.',
+ ...emojis.map(({ emoji, usage }) =>
+ usage?.trim()
+ ? `- ${emoji.trim()} — ${usage.trim().replaceAll(/\s+/g, ' ')}`
+ : `- ${emoji.trim()}`,
+ ),
+ '</reply_emojis>',
+ );
+ }
+
if (!supportsMarkdown) {
lines.push(
'',
diff --git a/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx b/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx
index b0cf1030dd3..f25c27a7421 100644
--- a/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx
+++ b/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx
@@ -271,8 +271,8 @@ describe('channel settings form: bot-wake options', () => {
expect(area).toBeInTheDocument();
expect(Number(area.getAttribute('rows'))).toBeGreaterThanOrEqual(8);
expect(Number(area.getAttribute('maxlength'))).toBeGreaterThanOrEqual(2000);
- // Multi-line next to the duties only: the others stay single-line.
- expect(container.querySelectorAll('textarea')).toHaveLength(2);
+ // Multi-line next to the duties and the reply style only: the others stay single-line.
+ expect(container.querySelectorAll('textarea')).toHaveLength(3);
});
it('opens the wake options with the duties: a text area, empty by default, and its dial', () => {