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

推荐订阅源

D
DataBreaches.Net
IT之家
IT之家
博客园_首页
博客园 - 【当耐特】
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
GbyAI
GbyAI
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
H
Help Net Security
T
Tailwind CSS Blog
B
Blog RSS Feed
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
The Cloudflare 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(agents): guard delivery-evidence attachment recursion...
Pick-cat · 2026-06-27 · via Recent Commits to openclaw:main

File tree

  • src/agents/embedded-agent-runner

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,46 @@

1+

import { describe, expect, it } from "vitest";

2+

import { collectDeliveredMediaUrls } from "./delivery-evidence.js";

3+
4+

describe("collectDeliveredMediaUrls attachment recursion", () => {

5+

it("collects media URLs across nested attachments", () => {

6+

const urls = collectDeliveredMediaUrls({

7+

payloads: [

8+

{

9+

url: "https://example.com/root.png",

10+

attachments: [

11+

{ mediaUrl: "https://example.com/child.png" },

12+

{ attachments: [{ filePath: "/tmp/grandchild.jpg" }] },

13+

],

14+

},

15+

],

16+

});

17+

expect(urls.toSorted()).toEqual([

18+

"/tmp/grandchild.jpg",

19+

"https://example.com/child.png",

20+

"https://example.com/root.png",

21+

]);

22+

});

23+
24+

it("does not overflow the stack on a self-referential attachments cycle", () => {

25+

// Payloads arrive as in-process `unknown` objects; a malformed self-referential

26+

// attachments chain previously recursed until the stack overflowed.

27+

const cyclic: Record<string, unknown> = { url: "https://example.com/loop.png" };

28+

cyclic.attachments = [cyclic];

29+
30+

let urls: string[] = [];

31+

expect(() => {

32+

urls = collectDeliveredMediaUrls({ payloads: [cyclic] });

33+

}).not.toThrow();

34+

expect(urls).toEqual(["https://example.com/loop.png"]);

35+

});

36+
37+

it("does not overflow on a mutual attachments cycle", () => {

38+

const a: Record<string, unknown> = { mediaUrl: "https://example.com/a.png" };

39+

const b: Record<string, unknown> = { mediaUrl: "https://example.com/b.png" };

40+

a.attachments = [b];

41+

b.attachments = [a];

42+
43+

const urls = collectDeliveredMediaUrls({ payloads: [a] });

44+

expect(urls.toSorted()).toEqual(["https://example.com/a.png", "https://example.com/b.png"]);

45+

});

46+

});

Original file line numberDiff line numberDiff line change

@@ -80,7 +80,19 @@ function collectStringValues(value: unknown, output: Set<string>) {

8080

}

8181

}

8282
83-

function collectMediaUrlsFromRecord(record: Record<string, unknown>, output: Set<string>) {

83+

function collectMediaUrlsFromRecord(

84+

record: Record<string, unknown>,

85+

output: Set<string>,

86+

// Payloads arrive as in-process `unknown` objects, so a malformed

87+

// self-referential `attachments` chain would recurse until the stack

88+

// overflows. Track visited records to bound the descent, matching

89+

// redactStringsDeep in embedded-agent-subscribe.tools.ts.

90+

seen = new WeakSet<object>(),

91+

) {

92+

if (seen.has(record)) {

93+

return;

94+

}

95+

seen.add(record);

8496

collectStringValues(record.mediaUrl, output);

8597

collectStringValues(record.mediaUrls, output);

8698

collectStringValues(record.path, output);

@@ -90,7 +102,7 @@ function collectMediaUrlsFromRecord(record: Record<string, unknown>, output: Set

90102

if (Array.isArray(attachments)) {

91103

for (const attachment of attachments) {

92104

if (attachment && typeof attachment === "object" && !Array.isArray(attachment)) {

93-

collectMediaUrlsFromRecord(attachment as Record<string, unknown>, output);

105+

collectMediaUrlsFromRecord(attachment as Record<string, unknown>, output, seen);

94106

}

95107

}

96108

}