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

推荐订阅源

Google DeepMind News
Google DeepMind News
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
罗磊的独立博客
Last Week in AI
Last Week in AI
B
Blog
IT之家
IT之家
S
SegmentFault 最新的问题
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
博客园 - 聂微东
U
Unit 42
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
MyScale Blog
MyScale 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: seed Slack thread context after reset (#97100) · ope...
bek91 · 2026-06-28 · via Recent Commits to openclaw:main
11

// Slack plugin module implements prepare thread context behavior.

22

import { formatInboundEnvelope } from "openclaw/plugin-sdk/channel-inbound";

33

import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";

4-

import type { ContextVisibilityMode } from "openclaw/plugin-sdk/config-contracts";

4+

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

55

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

66

import {

77

filterSupplementalContextItems,

@@ -10,7 +10,7 @@ import {

1010

import type { ResolvedSlackAccount } from "../../accounts.js";

1111

import type { SlackMessageEvent } from "../../types.js";

1212

import { resolveSlackAllowListMatch } from "../allow-list.js";

13-

import { readSessionUpdatedAt } from "../config.runtime.js";

13+

import { readSessionUpdatedAt, resolveChannelResetConfig } from "../config.runtime.js";

1414

import type { SlackMonitorContext } from "../context.js";

1515

import type { SlackMediaResult } from "../media-types.js";

1616

import { resolveSlackThreadHistory, type SlackThreadStarter } from "../thread.js";

@@ -35,13 +35,49 @@ function loadSlackMediaModule(): Promise<SlackMediaModule> {

3535

type SlackThreadContextData = {

3636

threadStarterBody: string | undefined;

3737

threadHistoryBody: string | undefined;

38-

threadSessionPreviousTimestamp: number | undefined;

38+

shouldSeedInitialThreadContext: boolean;

3939

threadLabel: string | undefined;

4040

threadStarterMedia: SlackMediaResult[] | null;

4141

};

42424343

const SLACK_THREAD_CONTEXT_USER_LOOKUP_CONCURRENCY = 4;

444445+

type SlackSessionResetFreshness = {

46+

state: "missing" | "fresh" | "stale";

47+

};

48+49+

type SlackSessionFreshnessRuntime = {

50+

session?: {

51+

resolveEntryResetFreshness?: (params: {

52+

storePath?: string;

53+

sessionKey: string;

54+

sessionCfg?: OpenClawConfig["session"];

55+

resetType: "thread";

56+

resetOverride?: ReturnType<typeof resolveChannelResetConfig>;

57+

}) => SlackSessionResetFreshness;

58+

};

59+

};

60+61+

function resolveSlackThreadSessionFreshness(params: {

62+

ctx: SlackMonitorContext;

63+

storePath: string;

64+

sessionKey: string;

65+

}): SlackSessionResetFreshness | undefined {

66+

// Gateway startup supplies the full channel runtime, but the public surface

67+

// intentionally keeps non-context helpers untyped for external plugins.

68+

const runtime = params.ctx.channelRuntime as SlackSessionFreshnessRuntime | undefined;

69+

return runtime?.session?.resolveEntryResetFreshness?.({

70+

storePath: params.storePath,

71+

sessionKey: params.sessionKey,

72+

sessionCfg: params.ctx.cfg.session,

73+

resetType: "thread",

74+

resetOverride: resolveChannelResetConfig({

75+

sessionCfg: params.ctx.cfg.session,

76+

channel: "slack",

77+

}),

78+

});

79+

}

80+4581

function isSlackThreadContextSenderAllowed(params: {

4682

allowFromLower: string[];

4783

allowNameMatching: boolean;

@@ -125,19 +161,36 @@ export async function resolveSlackThreadContextData(params: {

125161

let threadHistoryBody: string | undefined;

126162

let threadLabel: string | undefined;

127163

let threadStarterMedia: SlackMediaResult[] | null = null;

128-

const threadSessionPreviousTimestamp =

164+

const threadSessionFreshness =

129165

params.isThreadReply && params.threadTs

166+

? resolveSlackThreadSessionFreshness({

167+

ctx: params.ctx,

168+

storePath: params.storePath,

169+

sessionKey: params.sessionKey,

170+

})

171+

: undefined;

172+

const threadSessionPreviousTimestamp =

173+

params.isThreadReply && params.threadTs && !threadSessionFreshness

130174

? readSessionUpdatedAt({

131175

storePath: params.storePath,

132176

sessionKey: params.sessionKey,

133177

})

134178

: undefined;

179+

const shouldSeedInitialThreadContext = Boolean(

180+

params.isThreadReply &&

181+

params.threadTs &&

182+

(threadSessionFreshness

183+

? threadSessionFreshness.state !== "fresh"

184+

: threadSessionPreviousTimestamp === undefined),

185+

);

186+

const shouldLoadInitialThreadHistory =

187+

shouldSeedInitialThreadContext || params.forceInitialHistory === true;

135188136189

if (!params.isThreadReply || !params.threadTs) {

137190

return {

138191

threadStarterBody,

139192

threadHistoryBody,

140-

threadSessionPreviousTimestamp,

193+

shouldSeedInitialThreadContext,

141194

threadLabel,

142195

threadStarterMedia,

143196

};

@@ -195,10 +248,9 @@ export async function resolveSlackThreadContextData(params: {

195248

threadLabel = `Slack thread ${params.roomLabel}`;

196249

}

197250198-

const isNewThreadSession = !threadSessionPreviousTimestamp;

199251

const includeBotStarterAsRootContext = shouldIncludeBotThreadStarterContext({

200252

starterIsCurrentBot,

201-

isNewThreadSession,

253+

isNewThreadSession: shouldSeedInitialThreadContext,

202254

hasStarterText: Boolean(starter?.text),

203255

});

204256

@@ -218,10 +270,7 @@ export async function resolveSlackThreadContextData(params: {

218270219271

const threadInitialHistoryLimit = params.account.config?.thread?.initialHistoryLimit ?? 20;

220272221-

if (

222-

threadInitialHistoryLimit > 0 &&

223-

(!threadSessionPreviousTimestamp || params.forceInitialHistory)

224-

) {

273+

if (threadInitialHistoryLimit > 0 && shouldLoadInitialThreadHistory) {

225274

const currentBotRootTs = starter?.ts ?? params.threadTs;

226275

const threadHistory = await resolveSlackThreadHistory({

227276

channelId: params.message.channel,

@@ -333,7 +382,7 @@ export async function resolveSlackThreadContextData(params: {

333382

return {

334383

threadStarterBody,

335384

threadHistoryBody,

336-

threadSessionPreviousTimestamp,

385+

shouldSeedInitialThreadContext,

337386

threadLabel,

338387

threadStarterMedia,

339388

};