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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
月光博客
月光博客
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
U
Unit 42
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
B
Blog
C
Check Point Blog
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
量子位
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell

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): avoid fallback after message tool send (#7...
neeravmakwan · 2026-05-07 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai

66
77

### Changes

88
9+

- Telegram: treat successful same-chat `message` tool outbound sends during an inbound telegram turn as delivered when deciding whether to emit the rewritten silent reply fallback (#78685). Thanks @neeravmakwana.

910

- Docs/iMessage: deprecate BlueBubbles for new OpenClaw setups, document the upstream server-release rationale, and point new iMessage deployments toward the native `imsg` path while keeping BlueBubbles as a supported legacy fallback.

1011

- Discord/streaming: default Discord replies to progress draft previews so tool/work activity appears in one edited Discord message unless `channels.discord.streaming.mode` is set to `off`.

1112

- Plugins/install: add `npm-pack:<path.tgz>` installs so local npm pack artifacts run through the same managed npm-root install, lockfile verification, dependency scan, and install-record path as registry npm plugins.

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";

22

import { captureEnv } from "openclaw/plugin-sdk/test-env";

33

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

44

import { handleTelegramAction, telegramActionRuntime } from "./action-runtime.js";

5+

import { beginTelegramInboundTurnDeliveryCorrelation } from "./inbound-turn-delivery.js";

56
67

const originalTelegramActionRuntime = { ...telegramActionRuntime };

78

const reactMessageTelegram = vi.fn(async () => ({ ok: true }));

@@ -357,6 +358,27 @@ describe("handleTelegramAction", () => {

357358

});

358359

});

359360
361+

it("marks the matching inbound turn delivered after a successful send", async () => {

362+

let count = 0;

363+

const end = beginTelegramInboundTurnDeliveryCorrelation("telegram-session", {

364+

outboundTo: "@testchannel",

365+

markInboundTurnDelivered: () => {

366+

count += 1;

367+

},

368+

});

369+

await handleTelegramAction(

370+

{

371+

action: "sendMessage",

372+

to: "@testchannel",

373+

content: "Hello, Telegram!",

374+

},

375+

telegramConfig(),

376+

{ sessionKey: "telegram-session" },

377+

);

378+

expect(count).toBe(1);

379+

end();

380+

});

381+
360382

it("accepts shared send action aliases", async () => {

361383

await handleTelegramAction(

362384

{

Original file line numberDiff line numberDiff line change

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

1919

import type { MessagePresentation } from "openclaw/plugin-sdk/interactive-runtime";

2020

import { createTelegramActionGate, resolveTelegramPollActionGateState } from "./accounts.js";

2121

import { resolveTelegramInlineButtons } from "./button-types.js";

22+

import { notifyTelegramInboundTurnOutboundSuccess } from "./inbound-turn-delivery.js";

2223

import {

2324

resolveTelegramInlineButtonsScope,

2425

resolveTelegramTargetChatType,

@@ -228,6 +229,7 @@ export async function handleTelegramAction(

228229

options?: {

229230

mediaLocalRoots?: readonly string[];

230231

mediaReadFile?: (filePath: string) => Promise<Buffer>;

232+

sessionKey?: string | null;

231233

},

232234

): Promise<AgentToolResult<unknown>> {

233235

const { action, accountId } = {

@@ -394,6 +396,11 @@ export async function handleTelegramAction(

394396

readBooleanParam(params, "asDocument") ??

395397

false,

396398

});

399+

notifyTelegramInboundTurnOutboundSuccess({

400+

sessionKey: options?.sessionKey ?? undefined,

401+

to,

402+

accountId,

403+

});

397404

await maybePinTelegramActionSend({

398405

args: params,

399406

cfg,

Original file line numberDiff line numberDiff line change

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

8080

} from "./error-policy.js";

8181

import { shouldSuppressLocalTelegramExecApprovalPrompt } from "./exec-approvals.js";

8282

import { markdownToTelegramChunks, renderTelegramHtmlText } from "./format.js";

83+

import { beginTelegramInboundTurnDeliveryCorrelation } from "./inbound-turn-delivery.js";

8384

import {

8485

createLaneDeliveryStateTracker,

8586

createLaneTextDeliverer,

@@ -684,6 +685,14 @@ export const dispatchTelegramMessage = async ({

684685

? ctxPayload.ReplyToQuoteEntities

685686

: undefined;

686687

const deliveryState = createLaneDeliveryStateTracker();

688+

const endTelegramInboundTurnDeliveryCorrelation = beginTelegramInboundTurnDeliveryCorrelation(

689+

ctxPayload.SessionKey,

690+

{

691+

outboundTo: String(chatId),

692+

outboundAccountId: route.accountId,

693+

markInboundTurnDelivered: () => deliveryState.markDelivered(),

694+

},

695+

);

687696

const clearGroupHistory = () => {

688697

if (isGroup && historyKey) {

689698

clearHistoryEntriesIfEnabled({

@@ -1354,6 +1363,7 @@ export const dispatchTelegramMessage = async ({

13541363

} finally {

13551364

dispatchWasSuperseded = isDispatchSuperseded();

13561365

releaseReplyFence();

1366+

endTelegramInboundTurnDeliveryCorrelation();

13571367

}

13581368

if (dispatchWasSuperseded) {

13591369

if (statusReactionController) {

Original file line numberDiff line numberDiff line change

@@ -43,6 +43,7 @@ describe("telegramMessageActions", () => {

4343

cfg: {} as never,

4444

accountId: "default",

4545

mediaLocalRoots: [],

46+

sessionKey: "telegram-session",

4647

} as never);

4748
4849

expect(handleTelegramActionMock).toHaveBeenCalledWith(

@@ -62,6 +63,7 @@ describe("telegramMessageActions", () => {

6263

expect.anything(),

6364

expect.objectContaining({

6465

mediaLocalRoots: [],

66+

sessionKey: "telegram-session",

6567

}),

6668

);

6769

});

Original file line numberDiff line numberDiff line change

@@ -177,7 +177,15 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {

177177

extractToolSend: ({ args }) => {

178178

return extractToolSend(args, "sendMessage");

179179

},

180-

handleAction: async ({ action, params, cfg, accountId, mediaLocalRoots, toolContext }) => {

180+

handleAction: async ({

181+

action,

182+

params,

183+

cfg,

184+

accountId,

185+

mediaLocalRoots,

186+

sessionKey,

187+

toolContext,

188+

}) => {

181189

const telegramAction = resolveTelegramMessageActionName(action);

182190

if (!telegramAction) {

183191

throw new Error(`Unsupported Telegram action: ${action}`);

@@ -194,7 +202,7 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {

194202

: {}),

195203

},

196204

cfg,

197-

{ mediaLocalRoots },

205+

{ mediaLocalRoots, sessionKey },

198206

);

199207

},

200208

};

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,48 @@

1+

import { describe, expect, it } from "vitest";

2+

import {

3+

beginTelegramInboundTurnDeliveryCorrelation,

4+

notifyTelegramInboundTurnOutboundSuccess,

5+

} from "./inbound-turn-delivery.js";

6+
7+

describe("telegram inbound turn delivery", () => {

8+

it("marks delivered once for a matching outbound send then clears correlation", () => {

9+

let count = 0;

10+

const end = beginTelegramInboundTurnDeliveryCorrelation("sess:z", {

11+

outboundTo: "999",

12+

outboundAccountId: "a1",

13+

markInboundTurnDelivered: () => {

14+

count += 1;

15+

},

16+

});

17+

notifyTelegramInboundTurnOutboundSuccess({

18+

sessionKey: "sess:z",

19+

to: "999",

20+

accountId: "a1",

21+

});

22+

expect(count).toBe(1);

23+

end();

24+

notifyTelegramInboundTurnOutboundSuccess({

25+

sessionKey: "sess:z",

26+

to: "999",

27+

accountId: "a1",

28+

});

29+

expect(count).toBe(1);

30+

});

31+
32+

it("ignores outbound sends to another destination", () => {

33+

let count = 0;

34+

const end = beginTelegramInboundTurnDeliveryCorrelation("sess:y", {

35+

outboundTo: "1",

36+

markInboundTurnDelivered: () => {

37+

count += 1;

38+

},

39+

});

40+

notifyTelegramInboundTurnOutboundSuccess({

41+

sessionKey: "sess:y",

42+

to: "2",

43+

accountId: undefined,

44+

});

45+

expect(count).toBe(0);

46+

end();

47+

});

48+

});

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,42 @@

1+

export type TelegramInboundTurnDeliveryEnd = () => void;

2+
3+

type ActiveTurn = {

4+

outboundTo: string;

5+

outboundAccountId?: string;

6+

markInboundTurnDelivered: () => void;

7+

};

8+
9+

const registry = new Map<string, ActiveTurn>();

10+
11+

export function beginTelegramInboundTurnDeliveryCorrelation(

12+

sessionKey: string | undefined,

13+

turn: ActiveTurn,

14+

): TelegramInboundTurnDeliveryEnd {

15+

const key = sessionKey?.trim();

16+

if (!key) {

17+

return () => {};

18+

}

19+

registry.set(key, turn);

20+

return () => {

21+

registry.delete(key);

22+

};

23+

}

24+
25+

export function notifyTelegramInboundTurnOutboundSuccess(params: {

26+

sessionKey: string | undefined;

27+

to: string;

28+

accountId?: string | null;

29+

}): void {

30+

const key = params.sessionKey?.trim();

31+

if (!key) {

32+

return;

33+

}

34+

const turn = registry.get(key);

35+

if (!turn || turn.outboundTo !== params.to) {

36+

return;

37+

}

38+

if (turn.outboundAccountId && params.accountId && params.accountId !== turn.outboundAccountId) {

39+

return;

40+

}

41+

turn.markInboundTurnDelivered();

42+

}