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

推荐订阅源

M
MIT News - Artificial intelligence
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
The Cloudflare Blog
IT之家
IT之家
雷峰网
雷峰网
小众软件
小众软件
博客园 - 叶小钗
博客园 - 聂微东
爱范儿
爱范儿
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
博客园 - 【当耐特】
V
V2EX
博客园_首页
T
Tailwind CSS 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
refactor: record dropped channel history in turn kernel ·...
steipete · 2026-05-15 · via Recent Commits to openclaw:main

@@ -1,5 +1,9 @@

11

import type { ReplyPayload } from "../../auto-reply/reply-payload.js";

2-

import { clearHistoryEntriesIfEnabled } from "../../auto-reply/reply/history.js";

2+

import {

3+

clearHistoryEntriesIfEnabled,

4+

recordPendingHistoryEntryWithMedia,

5+

} from "../../auto-reply/reply/history.js";

6+

import type { HistoryMediaEntry } from "../../auto-reply/reply/history.types.js";

37

import { createChannelReplyPipeline } from "../message/reply-pipeline.js";

48

import type { CreateChannelReplyPipelineParams } from "../message/reply-pipeline.js";

59

import { recordChannelBotPairLoopAndCheckSuppression } from "./bot-loop-protection.js";

@@ -38,6 +42,8 @@ import type {

3842

ChannelTurnResolved,

3943

ChannelTurnResult,

4044

DispatchedChannelTurnResult,

45+

InboundMediaFacts,

46+

NormalizedTurnInput,

4147

PreparedChannelTurn,

4248

PreflightFacts,

4349

RunChannelTurnParams,

@@ -61,6 +67,7 @@ export type {

6167

ChannelTurnAdapter,

6268

ChannelTurnAdmission,

6369

ChannelTurnDeliveryAdapter,

70+

ChannelTurnDroppedHistoryOptions,

6471

ChannelTurnHistoryFinalizeOptions,

6572

ChannelTurnDispatcherOptions,

6673

ChannelTurnLogEvent,

@@ -152,6 +159,85 @@ function clearPendingHistoryAfterTurn(params?: ChannelTurnHistoryFinalizeOptions

152159

});

153160

}

154161162+

function historyMediaFromInboundFacts(

163+

media: readonly InboundMediaFacts[] | readonly HistoryMediaEntry[] | null | undefined,

164+

messageId: string,

165+

): HistoryMediaEntry[] {

166+

if (!Array.isArray(media)) {

167+

return [];

168+

}

169+

return media.map((entry) => ({

170+

path: entry.path,

171+

url: entry.url,

172+

contentType: entry.contentType,

173+

kind: entry.kind,

174+

messageId: entry.messageId ?? messageId,

175+

}));

176+

}

177+178+

function resolveDroppedHistorySender(input: NormalizedTurnInput, preflight: PreflightFacts) {

179+

return (

180+

preflight.message?.senderLabel ??

181+

preflight.message?.envelopeFrom ??

182+

(typeof input.raw === "object" &&

183+

input.raw &&

184+

"sender" in input.raw &&

185+

typeof (input.raw as { sender?: unknown }).sender === "string"

186+

? (input.raw as { sender: string }).sender

187+

: undefined) ??

188+

"unknown"

189+

);

190+

}

191+192+

function resolveDroppedHistoryBody(input: NormalizedTurnInput, preflight: PreflightFacts) {

193+

return (

194+

preflight.message?.bodyForAgent ??

195+

preflight.message?.body ??

196+

preflight.message?.rawBody ??

197+

input.textForAgent ??

198+

input.rawText

199+

);

200+

}

201+202+

export async function recordDroppedChannelTurnHistory(params: {

203+

input: NormalizedTurnInput;

204+

preflight: PreflightFacts;

205+

admission?: ChannelTurnAdmission;

206+

}): Promise<void> {

207+

const admission = params.admission ?? params.preflight.admission;

208+

if (admission?.kind !== "drop") {

209+

return;

210+

}

211+

const history = params.preflight.history;

212+

if (!history || history.limit <= 0 || !(history.recordOnDrop || admission.recordHistory)) {

213+

return;

214+

}

215+

const body = resolveDroppedHistoryBody(params.input, params.preflight);

216+

const entry =

217+

body.trim().length > 0

218+

? {

219+

sender: resolveDroppedHistorySender(params.input, params.preflight),

220+

body,

221+

timestamp: params.input.timestamp,

222+

messageId: params.input.id,

223+

}

224+

: null;

225+

const media = params.preflight.media;

226+

await recordPendingHistoryEntryWithMedia({

227+

historyMap: history.historyMap,

228+

historyKey: history.key,

229+

limit: history.limit,

230+

entry,

231+

mediaLimit: history.mediaLimit,

232+

messageId: params.input.id,

233+

shouldRecord: history.shouldRecord,

234+

media:

235+

typeof media === "function"

236+

? async () => historyMediaFromInboundFacts(await media(), params.input.id)

237+

: historyMediaFromInboundFacts(media, params.input.id),

238+

});

239+

}

240+155241

function resolveAssembledReplyPipeline(

156242

params: AssembledChannelTurn,

157243

): Pick<AssembledChannelTurn, "dispatcherOptions" | "replyOptions"> {

@@ -522,6 +608,11 @@ export async function runChannelTurn<

522608

preflightAdmission.kind !== "dispatch" &&

523609

preflightAdmission.kind !== "observeOnly"

524610

) {

611+

await recordDroppedChannelTurnHistory({

612+

input,

613+

preflight,

614+

admission: preflightAdmission,

615+

});

525616

emit({

526617

...params,

527618

event: {