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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
Jina AI
Jina AI
The Cloudflare Blog
V
Visual Studio Blog
博客园_首页
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
博客园 - Franky

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: centralize inbound history shaping · openclaw/o...
steipete · 2026-05-15 · via Recent Commits to openclaw:main

File tree

  • extensions

    • discord/src/monitor

    • feishu/src

    • imessage/src/monitor

    • line/src

    • matrix/src/matrix/monitor

    • mattermost/src/mattermost

    • msteams/src/monitor-handler

    • signal/src/monitor

    • slack/src/monitor/message-handler

    • telegram/src

    • whatsapp/src/auto-reply/monitor

    • zalouser/src

  • src

    • auto-reply

      • reply

    • channels/turn

    • plugin-sdk

    • plugins/contracts

Original file line numberDiff line numberDiff line change

@@ -6,7 +6,10 @@ import { resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context

66

import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/conversation-runtime";

77

import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";

88

import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-dispatch-runtime";

9-

import { buildPendingHistoryContextFromMap } from "openclaw/plugin-sdk/reply-history";

9+

import {

10+

buildInboundHistoryFromMap,

11+

buildPendingHistoryContextFromMap,

12+

} from "openclaw/plugin-sdk/reply-history";

1013

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

1114

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

1215

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

@@ -287,14 +290,13 @@ export async function buildDiscordMessageProcessContext(params: {

287290

return null;

288291

}

289292

const lastRouteTo = dmConversationTarget ?? effectiveTo;

290-

const inboundHistory =

291-

shouldIncludeChannelHistory && historyLimit > 0

292-

? (guildHistories.get(messageChannelId) ?? []).map((entry) => ({

293-

sender: entry.sender,

294-

body: entry.body,

295-

timestamp: entry.timestamp,

296-

}))

297-

: undefined;

293+

const inboundHistory = shouldIncludeChannelHistory

294+

? buildInboundHistoryFromMap({

295+

historyMap: guildHistories,

296+

historyKey: messageChannelId,

297+

limit: historyLimit,

298+

})

299+

: undefined;

298300

const originatingTo = autoThreadContext?.OriginatingTo ?? dmConversationTarget ?? replyTarget;

299301

const effectiveSessionKey =

300302

boundSessionKey ?? autoThreadContext?.SessionKey ?? threadKeys.sessionKey;

Original file line numberDiff line numberDiff line change

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

77

} from "openclaw/plugin-sdk/conversation-runtime";

88

import { resolveAgentOutboundIdentity } from "openclaw/plugin-sdk/outbound-runtime";

99

import {

10+

buildInboundHistoryFromMap,

1011

buildPendingHistoryContextFromMap,

1112

clearHistoryEntriesIfEnabled,

1213

DEFAULT_GROUP_HISTORY_LIMIT,

@@ -1076,11 +1077,11 @@ export async function handleFeishuMessage(params: {

10761077
10771078

const inboundHistory =

10781079

isGroup && historyKey && historyLimit > 0 && chatHistories

1079-

? (chatHistories.get(historyKey) ?? []).map((entry) => ({

1080-

sender: entry.sender,

1081-

body: entry.body,

1082-

timestamp: entry.timestamp,

1083-

}))

1080+

? buildInboundHistoryFromMap({

1081+

historyMap: chatHistories,

1082+

historyKey,

1083+

limit: historyLimit,

1084+

})

10841085

: undefined;

10851086
10861087

const threadContextBySessionKey = new Map<

Original file line numberDiff line numberDiff line change

@@ -21,6 +21,7 @@ import { hasControlCommand } from "openclaw/plugin-sdk/command-auth-native";

2121

import type { DmPolicy, GroupPolicy, OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";

2222

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

2323

import {

24+

buildInboundHistoryFromMap,

2425

buildPendingHistoryContextFromMap,

2526

recordPendingHistoryEntryIfEnabled,

2627

type HistoryEntry,

@@ -989,11 +990,11 @@ export function buildIMessageInboundContext(params: {

989990

const imessageTo = (decision.isGroup ? chatTarget : undefined) || `imessage:${decision.sender}`;

990991

const inboundHistory =

991992

decision.isGroup && decision.historyKey && params.historyLimit > 0

992-

? (params.groupHistories.get(decision.historyKey) ?? []).map((entry) => ({

993-

sender: entry.sender,

994-

body: entry.body,

995-

timestamp: entry.timestamp,

996-

}))

993+

? buildInboundHistoryFromMap({

994+

historyMap: params.groupHistories,

995+

historyKey: decision.historyKey,

996+

limit: params.historyLimit,

997+

})

997998

: undefined;

998999
9991000

const ctxPayload = finalizeInboundContext({

Original file line numberDiff line numberDiff line change

@@ -54,6 +54,20 @@ vi.mock("openclaw/plugin-sdk/runtime-env", () => ({

5454

}));

5555

vi.mock("openclaw/plugin-sdk/reply-history", () => ({

5656

DEFAULT_GROUP_HISTORY_LIMIT: 20,

57+

buildInboundHistoryFromMap: ({

58+

historyMap,

59+

historyKey,

60+

limit,

61+

}: {

62+

historyMap: Map<string, HistoryEntry[]>;

63+

historyKey: string;

64+

limit: number;

65+

}) => {

66+

if (limit <= 0) {

67+

return undefined;

68+

}

69+

return (historyMap.get(historyKey) ?? []).slice(-limit);

70+

},

5771

clearHistoryEntriesIfEnabled: ({

5872

historyMap,

5973

historyKey,

Original file line numberDiff line numberDiff line change

@@ -14,7 +14,7 @@ import {

1414

resolveRuntimeConversationBindingRoute,

1515

} from "openclaw/plugin-sdk/conversation-runtime";

1616

import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-dispatch-runtime";

17-

import type { HistoryEntry } from "openclaw/plugin-sdk/reply-history";

17+

import { buildInboundHistoryFromMap, type HistoryEntry } from "openclaw/plugin-sdk/reply-history";

1818

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

1919

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

2020

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

@@ -469,11 +469,11 @@ export async function buildLineMessageContext(params: BuildLineMessageContextPar

469469

const historyKey = isGroup ? peerId : undefined;

470470

const inboundHistory =

471471

historyKey && groupHistories && (historyLimit ?? 0) > 0

472-

? (groupHistories.get(historyKey) ?? []).map((entry) => ({

473-

sender: entry.sender,

474-

body: entry.body,

475-

timestamp: entry.timestamp,

476-

}))

472+

? buildInboundHistoryFromMap({

473+

historyMap: groupHistories,

474+

historyKey,

475+

limit: historyLimit ?? 0,

476+

})

477477

: undefined;

478478
479479

const finalized = await finalizeLineInboundContext({

Original file line numberDiff line numberDiff line change

@@ -24,6 +24,7 @@ import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-na

2424

import { hasFinalInboundReplyDispatch } from "openclaw/plugin-sdk/inbound-reply-dispatch";

2525

import type { ChannelBotLoopProtectionFacts } from "openclaw/plugin-sdk/inbound-reply-dispatch";

2626

import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";

27+

import { buildInboundHistoryFromEntries } from "openclaw/plugin-sdk/reply-history";

2728

import type { GetReplyOptions } from "openclaw/plugin-sdk/reply-runtime";

2829

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

2930

import {

@@ -1137,7 +1138,12 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam

11371138

messageId,

11381139

})

11391140

: undefined;

1140-

const inboundHistory = preparedTrigger?.history;

1141+

const inboundHistory = preparedTrigger

1142+

? buildInboundHistoryFromEntries({

1143+

entries: preparedTrigger.history,

1144+

limit: historyLimit,

1145+

})

1146+

: undefined;

11411147

const triggerSnapshot = preparedTrigger;

11421148
11431149

return {

Original file line numberDiff line numberDiff line change

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

8888

import {

8989

buildAgentMediaPayload,

9090

buildModelsProviderData,

91+

buildInboundHistoryFromMap,

9192

buildPendingHistoryContextFromMap,

9293

createChannelPairingController,

9394

createChannelMessageReplyPipeline,

@@ -1529,11 +1530,11 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}

15291530

const commandBody = rawText.trim();

15301531

const inboundHistory =

15311532

historyKey && historyLimit > 0

1532-

? (channelHistories.get(historyKey) ?? []).map((entry) => ({

1533-

sender: entry.sender,

1534-

body: entry.body,

1535-

timestamp: entry.timestamp,

1536-

}))

1533+

? buildInboundHistoryFromMap({

1534+

historyMap: channelHistories,

1535+

historyKey,

1536+

limit: historyLimit,

1537+

})

15371538

: undefined;

15381539

const ctxPayload = core.channel.reply.finalizeInboundContext({

15391540

Body: combinedBody,

Original file line numberDiff line numberDiff line change

@@ -30,6 +30,7 @@ export { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";

3030

export { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";

3131

export {

3232

DEFAULT_GROUP_HISTORY_LIMIT,

33+

buildInboundHistoryFromMap,

3334

buildPendingHistoryContextFromMap,

3435

recordPendingHistoryEntryIfEnabled,

3536

} from "openclaw/plugin-sdk/reply-history";

Original file line numberDiff line numberDiff line change

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

1515

resolveInboundReplyDispatchCounts,

1616

} from "openclaw/plugin-sdk/inbound-reply-dispatch";

1717

import {

18+

buildInboundHistoryFromMap,

1819

buildPendingHistoryContextFromMap,

1920

DEFAULT_GROUP_HISTORY_LIMIT,

2021

recordPendingHistoryEntryIfEnabled,

@@ -729,11 +730,11 @@ export function createMSTeamsMessageHandler(deps: MSTeamsMessageHandlerDeps) {

729730
730731

const inboundHistory =

731732

isRoomish && historyKey && historyLimit > 0

732-

? (conversationHistories.get(historyKey) ?? []).map((entry) => ({

733-

sender: entry.sender,

734-

body: entry.body,

735-

timestamp: entry.timestamp,

736-

}))

733+

? buildInboundHistoryFromMap({

734+

historyMap: conversationHistories,

735+

historyKey,

736+

limit: historyLimit,

737+

})

737738

: undefined;

738739

const commandBody = text.trim();

739740

const quoteSenderAllowed =

Original file line numberDiff line numberDiff line change

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

2727

import { runInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch";

2828

import { kindFromMime } from "openclaw/plugin-sdk/media-runtime";

2929

import {

30+

buildInboundHistoryFromMap,

3031

buildPendingHistoryContextFromMap,

3132

recordPendingHistoryEntryIfEnabled,

3233

} from "openclaw/plugin-sdk/reply-history";

@@ -186,11 +187,11 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {

186187

const signalTo = normalizeSignalMessagingTarget(signalToRaw) ?? signalToRaw;

187188

const inboundHistory =

188189

entry.isGroup && historyKey && deps.historyLimit > 0

189-

? (deps.groupHistories.get(historyKey) ?? []).map((historyEntry) => ({

190-

sender: historyEntry.sender,

191-

body: historyEntry.body,

192-

timestamp: historyEntry.timestamp,

193-

}))

190+

? buildInboundHistoryFromMap({

191+

historyMap: deps.groupHistories,

192+

historyKey,

193+

limit: deps.historyLimit,

194+

})

194195

: undefined;

195196

const ctxPayload = finalizeInboundContext({

196197

Body: combinedBody,