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

推荐订阅源

V
V2EX
Y
Y Combinator Blog
博客园_首页
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
B
Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
WordPress大学
WordPress大学
L
LangChain Blog
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Help Net Security

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
docs: document embedded subscribe text streaming · opencl...
steipete · 2026-06-05 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

// Text-end repeat tests ensure repeated full snapshots do not duplicate block

2+

// replies or assistantTexts.

13

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

24

import {

35

createTextEndBlockReplyHarness,

@@ -21,6 +23,8 @@ describe("subscribeEmbeddedAgentSession", () => {

2123

expect(subscription.assistantTexts).toEqual(["Good morning!"]);

2224

});

2325

it("does not duplicate block chunks when text_end repeats full content", async () => {

26+

// Chunked deltas may already flush all visible text before text_end repeats

27+

// the same content; the snapshot must be ignored.

2428

const onBlockReply = vi.fn();

2529

const { emit } = createTextEndBlockReplyHarness({

2630

onBlockReply,

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

// Duplicate block reply tests cover repeated text_end and message_end events

2+

// from providers that replay assistant snapshots.

13

import type { AssistantMessage } from "openclaw/plugin-sdk/llm";

24

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

35

import {

@@ -85,6 +87,8 @@ describe("subscribeEmbeddedAgentSession", () => {

8587

expect(subscription.assistantTexts).toEqual(["Hello world"]);

8688

});

8789

it("populates assistantTexts for non-streaming models with chunking enabled", () => {

90+

// Non-streaming providers may only send message_end; assistantTexts still

91+

// needs the final visible reply even when block chunking is enabled.

8892

// Non-streaming models (e.g. zai/glm-4.7): no text_delta events; message_end

8993

// must still populate assistantTexts so providers can deliver a final reply.

9094

const { session, emit } = createStubSessionHarness();

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

// Text-end block reply tests cover streamed block delivery, message_end

2+

// de-duplication, and OpenAI Responses phase handling.

13

import type { AssistantMessage } from "openclaw/plugin-sdk/llm";

24

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

35

import {

@@ -24,6 +26,8 @@ function emitOpenAiResponsesTextEvent(params: {

2426

signaturePhase?: OpenAiResponsesTextEventPhase;

2527

partialPhase?: OpenAiResponsesTextEventPhase;

2628

}) {

29+

// Responses events carry item ids and phase signatures; tests preserve those

30+

// fields so commentary/final routing matches provider payloads.

2731

const { emit, ...eventParams } = params;

2832

emit(createOpenAiResponsesTextEvent(eventParams));

2933

}

@@ -80,6 +84,8 @@ async function emitSuppressedCommentary(params: {

8084

emit: TextEndBlockReplyHarness["emit"];

8185

text: string;

8286

}) {

87+

// Commentary can stream before final_answer; this helper proves suppressed

88+

// commentary does not count as a delivered block.

8389

params.emit({ type: "message_start", message: { role: "assistant" } });

8490

emitOpenAiResponsesTextDeltaAndEnd({

8591

emit: params.emit,

@@ -101,6 +107,7 @@ function expectSingleBlockReplyText(params: {

101107

}

102108
103109

function requireBlockReplyPayload(onBlockReply: OnBlockReplyMock): BlockReplyPayload {

110+

// Most cases expect exactly one user-visible block reply.

104111

const call = onBlockReply.mock.calls[0];

105112

if (!call) {

106113

throw new Error("expected first block reply call");

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

// Reasoning block reply tests cover message_end extraction of native reasoning

2+

// and tag-promoted thinking when reasoning output is enabled.

13

import type { AssistantMessage } from "openclaw/plugin-sdk/llm";

24

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

35

import {

@@ -9,6 +11,8 @@ import { subscribeEmbeddedAgentSession } from "./embedded-agent-subscribe.js";

911
1012

describe("subscribeEmbeddedAgentSession", () => {

1113

function createReasoningBlockReplyHarness(params: { thinkingLevel?: "off" | "medium" } = {}) {

14+

// message_end block replies let reasoning and final answer be emitted as

15+

// separate payloads without depending on streaming deltas.

1216

const { session, emit } = createStubSessionHarness();

1317

const onBlockReply = vi.fn();

1418

@@ -33,6 +37,8 @@ describe("subscribeEmbeddedAgentSession", () => {

3337

}

3438
3539

function expectReasoningAndAnswerCalls(onBlockReply: ReturnType<typeof vi.fn>) {

40+

// The expected contract is two user-visible payloads: reasoning first,

41+

// final answer second.

3642

expect(onBlockReply).toHaveBeenCalledTimes(2);

3743

expect(blockReplyTextAt(onBlockReply, 0)).toBe("Because it helps");

3844

expect(blockReplyTextAt(onBlockReply, 1)).toBe("Final answer");

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

// Final-tag enforcement tests cover suppression of leaked reasoning and safe

2+

// extraction of <final> content across streamed code/fence boundaries.

13

import type { AssistantMessage } from "openclaw/plugin-sdk/llm";

24

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

35

import {

@@ -13,6 +15,8 @@ type ReplyMock = ReturnType<typeof vi.fn>;

1315

type ReplyPayload = { text?: string };

1416
1517

function requireFirstReplyPayload(mock: ReplyMock): ReplyPayload {

18+

// Enforcement cases emit at most one visible reply before assertions inspect

19+

// whether the hidden prefix stayed suppressed.

1620

const call = mock.mock.calls[0];

1721

if (!call) {

1822

throw new Error("expected first reply call");

@@ -96,6 +100,8 @@ describe("subscribeEmbeddedAgentSession", () => {

96100

});

97101
98102

it("keeps final tag literals inside streamed fenced code while enforcement is on", () => {

103+

// Literal <final> tags inside code fences remain hidden until a real final

104+

// tag appears outside the fence.

99105

const { session, emit } = createStubSessionHarness();

100106
101107

const onAgentEvent = vi.fn();