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

推荐订阅源

博客园 - 聂微东
Y
Y Combinator Blog
WordPress大学
WordPress大学
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
小众软件
小众软件
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
GbyAI
GbyAI
I
InfoQ
The GitHub Blog
The GitHub Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
C
Check Point Blog
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
量子位
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - 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
chore(deadcode): dedupe internal event formatting · openc...
vincentkoc · 2026-06-21 · via Recent Commits to openclaw:main

@@ -36,6 +36,8 @@ type AgentTaskCompletionInternalEvent = {

3636

replyInstruction: string;

3737

};

383839+

type TaskCompletionPromptMode = "plain" | "protected";

40+3941

/** Internal event variants that can be rendered into agent prompt context. */

4042

export type AgentInternalEvent = AgentTaskCompletionInternalEvent;

4143

@@ -86,7 +88,10 @@ function formatGeneratedMediaDirectiveLines(event: AgentTaskCompletionInternalEv

8688

return ["Generated media:", ...mediaUrls.map((mediaUrl) => `MEDIA:${mediaUrl}`)];

8789

}

889089-

function formatTaskCompletionEvent(event: AgentTaskCompletionInternalEvent): string {

91+

function formatTaskCompletionEvent(

92+

event: AgentTaskCompletionInternalEvent,

93+

mode: TaskCompletionPromptMode,

94+

): string {

9095

const sessionKey = sanitizeSingleLineField(event.childSessionKey, "unknown");

9196

const sessionId = sanitizeSingleLineField(event.childSessionId ?? "unknown", "unknown");

9297

const announceType = sanitizeSingleLineField(event.announceType, "unknown");

@@ -95,8 +100,14 @@ function formatTaskCompletionEvent(event: AgentTaskCompletionInternalEvent): str

95100

const result = formatChildResultDataBlock(event.result);

96101

const attachmentLines = formatGeneratedAttachmentLines(event.attachments);

97102

const mediaDirectiveLines = formatGeneratedMediaDirectiveLines(event);

98-

const lines = [

99-

"[Internal task completion event]",

103+

const lines =

104+

mode === "protected"

105+

? ["[Internal task completion event]"]

106+

: [

107+

"A background task completed. Use this result to reply to the user in your normal assistant voice.",

108+

"",

109+

];

110+

lines.push(

100111

`source: ${event.source}`,

101112

`session_key: ${sessionKey}`,

102113

`session_id: ${sessionId}`,

@@ -105,7 +116,7 @@ function formatTaskCompletionEvent(event: AgentTaskCompletionInternalEvent): str

105116

`status: ${statusLabel}`,

106117

"",

107118

result,

108-

];

119+

);

109120

if (attachmentLines.length > 0) {

110121

lines.push("", ...attachmentLines);

111122

}

@@ -115,41 +126,11 @@ function formatTaskCompletionEvent(event: AgentTaskCompletionInternalEvent): str

115126

if (event.statsLine?.trim()) {

116127

lines.push("", sanitizeMultilineField(event.statsLine, ""));

117128

}

118-

lines.push("", "Action:", sanitizeMultilineField(event.replyInstruction, ""));

119-

return lines.join("\n");

120-

}

121-122-

function formatTaskCompletionEventForPlainPrompt(event: AgentTaskCompletionInternalEvent): string {

123-

const sessionKey = sanitizeSingleLineField(event.childSessionKey, "unknown");

124-

const sessionId = sanitizeSingleLineField(event.childSessionId ?? "unknown", "unknown");

125-

const announceType = sanitizeSingleLineField(event.announceType, "unknown");

126-

const taskLabel = sanitizeSingleLineField(event.taskLabel, "unnamed task");

127-

const statusLabel = sanitizeSingleLineField(event.statusLabel, event.status);

128-

const result = formatChildResultDataBlock(event.result);

129-

const attachmentLines = formatGeneratedAttachmentLines(event.attachments);

130-

const mediaDirectiveLines = formatGeneratedMediaDirectiveLines(event);

131-

const lines = [

132-

"A background task completed. Use this result to reply to the user in your normal assistant voice.",

129+

lines.push(

133130

"",

134-

`source: ${event.source}`,

135-

`session_key: ${sessionKey}`,

136-

`session_id: ${sessionId}`,

137-

`type: ${announceType}`,

138-

`task: ${taskLabel}`,

139-

`status: ${statusLabel}`,

140-

"",

141-

result,

142-

];

143-

if (attachmentLines.length > 0) {

144-

lines.push("", ...attachmentLines);

145-

}

146-

if (mediaDirectiveLines.length > 0) {

147-

lines.push("", ...mediaDirectiveLines);

148-

}

149-

if (event.statsLine?.trim()) {

150-

lines.push("", sanitizeMultilineField(event.statsLine, ""));

151-

}

152-

lines.push("", "Instruction:", sanitizeMultilineField(event.replyInstruction, ""));

131+

mode === "protected" ? "Action:" : "Instruction:",

132+

sanitizeMultilineField(event.replyInstruction, ""),

133+

);

153134

return lines.join("\n");

154135

}

155136

@@ -161,7 +142,7 @@ export function formatAgentInternalEventsForPrompt(events?: AgentInternalEvent[]

161142

const blocks = events

162143

.map((event) => {

163144

if (event.type === "task_completion") {

164-

return formatTaskCompletionEvent(event);

145+

return formatTaskCompletionEvent(event, "protected");

165146

}

166147

return "";

167148

})

@@ -187,7 +168,7 @@ export function formatAgentInternalEventsForPlainPrompt(events?: AgentInternalEv

187168

return events

188169

.map((event) => {

189170

if (event.type === "task_completion") {

190-

return formatTaskCompletionEventForPlainPrompt(event);

171+

return formatTaskCompletionEvent(event, "plain");

191172

}

192173

return "";

193174

})