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

推荐订阅源

有赞技术团队
有赞技术团队
B
Blog
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
量子位
博客园 - 叶小钗
T
Tailwind CSS Blog
小众软件
小众软件
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
雷峰网
雷峰网
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Blog — PlanetScale
Blog — PlanetScale
V
V2EX
博客园_首页
I
InfoQ
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog

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 context session start boundary · openclaw/op...
VACInc · 2026-05-12 · via Recent Commits to openclaw:main

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

179179

key: string;

180180

threadId?: number;

181181

messages: Array<{ msg: Message; ctx: TelegramContext; receivedAtMs: number }>;

182+

promptContextMinTimestampMs?: number;

182183

timer: ReturnType<typeof setTimeout>;

183184

};

184185

const textFragmentBuffer = new Map<string, TextFragmentEntry>();

@@ -197,6 +198,22 @@ export const registerTelegramHandlers = ({

197198

debounceLane: TelegramDebounceLane;

198199

botUsername?: string;

199200

threadId?: number;

201+

promptContextMinTimestampMs?: number;

202+

};

203+

const normalizePromptContextMinTimestampMs = (timestampMs?: number) =>

204+

typeof timestampMs === "number" && Number.isFinite(timestampMs) ? timestampMs : undefined;

205+

const latestPromptContextMinTimestampMs = (

206+

...timestamps: Array<number | undefined>

207+

): number | undefined => {

208+

let latest: number | undefined;

209+

for (const timestampMs of timestamps) {

210+

const normalized = normalizePromptContextMinTimestampMs(timestampMs);

211+

if (normalized === undefined) {

212+

continue;

213+

}

214+

latest = latest === undefined ? normalized : Math.max(latest, normalized);

215+

}

216+

return latest;

200217

};

201218

const resolveTelegramDebounceLane = (msg: Message): TelegramDebounceLane => {

202219

const forwardMeta = msg as {

@@ -394,9 +411,13 @@ export const registerTelegramHandlers = ({

394411

return;

395412

}

396413

if (entries.length === 1) {

414+

const promptContextMinTimestampMs = normalizePromptContextMinTimestampMs(

415+

last.promptContextMinTimestampMs,

416+

);

397417

await processMessageWithReplyChain(last.ctx, last.msg, last.allMedia, last.storeAllowFrom, {

398418

receivedAtMs: last.receivedAtMs,

399419

ingressBuffer: "inbound-debounce",

420+

...(promptContextMinTimestampMs !== undefined ? { promptContextMinTimestampMs } : {}),

400421

});

401422

return;

402423

}

@@ -409,6 +430,9 @@ export const registerTelegramHandlers = ({

409430

return;

410431

}

411432

const first = entries[0];

433+

const promptContextMinTimestampMs = latestPromptContextMinTimestampMs(

434+

...entries.map((entry) => entry.promptContextMinTimestampMs),

435+

);

412436

const baseCtx = first.ctx;

413437

const syntheticMessage = buildSyntheticTextMessage({

414438

base: first.msg,

@@ -426,6 +450,7 @@ export const registerTelegramHandlers = ({

426450

...(messageIdOverride ? { messageIdOverride } : {}),

427451

receivedAtMs: first.receivedAtMs,

428452

ingressBuffer: "inbound-debounce",

453+

...(promptContextMinTimestampMs !== undefined ? { promptContextMinTimestampMs } : {}),

429454

},

430455

);

431456

},

@@ -454,13 +479,14 @@ export const registerTelegramHandlers = ({

454479

messageThreadId?: number;

455480

resolvedThreadId?: number;

456481

senderId?: string | number;

482+

runtimeCfg?: OpenClawConfig;

457483

}): {

458484

agentId: string;

459485

sessionEntry: ReturnType<typeof resolveSessionStoreEntry>["existing"];

460486

sessionKey: string;

461487

model?: string;

462488

} => {

463-

const runtimeCfg = telegramDeps.getRuntimeConfig();

489+

const runtimeCfg = params.runtimeCfg ?? telegramDeps.getRuntimeConfig();

464490

const resolvedThreadId =

465491

params.resolvedThreadId ??

466492

resolveTelegramForumThreadId({

@@ -505,7 +531,7 @@ export const registerTelegramHandlers = ({

505531

const storePath = telegramDeps.resolveStorePath(runtimeCfg.session?.store, {

506532

agentId: route.agentId,

507533

});

508-

const store = loadSessionStore(storePath);

534+

const store = (telegramDeps.loadSessionStore ?? loadSessionStore)(storePath);

509535

const entry = resolveSessionStoreEntry({ store, sessionKey }).existing;

510536

const storedOverride = resolveStoredModelOverride({

511537

sessionEntry: entry,

@@ -585,6 +611,9 @@ export const registerTelegramHandlers = ({

585611

primaryEntry.msg,

586612

allMedia,

587613

storeAllowFrom,

614+

entry.promptContextMinTimestampMs !== undefined

615+

? { promptContextMinTimestampMs: entry.promptContextMinTimestampMs }

616+

: undefined,

588617

);

589618

} catch (err) {

590619

runtime.error?.(danger(`media group handler failed: ${String(err)}`));

@@ -620,6 +649,9 @@ export const registerTelegramHandlers = ({

620649

messageIdOverride: String(last.msg.message_id),

621650

receivedAtMs: first.receivedAtMs,

622651

ingressBuffer: "text-fragment",

652+

...(entry.promptContextMinTimestampMs !== undefined

653+

? { promptContextMinTimestampMs: entry.promptContextMinTimestampMs }

654+

: {}),

623655

});

624656

} catch (err) {

625657

runtime.error?.(danger(`text fragment handler failed: ${String(err)}`));

@@ -698,6 +730,7 @@ export const registerTelegramHandlers = ({

698730

const buildPromptContextForMessage = (

699731

msg: Message,

700732

replyChainNodes: TelegramCachedMessageNode[],

733+

options?: TelegramMessageContextOptions,

701734

): TelegramPromptContextEntry[] => {

702735

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

703736

const currentNode = messageCache.get({

@@ -715,6 +748,9 @@ export const registerTelegramHandlers = ({

715748

replyChainNodes,

716749

recentLimit: 10,

717750

replyTargetWindowSize: 2,

751+

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

752+

? { minTimestampMs: options.promptContextMinTimestampMs }

753+

: {}),

718754

});

719755

return conversationContext.length > 0

720756

? [

@@ -785,7 +821,7 @@ export const registerTelegramHandlers = ({

785821

) => {

786822

const replyChainNodes = buildReplyChainForMessage(msg);

787823

const { replyMedia, replyChain } = await resolveReplyMediaForChain(ctx, replyChainNodes);

788-

const promptContext = buildPromptContextForMessage(msg, replyChainNodes);

824+

const promptContext = buildPromptContextForMessage(msg, replyChainNodes, options);

789825

await processMessage(

790826

ctx,

791827

allMedia,

@@ -1267,6 +1303,7 @@ export const registerTelegramHandlers = ({

12671303

storeAllowFrom: string[];

12681304

sendOversizeWarning: boolean;

12691305

oversizeLogMessage: string;

1306+

promptContextMinTimestampMs?: number;

12701307

}) => {

12711308

const {

12721309

ctx,

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

12771314

storeAllowFrom,

12781315

sendOversizeWarning,

12791316

oversizeLogMessage,

1317+

promptContextMinTimestampMs,

12801318

} = params;

1281131912821320

// Text fragment handling - Telegram splits long pastes into multiple inbound messages (~4096 chars).

@@ -1314,6 +1352,10 @@ export const registerTelegramHandlers = ({

13141352

nextTotalChars <= TELEGRAM_TEXT_FRAGMENT_MAX_TOTAL_CHARS

13151353

) {

13161354

existing.messages.push({ msg, ctx, receivedAtMs: nowMs });

1355+

existing.promptContextMinTimestampMs = latestPromptContextMinTimestampMs(

1356+

existing.promptContextMinTimestampMs,

1357+

promptContextMinTimestampMs,

1358+

);

13171359

scheduleTextFragmentFlush(existing);

13181360

return;

13191361

}

@@ -1335,6 +1377,7 @@ export const registerTelegramHandlers = ({

13351377

const entry: TextFragmentEntry = {

13361378

key,

13371379

messages: [{ msg, ctx, receivedAtMs: nowMs }],

1380+

...(promptContextMinTimestampMs !== undefined ? { promptContextMinTimestampMs } : {}),

13381381

timer: setTimeout(() => {}, TELEGRAM_TEXT_FRAGMENT_MAX_GAP_MS),

13391382

};

13401383

textFragmentBuffer.set(key, entry);

@@ -1350,6 +1393,10 @@ export const registerTelegramHandlers = ({

13501393

if (existing) {

13511394

clearTimeout(existing.timer);

13521395

existing.messages.push({ msg, ctx });

1396+

existing.promptContextMinTimestampMs = latestPromptContextMinTimestampMs(

1397+

existing.promptContextMinTimestampMs,

1398+

promptContextMinTimestampMs,

1399+

);

13531400

existing.timer = setTimeout(async () => {

13541401

mediaGroupBuffer.delete(mediaGroupId);

13551402

mediaGroupProcessing = mediaGroupProcessing

@@ -1362,6 +1409,7 @@ export const registerTelegramHandlers = ({

13621409

} else {

13631410

const entry: MediaGroupEntry = {

13641411

messages: [{ msg, ctx }],

1412+

...(promptContextMinTimestampMs !== undefined ? { promptContextMinTimestampMs } : {}),

13651413

timer: setTimeout(async () => {

13661414

mediaGroupBuffer.delete(mediaGroupId);

13671415

mediaGroupProcessing = mediaGroupProcessing

@@ -1458,6 +1506,7 @@ export const registerTelegramHandlers = ({

14581506

debounceKey,

14591507

debounceLane,

14601508

botUsername: ctx.me?.username,

1509+

...(promptContextMinTimestampMs !== undefined ? { promptContextMinTimestampMs } : {}),

14611510

});

14621511

};

14631512

bot.on("callback_query", async (ctx) => {

@@ -2326,6 +2375,18 @@ export const registerTelegramHandlers = ({

23262375

}

23272376

}

232823772378+

const promptContextMinTimestampMs = normalizePromptContextMinTimestampMs(

2379+

resolveTelegramSessionState({

2380+

chatId: event.chatId,

2381+

isGroup: event.isGroup,

2382+

isForum: event.isForum,

2383+

messageThreadId: event.messageThreadId,

2384+

resolvedThreadId,

2385+

senderId: event.senderId,

2386+

runtimeCfg: cfg,

2387+

}).sessionEntry?.sessionStartedAt,

2388+

);

2389+23292390

recordMessageForReplyChain(event.msg, resolvedThreadId ?? dmThreadId);

23302391

await processInboundMessage({

23312392

ctx: event.ctx,

@@ -2336,6 +2397,7 @@ export const registerTelegramHandlers = ({

23362397

storeAllowFrom,

23372398

sendOversizeWarning: event.sendOversizeWarning,

23382399

oversizeLogMessage: event.oversizeLogMessage,

2400+

...(promptContextMinTimestampMs !== undefined ? { promptContextMinTimestampMs } : {}),

23392401

});

23402402

} catch (err) {

23412403

runtime.error?.(danger(`${event.errorMessage}: ${String(err)}`));