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

推荐订阅源

罗磊的独立博客
Recent Announcements
Recent Announcements
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
U
Unit 42
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
T
Tailwind CSS Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
腾讯CDC
I
InfoQ
GbyAI
GbyAI
博客园_首页

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
refactor(telegram): clarify reply supersession fence · op...
steipete · 2026-05-04 · via Recent Commits to openclaw:main

@@ -123,13 +123,13 @@ type DispatchTelegramMessageParams = {

123123124124

type TelegramReasoningLevel = "off" | "on" | "stream";

125125126-

type TelegramAbortFenceState = {

126+

type TelegramReplyFenceState = {

127127

generation: number;

128128

activeDispatches: number;

129129

};

130130131131

// Newer accepted turns and authorized aborts can arrive ahead of older same-session reply work.

132-

const telegramAbortFenceByKey = new Map<string, TelegramAbortFenceState>();

132+

const telegramReplyFenceByKey = new Map<string, TelegramReplyFenceState>();

133133134134

function normalizeTelegramFenceKey(value: unknown): string | undefined {

135135

if (typeof value !== "string") {

@@ -139,7 +139,7 @@ function normalizeTelegramFenceKey(value: unknown): string | undefined {

139139

return trimmed.length > 0 ? trimmed : undefined;

140140

}

141141142-

function resolveTelegramAbortFenceKey(params: {

142+

function resolveTelegramReplyFenceKey(params: {

143143

ctxPayload: { SessionKey?: string; CommandTargetSessionKey?: string };

144144

chatId: number | string;

145145

threadSpec: { id?: number | string | null; scope?: string };

@@ -151,41 +151,51 @@ function resolveTelegramAbortFenceKey(params: {

151151

);

152152

}

153153154-

function beginTelegramAbortFence(params: { key: string; supersede: boolean }): number {

155-

const existing = telegramAbortFenceByKey.get(params.key);

156-

const state: TelegramAbortFenceState = existing ?? {

154+

function beginTelegramReplyFence(params: { key: string; supersede: boolean }): number {

155+

const existing = telegramReplyFenceByKey.get(params.key);

156+

const state: TelegramReplyFenceState = existing ?? {

157157

generation: 0,

158158

activeDispatches: 0,

159159

};

160160

if (params.supersede) {

161161

state.generation += 1;

162162

}

163163

state.activeDispatches += 1;

164-

telegramAbortFenceByKey.set(params.key, state);

164+

telegramReplyFenceByKey.set(params.key, state);

165165

return state.generation;

166166

}

167167168-

function isTelegramAbortFenceSuperseded(params: { key: string; generation: number }): boolean {

169-

return (telegramAbortFenceByKey.get(params.key)?.generation ?? 0) !== params.generation;

168+

function isTelegramReplyFenceSuperseded(params: { key: string; generation: number }): boolean {

169+

return (telegramReplyFenceByKey.get(params.key)?.generation ?? 0) !== params.generation;

170170

}

171171172-

function endTelegramAbortFence(key: string): void {

173-

const state = telegramAbortFenceByKey.get(key);

172+

function endTelegramReplyFence(key: string): void {

173+

const state = telegramReplyFenceByKey.get(key);

174174

if (!state) {

175175

return;

176176

}

177177

state.activeDispatches -= 1;

178178

if (state.activeDispatches <= 0) {

179-

telegramAbortFenceByKey.delete(key);

179+

telegramReplyFenceByKey.delete(key);

180180

}

181181

}

182182183-

export function getTelegramAbortFenceSizeForTests(): number {

184-

return telegramAbortFenceByKey.size;

183+

function shouldSupersedeTelegramReplyFence(ctxPayload: {

184+

Body?: string;

185+

RawBody?: string;

186+

CommandBody?: string;

187+

CommandAuthorized: boolean;

188+

}): boolean {

189+

const dispatchText = ctxPayload.CommandBody ?? ctxPayload.RawBody ?? ctxPayload.Body ?? "";

190+

return !isAbortRequestText(dispatchText) || ctxPayload.CommandAuthorized;

191+

}

192+193+

export function getTelegramReplyFenceSizeForTests(): number {

194+

return telegramReplyFenceByKey.size;

185195

}

186196187-

export function resetTelegramAbortFenceForTests(): void {

188-

telegramAbortFenceByKey.clear();

197+

export function resetTelegramReplyFenceForTests(): void {

198+

telegramReplyFenceByKey.clear();

189199

}

190200191201

function resolveTelegramReasoningLevel(params: {

@@ -305,25 +315,25 @@ export const dispatchTelegramMessage = async ({

305315

}

306316

await statusReactionController.restoreInitial();

307317

};

308-

const dispatchFenceKey = resolveTelegramAbortFenceKey({

318+

const replyFenceKey = resolveTelegramReplyFenceKey({

309319

ctxPayload,

310320

chatId,

311321

threadSpec,

312322

});

313-

let abortFenceGeneration: number | undefined;

323+

let replyFenceGeneration: number | undefined;

314324

let dispatchWasSuperseded = false;

315325

const isDispatchSuperseded = () =>

316-

abortFenceGeneration !== undefined &&

317-

isTelegramAbortFenceSuperseded({

318-

key: dispatchFenceKey,

319-

generation: abortFenceGeneration,

326+

replyFenceGeneration !== undefined &&

327+

isTelegramReplyFenceSuperseded({

328+

key: replyFenceKey,

329+

generation: replyFenceGeneration,

320330

});

321-

const releaseAbortFence = () => {

322-

if (abortFenceGeneration === undefined) {

331+

const releaseReplyFence = () => {

332+

if (replyFenceGeneration === undefined) {

323333

return;

324334

}

325-

endTelegramAbortFence(dispatchFenceKey);

326-

abortFenceGeneration = undefined;

335+

endTelegramReplyFence(replyFenceKey);

336+

replyFenceGeneration = undefined;

327337

};

328338

const draftMaxChars = Math.min(textLimit, 4096);

329339

const tableMode = resolveMarkdownTableMode({

@@ -607,13 +617,10 @@ export const dispatchTelegramMessage = async ({

607617

: undefined;

608618609619

const chunkMode = resolveChunkMode(cfg, "telegram", route.accountId);

610-

const dispatchText = ctxPayload.CommandBody ?? ctxPayload.RawBody ?? ctxPayload.Body ?? "";

611-

const isAbortRequest = isAbortRequestText(dispatchText);

612-

const shouldSupersedeAbortFence = isAbortRequest ? ctxPayload.CommandAuthorized : true;

613620614-

abortFenceGeneration = beginTelegramAbortFence({

615-

key: dispatchFenceKey,

616-

supersede: shouldSupersedeAbortFence,

621+

replyFenceGeneration = beginTelegramReplyFence({

622+

key: replyFenceKey,

623+

supersede: shouldSupersedeTelegramReplyFence(ctxPayload),

617624

});

618625619626

const implicitQuoteReplyTargetId =

@@ -908,7 +915,7 @@ export const dispatchTelegramMessage = async ({

908915909916

const flushBufferedFinalAnswer = async () => {

910917

const buffered =

911-

reasoningStepState.takeBufferedFinalAnswer(abortFenceGeneration);

918+

reasoningStepState.takeBufferedFinalAnswer(replyFenceGeneration);

912919

if (!buffered) {

913920

return;

914921

}

@@ -936,7 +943,7 @@ export const dispatchTelegramMessage = async ({

936943

reasoningStepState.bufferFinalAnswer({

937944

payload,

938945

text: segment.text,

939-

bufferedGeneration: abortFenceGeneration,

946+

bufferedGeneration: replyFenceGeneration,

940947

});

941948

continue;

942949

}

@@ -1254,7 +1261,7 @@ export const dispatchTelegramMessage = async ({

12541261

}

12551262

} finally {

12561263

dispatchWasSuperseded = isDispatchSuperseded();

1257-

releaseAbortFence();

1264+

releaseReplyFence();

12581265

}

12591266

if (dispatchWasSuperseded) {

12601267

if (statusReactionController) {