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

推荐订阅源

云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
V
Visual Studio Blog
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MongoDB | Blog
MongoDB | Blog
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
L
LangChain Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
博客园 - 司徒正美

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
test(gateway): keep trajectory export live proof correlat...
vincentkoc · 2026-06-14 · via Recent Commits to openclaw:main

@@ -172,16 +172,37 @@ function formatTextPreview(texts: string[], maxChars = 800): string {

172172

return combined.length > maxChars ? `${combined.slice(0, maxChars)}...` : combined;

173173

}

174174175+

function extractAssistantTexts(messages: unknown[]): string[] {

176+

const texts: string[] = [];

177+

for (const entry of messages) {

178+

if (!entry || typeof entry !== "object") {

179+

continue;

180+

}

181+

if ((entry as { role?: unknown }).role !== "assistant") {

182+

continue;

183+

}

184+

const text = extractVisibleMessageText(entry);

185+

if (typeof text === "string" && text.trim().length > 0) {

186+

texts.push(text);

187+

}

188+

}

189+

return texts;

190+

}

191+175192

async function waitForTrajectoryExportInstructionText(params: {

193+

client: GatewayClient;

176194

events: EventFrame[];

195+

eventStartIndex: number;

177196

expectedText: string;

178197

runId: string;

198+

sessionKey: string;

179199

timeoutMs: number;

180200

}): Promise<string> {

181201

const deadline = Date.now() + params.timeoutMs;

182202

let finalTexts: string[] = [];

183203

while (Date.now() < deadline) {

184-

finalTexts = params.events

204+

const newEvents = params.events.slice(params.eventStartIndex);

205+

finalTexts = newEvents

185206

.map((event) => extractChatFinalText(event, params.runId))

186207

.filter((text): text is string => typeof text === "string" && text.trim().length > 0);

187208

const matchedText = finalTexts.find((text) => text.includes(params.expectedText));

@@ -192,9 +213,23 @@ async function waitForTrajectoryExportInstructionText(params: {

192213

setTimeout(resolve, 500);

193214

});

194215

}

216+

let assistantTexts: string[];

217+

try {

218+

const history = (await params.client.request(

219+

"chat.history",

220+

{

221+

sessionKey: params.sessionKey,

222+

limit: 24,

223+

},

224+

{ timeoutMs: 10_000 },

225+

)) as { messages?: unknown[] };

226+

assistantTexts = extractAssistantTexts(history.messages ?? []);

227+

} catch {

228+

assistantTexts = [];

229+

}

195230

throw new Error(

196231

`timed out waiting for trajectory export instruction text for ${params.runId}; ` +

197-

`events=${params.events.length}; finalTexts=${formatTextPreview(finalTexts)}`,

232+

`events=${params.events.length}; finalTexts=${formatTextPreview(finalTexts)}; assistantTexts=${formatTextPreview(assistantTexts)}`,

198233

);

199234

}

200235

@@ -210,6 +245,10 @@ function extractChatFinalText(event: EventFrame, runId: string): string | undefi

210245

if (record.runId !== runId || record.state !== "final") {

211246

return undefined;

212247

}

248+

return extractChatFinalRecordText(record);

249+

}

250+251+

function extractChatFinalRecordText(record: Record<string, unknown>): string | undefined {

213252

const message = record.message;

214253

if (!message || typeof message !== "object") {

215254

return undefined;

@@ -395,6 +434,7 @@ describeLive("gateway live trajectory export", () => {

395434

const bundleDir = path.join(workspaceDir, ".openclaw", "trajectory-exports", "bundle");

396435

const beforeExport = new Set(await listDirectoryNames(tempDir));

397436

const exportRunId = `chat-export-${randomUUID()}`;

437+

const exportEventStartIndex = gatewayEvents.length;

398438

logLiveStep("export:start", { bundleDir, exportRunId });

399439

const exportResponse = (await client.request(

400440

"chat.send",

@@ -415,9 +455,12 @@ describeLive("gateway live trajectory export", () => {

415455

typeof exportResponse?.message === "object"

416456

? extractVisibleMessageText(exportResponse.message)

417457

: await waitForTrajectoryExportInstructionText({

458+

client,

418459

events: gatewayEvents,

460+

eventStartIndex: exportEventStartIndex,

419461

expectedText: "Trajectory exports can include",

420462

runId: exportRunId,

463+

sessionKey,

421464

timeoutMs: 60_000,

422465

});

423466

expect(finalText).toContain("Trajectory exports can include");