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

推荐订阅源

L
LangChain Blog
Martin Fowler
Martin Fowler
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
博客园_首页
量子位
小众软件
小众软件
F
Full Disclosure
Vercel News
Vercel News
爱范儿
爱范儿
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
博客园 - 聂微东
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
WordPress大学
WordPress大学
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
L
Lohrmann on Cybersecurity
H
Hacker News: Front Page
Spread Privacy
Spread Privacy
AI
AI
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CERT Recently Published Vulnerability Notes
D
Docker
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recorded Future
Recorded Future
L
LINUX DO - 热门话题
Microsoft Azure Blog
Microsoft Azure Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Latest news
Latest news
W
WeLiveSecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 司徒正美
博客园 - 叶小钗
T
Threat Research - Cisco Blogs
P
Privacy International News Feed
O
OpenAI News
Help Net Security
Help Net Security
aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
博客园 - Franky

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: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
fix(ui): render persisted history text blocks (#93841) · openclaw/openclaw@cb84041
mushuiyu886 · 2026-06-23 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -580,14 +580,18 @@ function extractAssistantTextForSilentCheck(message: unknown): string | undefine

580580

return undefined;

581581

}

582582

const typed = block as { type?: unknown; text?: unknown };

583-

if (typed.type !== "text" || typeof typed.text !== "string") {

583+

if (!isAssistantTextContentType(typed.type) || typeof typed.text !== "string") {

584584

return undefined;

585585

}

586586

texts.push(typed.text);

587587

}

588588

return texts.length > 0 ? texts.join("\n") : undefined;

589589

}

590590
591+

function isAssistantTextContentType(type: unknown): boolean {

592+

return type === "text" || type === "input_text" || type === "output_text";

593+

}

594+
591595

function hasAssistantNonTextContent(message: unknown): boolean {

592596

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

593597

return false;

@@ -597,7 +601,10 @@ function hasAssistantNonTextContent(message: unknown): boolean {

597601

return false;

598602

}

599603

return content.some(

600-

(block) => block && typeof block === "object" && (block as { type?: unknown }).type !== "text",

604+

(block) =>

605+

block &&

606+

typeof block === "object" &&

607+

!isAssistantTextContentType((block as { type?: unknown }).type),

601608

);

602609

}

603610

@@ -619,7 +626,11 @@ function hasAssistantMixedToolVisibleText(message: unknown): boolean {

619626

if (isToolHistoryBlockType(entry.type)) {

620627

hasToolHistoryBlock = true;

621628

}

622-

if (entry.type === "text" && typeof entry.text === "string" && entry.text.trim()) {

629+

if (

630+

isAssistantTextContentType(entry.type) &&

631+

typeof entry.text === "string" &&

632+

entry.text.trim()

633+

) {

623634

hasText = true;

624635

}

625636

}

@@ -1644,7 +1655,7 @@ function projectEmptyAssistantErrorMessages(

16441655

}

16451656

const type = (block as { type?: unknown }).type;

16461657

return (

1647-

type !== "text" &&

1658+

!isAssistantTextContentType(type) &&

16481659

type !== "thinking" &&

16491660

type !== "reasoning" &&

16501661

type !== "redacted_thinking"

@@ -1665,7 +1676,7 @@ function projectEmptyAssistantErrorMessages(

16651676

continue;

16661677

}

16671678

const entry = block as { type?: unknown; text?: unknown };

1668-

if (entry.type === "text" && typeof entry.text === "string") {

1679+

if (isAssistantTextContentType(entry.type) && typeof entry.text === "string") {

16691680

visibleTexts.push(entry.text);

16701681

}

16711682

}

Original file line numberDiff line numberDiff line change

@@ -25,6 +25,39 @@ describe("stripEnvelopeFromMessage", () => {

2525

expect(result.content?.[0]?.text).toBe("hi");

2626

});

2727
28+

test("strips role-appropriate Responses text blocks", () => {

29+

const user = stripEnvelopeFromMessage({

30+

role: "user",

31+

content: [{ type: "input_text", text: "hello\n[message_id: abc123]" }],

32+

}) as { content?: Array<{ text?: string }> };

33+

const assistant = stripEnvelopeFromMessage({

34+

role: "assistant",

35+

content: [

36+

{

37+

type: "output_text",

38+

text: 'Conversation info (untrusted metadata):\n```json\n{"message_id":"123"}\n```\n\nAssistant body',

39+

},

40+

],

41+

}) as { content?: Array<{ text?: string }> };

42+
43+

expect(user.content?.[0]?.text).toBe("hello");

44+

expect(assistant.content?.[0]?.text).toBe("Assistant body");

45+

});

46+
47+

test("strips internal metadata from assistant input_text blocks", () => {

48+

const assistant = stripEnvelopeFromMessage({

49+

role: "assistant",

50+

content: [

51+

{

52+

type: "input_text",

53+

text: 'Conversation info (untrusted metadata):\n```json\n{"message_id":"123"}\n```\n\nAssistant body',

54+

},

55+

],

56+

}) as { content?: Array<{ text?: string }> };

57+
58+

expect(assistant.content?.[0]?.text).toBe("Assistant body");

59+

});

60+
2861

test("does not strip inline message_id text that is part of a line", () => {

2962

const input = {

3063

role: "user",

Original file line numberDiff line numberDiff line change

@@ -47,15 +47,20 @@ function extractMessageSenderLabel(entry: Record<string, unknown>): string | nul

4747

// inbound envelopes while assistant/tool content may carry internal metadata.

4848

function stripEnvelopeFromContentWithRole(

4949

content: unknown[],

50-

stripUserEnvelope: boolean,

50+

role: string,

5151

): { content: unknown[]; changed: boolean } {

52+

const stripUserEnvelope = role === "user";

5253

let changed = false;

5354

const next = content.map((item) => {

5455

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

5556

return item;

5657

}

5758

const entry = item as Record<string, unknown>;

58-

if (entry.type !== "text" || typeof entry.text !== "string") {

59+

const isRoleTextBlock =

60+

entry.type === "text" ||

61+

(role === "user" && entry.type === "input_text") ||

62+

(role === "assistant" && (entry.type === "input_text" || entry.type === "output_text"));

63+

if (!isRoleTextBlock || typeof entry.text !== "string") {

5964

return item;

6065

}

6166

const stripped = stripUserEnvelope

@@ -99,7 +104,7 @@ export function stripEnvelopeFromMessage(message: unknown): unknown {

99104

changed = true;

100105

}

101106

} else if (Array.isArray(entry.content)) {

102-

const updated = stripEnvelopeFromContentWithRole(entry.content, stripUserEnvelope);

107+

const updated = stripEnvelopeFromContentWithRole(entry.content, role);

103108

if (updated.changed) {

104109

next.content = updated.content;

105110

changed = true;

Original file line numberDiff line numberDiff line change

@@ -941,6 +941,43 @@ describe("projectRecentChatDisplayMessages", () => {

941941

]);

942942

});

943943
944+

it.each([

945+

["output_text", ""],

946+

["output_text", "NO_REPLY"],

947+

["input_text", ""],

948+

["input_text", "NO_REPLY"],

949+

])("projects hidden %s assistant errors %j as a generic safe failure", (type, text) => {

950+

const result = projectRecentChatDisplayMessages([

951+

{

952+

role: "assistant",

953+

content: [{ type, text }],

954+

stopReason: "error",

955+

errorMessage: "Connection error.",

956+

timestamp: 1,

957+

},

958+

]);

959+
960+

expect(result[0]?.content).toEqual([

961+

{ type: "text", text: "The agent run failed before producing a reply." },

962+

]);

963+

});

964+
965+

it("preserves visible output_text from a failed assistant turn", () => {

966+

const result = projectRecentChatDisplayMessages([

967+

{

968+

role: "assistant",

969+

content: [{ type: "output_text", text: "A partial reply before the run failed." }],

970+

stopReason: "error",

971+

errorMessage: "Connection error.",

972+

timestamp: 1,

973+

},

974+

]);

975+
976+

expect(result[0]?.content).toEqual([

977+

{ type: "output_text", text: "A partial reply before the run failed." },

978+

]);

979+

});

980+
944981

it("projects thinking-only assistant errors as a generic safe failure", () => {

945982

const result = projectRecentChatDisplayMessages([

946983

{

Original file line numberDiff line numberDiff line change

@@ -702,6 +702,36 @@ describe("gateway server chat", () => {

702702

expect(textValues).toEqual(["hello", "real reply", "real text field reply", "NO_REPLY"]);

703703

});

704704
705+

test("chat.history hides assistant control replies in Responses output blocks", async () => {

706+

const historyMessages = await loadChatHistoryWithMessages([

707+

{

708+

role: "assistant",

709+

content: [{ type: "output_text", text: "NO_REPLY" }],

710+

timestamp: 1,

711+

},

712+

{

713+

role: "assistant",

714+

content: [{ type: "output_text", text: "visible response" }],

715+

timestamp: 2,

716+

},

717+

{

718+

role: "assistant",

719+

content: [{ type: "input_text", text: "NO_REPLY" }],

720+

timestamp: 3,

721+

},

722+

{

723+

role: "assistant",

724+

content: [{ type: "input_text", text: "visible assistant input" }],

725+

timestamp: 4,

726+

},

727+

]);

728+
729+

expect(collectHistoryTextValues(historyMessages)).toEqual([

730+

"visible response",

731+

"visible assistant input",

732+

]);

733+

});

734+
705735

test("chat.history mirrors current-session message tool sends before NO_REPLY", async () => {

706736

const replyText = "Here, love. Eva, not Evo.";

707737

const historyMessages = await loadChatHistoryWithMessages([

Original file line numberDiff line numberDiff line change

@@ -138,6 +138,24 @@ describe("extractAssistantVisibleText", () => {

138138

).toBe("Legacy answer");

139139

});

140140
141+

it("extracts persisted Responses output_text blocks as assistant-visible text", () => {

142+

expect(

143+

extractAssistantVisibleText({

144+

role: "assistant",

145+

content: [{ type: "output_text", text: "Persisted assistant answer" }],

146+

}),

147+

).toBe("Persisted assistant answer");

148+

});

149+
150+

it("extracts persisted Responses assistant input_text blocks", () => {

151+

expect(

152+

extractAssistantVisibleText({

153+

role: "assistant",

154+

content: [{ type: "input_text", text: "Persisted assistant input" }],

155+

}),

156+

).toBe("Persisted assistant input");

157+

});

158+
141159

it("does not mix unphased legacy text into final_answer output", () => {

142160

expect(

143161

extractAssistantVisibleText({

Original file line numberDiff line numberDiff line change

@@ -23,6 +23,10 @@ export function extractFirstTextBlock(message: unknown): string | undefined {

2323
2424

export type AssistantPhase = "commentary" | "final_answer";

2525
26+

function isAssistantTextContentBlockType(value: unknown): boolean {

27+

return value === "text" || value === "input_text" || value === "output_text";

28+

}

29+
2630

/** Narrows unknown phase metadata to assistant text phases that affect visibility. */

2731

export function normalizeAssistantPhase(value: unknown): AssistantPhase | undefined {

2832

return value === "commentary" || value === "final_answer" ? value : undefined;

@@ -73,7 +77,7 @@ export function resolveAssistantMessagePhase(message: unknown): AssistantPhase |

7377

continue;

7478

}

7579

const record = block as { type?: unknown; textSignature?: unknown };

76-

if (record.type !== "text") {

80+

if (!isAssistantTextContentBlockType(record.type)) {

7781

continue;

7882

}

7983

const phase = parseAssistantTextSignature(record.textSignature)?.phase;

@@ -156,7 +160,7 @@ export function extractAssistantTextForPhase(

156160

return false;

157161

}

158162

const record = block as { type?: unknown; textSignature?: unknown };

159-

if (record.type !== "text") {

163+

if (!isAssistantTextContentBlockType(record.type)) {

160164

return false;

161165

}

162166

return Boolean(parseAssistantTextSignature(record.textSignature)?.phase);

@@ -173,7 +177,7 @@ export function extractAssistantTextForPhase(

173177

return null;

174178

}

175179

const record = block as { type?: unknown; text?: unknown; textSignature?: unknown };

176-

if (record.type !== "text" || typeof record.text !== "string") {

180+

if (!isAssistantTextContentBlockType(record.type) || typeof record.text !== "string") {

177181

return null;

178182

}

179183

const signature = parseAssistantTextSignature(record.textSignature);

Original file line numberDiff line numberDiff line change

@@ -44,6 +44,36 @@ describe("extractTextCached", () => {

4444

expect(extractTextCached(message)).toBe("Final user answer");

4545

});

4646
47+

it("extracts text from persisted Responses content blocks", () => {

48+

expect(

49+

extractText({

50+

role: "user",

51+

content: [{ type: "input_text", text: "Persisted user question" }],

52+

}),

53+

).toBe("Persisted user question");

54+

expect(

55+

extractText({

56+

role: "assistant",

57+

content: [{ type: "output_text", text: "Persisted assistant answer" }],

58+

}),

59+

).toBe("Persisted assistant answer");

60+

});

61+
62+

it("accepts assistant Responses input blocks but ignores user output blocks", () => {

63+

expect(

64+

extractText({

65+

role: "user",

66+

content: [{ type: "output_text", text: "Assistant-only block" }],

67+

}),

68+

).toBeNull();

69+

expect(

70+

extractText({

71+

role: "assistant",

72+

content: [{ type: "input_text", text: "User-only block" }],

73+

}),

74+

).toBe("User-only block");

75+

});

76+
4777

it("prefers final_answer assistant text over commentary text", () => {

4878

const message = {

4979

role: "assistant",

Original file line numberDiff line numberDiff line change

@@ -9,6 +9,14 @@ import { stripThinkingTags } from "../strip-thinking-tags.ts";

99

const textCache = new WeakMap<object, string | null>();

1010

const thinkingCache = new WeakMap<object, string | null>();

1111
12+

function isTextContentBlockType(value: unknown, role: string): boolean {

13+

return (

14+

value === "text" ||

15+

(role === "user" && value === "input_text") ||

16+

(role === "assistant" && (value === "input_text" || value === "output_text"))

17+

);

18+

}

19+
1220

function processMessageText(text: string, role: string): string {

1321

const shouldStripInboundMetadata = normalizeLowercaseStringOrEmpty(role) === "user";

1422

const withoutInternalContext = stripInternalRuntimeContext(text);

@@ -90,6 +98,7 @@ export function extractThinkingCached(message: unknown): string | null {

9098
9199

export function extractRawText(message: unknown): string | null {

92100

const m = message as Record<string, unknown>;

101+

const role = normalizeLowercaseStringOrEmpty(m.role);

93102

const content = m.content;

94103

if (typeof content === "string") {

95104

return content;

@@ -98,7 +107,7 @@ export function extractRawText(message: unknown): string | null {

98107

const parts = content

99108

.map((p) => {

100109

const item = p as Record<string, unknown>;

101-

if (item.type === "text" && typeof item.text === "string") {

110+

if (isTextContentBlockType(item.type, role) && typeof item.text === "string") {

102111

return item.text;

103112

}

104113

return null;

Original file line numberDiff line numberDiff line change

@@ -90,6 +90,41 @@ describe("message-normalizer", () => {

9090

});

9191

});

9292
93+

it("normalizes persisted Responses text blocks as renderable text", () => {

94+

const user = normalizeMessage({

95+

role: "user",

96+

content: [{ type: "input_text", text: "Persisted user question" }],

97+

});

98+

const assistant = normalizeMessage({

99+

role: "assistant",

100+

content: [{ type: "output_text", text: "Persisted assistant answer" }],

101+

});

102+
103+

expect(user.content).toEqual([

104+

{

105+

type: "text",

106+

text: "Persisted user question",

107+

name: undefined,

108+

args: undefined,

109+

},

110+

]);

111+

expect(assistant.content).toEqual([{ type: "text", text: "Persisted assistant answer" }]);

112+

});

113+
114+

it("accepts assistant Responses input blocks but rejects user output blocks", () => {

115+

const user = normalizeMessage({

116+

role: "user",

117+

content: [{ type: "output_text", text: "Assistant-only block" }],

118+

});

119+

const assistant = normalizeMessage({

120+

role: "assistant",

121+

content: [{ type: "input_text", text: "User-only block" }],

122+

});

123+
124+

expect(user.content).not.toContainEqual({ type: "text", text: "Assistant-only block" });

125+

expect(assistant.content).toContainEqual({ type: "text", text: "User-only block" });

126+

});

127+
93128

it("normalizes structured base64 audio content blocks as renderable attachments", () => {

94129

const result = normalizeMessage({

95130

role: "assistant",