惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
博客园_首页
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
Y
Y Combinator Blog
博客园 - 聂微东
The Cloudflare Blog
小众软件
小众软件
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
H
Help Net Security
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
Control Telegram group history context (#89547) · opencla...
mmaps · 2026-06-16 · via Recent Commits to openclaw:main

@@ -123,6 +123,7 @@ import {

123123

evaluateTelegramGroupBaseAccess,

124124

evaluateTelegramGroupPolicyAccess,

125125

} from "./group-access.js";

126+

import { resolveTelegramGroupHistoryContextMode } from "./group-history-context.js";

126127

import { migrateTelegramGroupConfig } from "./group-migration.js";

127128

import {

128129

resolveTelegramCommandIngressAuthorization,

@@ -1173,12 +1174,76 @@ export const registerTelegramHandlers = ({

11731174

is_reply_target: flags?.replyTarget === true ? true : undefined,

11741175

});

117511761177+

const buildMentionOnlyGroupHistoryPredicate = (params: {

1178+

ctx: TelegramContext;

1179+

msg: Message;

1180+

threadId?: number;

1181+

}): ((node: TelegramCachedMessageNode) => boolean) => {

1182+

const runtimeCfg = telegramDeps.getRuntimeConfig();

1183+

const isForum =

1184+

params.msg.chat.type === "supergroup" &&

1185+

Boolean(params.msg.chat.is_forum || params.msg.is_topic_message);

1186+

const senderId = params.msg.from?.id != null ? String(params.msg.from.id) : undefined;

1187+

const sessionState = resolveTelegramSessionState({

1188+

chatId: params.msg.chat.id,

1189+

isGroup: true,

1190+

isForum,

1191+

messageThreadId: params.msg.message_thread_id,

1192+

resolvedThreadId: params.threadId,

1193+

senderId,

1194+

runtimeCfg,

1195+

});

1196+

const conversationId = buildTelegramGroupPeerId(params.msg.chat.id, params.threadId);

1197+

const mentionRegexes = buildMentionRegexes(runtimeCfg, sessionState.agentId, {

1198+

provider: "telegram",

1199+

conversationId,

1200+

providerPolicy: telegramCfg.mentionPatterns,

1201+

});

1202+

const botUsername = params.ctx.me?.username?.trim().toLowerCase();

1203+

const botId = params.ctx.me?.id;

1204+

return (node) => {

1205+

if (botId != null && node.sourceMessage.from?.id === botId) {

1206+

return true;

1207+

}

1208+

const replyFromId = node.sourceMessage.reply_to_message?.from?.id;

1209+

if (

1210+

botId != null &&

1211+

replyFromId === botId &&

1212+

!isTelegramForumServiceMessage(node.sourceMessage.reply_to_message)

1213+

) {

1214+

return true;

1215+

}

1216+

const messageTextParts = getTelegramTextParts(node.sourceMessage);

1217+

const hasAnyMention = messageTextParts.entities.some((ent) => ent.type === "mention");

1218+

const explicitlyMentioned = botUsername

1219+

? hasBotMention(node.sourceMessage, botUsername)

1220+

: false;

1221+

return matchesMentionWithExplicit({

1222+

text: messageTextParts.text,

1223+

mentionRegexes,

1224+

explicit: {

1225+

hasAnyMention,

1226+

isExplicitlyMentioned: explicitlyMentioned,

1227+

canResolveExplicit: Boolean(botUsername),

1228+

},

1229+

});

1230+

};

1231+

};

1232+11761233

const buildPromptContextForMessage = async (

1234+

ctx: TelegramContext,

11771235

msg: Message,

11781236

replyChainNodes: TelegramCachedMessageNode[],

11791237

options?: TelegramMessageContextOptions,

11801238

mediaByMessageId?: ReadonlyMap<string, TelegramMediaRef>,

11811239

): Promise<TelegramPromptContextEntry[]> => {

1240+

const isGroup = msg.chat.type === "group" || msg.chat.type === "supergroup";

1241+

const groupHistoryContextMode = isGroup

1242+

? resolveTelegramGroupHistoryContextMode(telegramCfg)

1243+

: "recent";

1244+

if (isGroup && groupHistoryContextMode === "none") {

1245+

return [];

1246+

}

11821247

const messageId = typeof msg.message_id === "number" ? String(msg.message_id) : undefined;

11831248

const currentNode = await messageCache.get({

11841249

accountId,

@@ -1198,6 +1263,9 @@ export const registerTelegramHandlers = ({

11981263

...(options?.promptContextMinTimestampMs !== undefined

11991264

? { minTimestampMs: options.promptContextMinTimestampMs }

12001265

: {}),

1266+

...(isGroup && groupHistoryContextMode === "mention-only"

1267+

? { includeNode: buildMentionOnlyGroupHistoryPredicate({ ctx, msg, threadId }) }

1268+

: {}),

12011269

});

12021270

return conversationContext.length > 0

12031271

? [

@@ -1314,6 +1382,7 @@ export const registerTelegramHandlers = ({

13141382

}

13151383

}

13161384

const promptContext = await buildPromptContextForMessage(

1385+

params.ctx,

13171386

params.msg,

13181387

replyChainNodes,

13191388

params.options,