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

推荐订阅源

博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
罗磊的独立博客
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
B
Blog RSS Feed

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
fix(telegram): hydrate group reply-chain media into model...
eldar702 · 2026-06-16 · via Recent Commits to openclaw:main

@@ -25,6 +25,7 @@ import type {

2525

TelegramTopicConfig,

2626

} from "openclaw/plugin-sdk/config-contracts";

2727

import { mutateConfigFile } from "openclaw/plugin-sdk/config-mutation";

28+

import { resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context-visibility-runtime";

2829

import {

2930

buildPluginBindingResolvedText,

3031

parsePluginBindingApprovalCustomId,

@@ -37,18 +38,21 @@ import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";

3738

import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";

3839

import { resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";

3940

import { danger, logVerbose, warn } from "openclaw/plugin-sdk/runtime-env";

41+

import { evaluateSupplementalContextVisibility } from "openclaw/plugin-sdk/security-runtime";

4042

import {

4143

getSessionEntry,

4244

listSessionEntries,

4345

patchSessionEntry,

4446

} from "openclaw/plugin-sdk/session-store-runtime";

4547

import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";

4648

import { expandTelegramAllowFromWithAccessGroups } from "./access-groups.js";

47-

import { resolveTelegramMediaRuntimeOptions } from "./accounts.js";

49+

import { resolveTelegramAccount, resolveTelegramMediaRuntimeOptions } from "./accounts.js";

4850

import { withTelegramApiErrorLogging } from "./api-logging.js";

4951

import {

5052

normalizeDmAllowFromWithStore,

5153

firstDefined,

54+

isSenderAllowed,

55+

normalizeAllowFrom,

5256

resolveTelegramEffectiveDmPolicy,

5357

type NormalizedAllowFrom,

5458

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

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

123127

evaluateTelegramGroupBaseAccess,

124128

evaluateTelegramGroupPolicyAccess,

125129

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

130+

import { resolveTelegramScopedGroupConfig } from "./group-config-helpers.js";

126131

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

127132

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

128133

import {

@@ -1292,13 +1297,18 @@ export const registerTelegramHandlers = ({

12921297

const resolveReplyMediaForChain = async (

12931298

ctx: TelegramContext,

12941299

chain: TelegramCachedMessageNode[],

1300+

shouldHydrateMedia: (node: TelegramCachedMessageNode, index: number) => Promise<boolean>,

12951301

): Promise<{ replyMedia: TelegramMediaRef[]; replyChain: TelegramReplyChainEntry[] }> => {

12961302

const replyMedia: TelegramMediaRef[] = [];

12971303

const replyChain: TelegramReplyChainEntry[] = [];

1298-

for (const node of chain) {

1304+

for (const [index, node] of chain.entries()) {

12991305

let mediaRef: TelegramMediaRef | undefined;

13001306

const replyFileId = resolveInboundMediaFileId(node.sourceMessage);

1301-

if (replyFileId && hasInboundMedia(node.sourceMessage)) {

1307+

if (

1308+

replyFileId &&

1309+

hasInboundMedia(node.sourceMessage) &&

1310+

(await shouldHydrateMedia(node, index))

1311+

) {

13021312

try {

13031313

const media = await resolveMedia({

13041314

ctx: {

@@ -1349,9 +1359,65 @@ export const registerTelegramHandlers = ({

13491359

};

13501360

try {

13511361

const replyChainNodes = await buildReplyChainForMessage(params.msg);

1362+

const isGroupConversation =

1363+

params.msg.chat.type === "group" || params.msg.chat.type === "supergroup";

1364+

const runtimeCfg = telegramDeps.getRuntimeConfig();

1365+

const runtimeTelegramCfg = resolveTelegramAccount({ cfg: runtimeCfg, accountId }).config;

1366+

const isForum =

1367+

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

1368+

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

1369+

const scopedThreadId = resolveTelegramForumThreadId({

1370+

isForum,

1371+

messageThreadId: params.msg.message_thread_id,

1372+

});

1373+

const { groupConfig, topicConfig } = resolveTelegramScopedGroupConfig(

1374+

runtimeTelegramCfg,

1375+

params.msg.chat.id,

1376+

scopedThreadId,

1377+

);

1378+

const scopedAllowFrom = firstDefined(topicConfig?.allowFrom, groupConfig?.allowFrom);

1379+

const configuredGroupAllowFrom =

1380+

scopedAllowFrom ??

1381+

opts.groupAllowFrom ??

1382+

runtimeTelegramCfg.groupAllowFrom ??

1383+

runtimeTelegramCfg.allowFrom ??

1384+

opts.allowFrom;

1385+

const contextVisibilityMode = resolveChannelContextVisibilityMode({

1386+

cfg: runtimeCfg,

1387+

channel: "telegram",

1388+

accountId,

1389+

});

1390+

const shouldHydrateReplyMedia = async (

1391+

node: TelegramCachedMessageNode,

1392+

index: number,

1393+

): Promise<boolean> => {

1394+

if (!isGroupConversation) {

1395+

return true;

1396+

}

1397+

const expandedAllowFrom = await expandTelegramAllowFromWithAccessGroups({

1398+

cfg: runtimeCfg,

1399+

allowFrom: configuredGroupAllowFrom,

1400+

accountId,

1401+

senderId: node.senderId,

1402+

});

1403+

const effectiveAllow = normalizeAllowFrom(expandedAllowFrom);

1404+

const senderAllowed = effectiveAllow.hasEntries

1405+

? isSenderAllowed({

1406+

allow: effectiveAllow,

1407+

senderId: node.senderId,

1408+

senderUsername: node.senderUsername,

1409+

})

1410+

: true;

1411+

return evaluateSupplementalContextVisibility({

1412+

mode: contextVisibilityMode,

1413+

kind: index === 0 ? "quote" : "thread",

1414+

senderAllowed,

1415+

}).include;

1416+

};

13521417

const { replyMedia, replyChain } = await resolveReplyMediaForChain(

13531418

params.ctx,

13541419

replyChainNodes,

1420+

shouldHydrateReplyMedia,

13551421

);

13561422

const promptContextMediaByMessageId = new Map<string, TelegramMediaRef>();

13571423

const currentMessageId =

@@ -1366,19 +1432,15 @@ export const registerTelegramHandlers = ({

13661432

path: currentPromptMediaPath,

13671433

});

13681434

}

1369-

const isGroupConversation =

1370-

params.msg.chat.type === "group" || params.msg.chat.type === "supergroup";

1371-

if (!isGroupConversation) {

1372-

for (const entry of replyChain) {

1373-

const promptMediaPath = entry.mediaPath

1374-

? resolveTelegramPromptMediaPath(entry.mediaPath)

1375-

: undefined;

1376-

if (entry.messageId && entry.mediaPath && promptMediaPath) {

1377-

promptContextMediaByMessageId.set(entry.messageId, {

1378-

path: promptMediaPath,

1379-

...(entry.mediaType ? { contentType: entry.mediaType } : {}),

1380-

});

1381-

}

1435+

for (const entry of replyChain) {

1436+

const promptMediaPath = entry.mediaPath

1437+

? resolveTelegramPromptMediaPath(entry.mediaPath)

1438+

: undefined;

1439+

if (entry.messageId && entry.mediaPath && promptMediaPath) {

1440+

promptContextMediaByMessageId.set(entry.messageId, {

1441+

path: promptMediaPath,

1442+

...(entry.mediaType ? { contentType: entry.mediaType } : {}),

1443+

});

13821444

}

13831445

}

13841446

const promptContext = await buildPromptContextForMessage(