docs: document embedded subscribe chunking · openclaw/openclaw@a5880a3
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Tool summary metadata tests cover canvas actions and shouldEmitToolResult |
| 2 | +// overrides in subscribed embedded sessions. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import { createSubscribedSessionHarness } from "./embedded-agent-subscribe.e2e-harness.js"; |
3 | 5 | |
4 | 6 | describe("subscribeEmbeddedAgentSession", () => { |
5 | 7 | it("includes canvas action metadata in tool summaries", async () => { |
| 8 | +// Canvas actions need their JSONL path in summaries so users can inspect the |
| 9 | +// generated artifact without verbose tool output. |
6 | 10 | const onToolResult = vi.fn(); |
7 | 11 | |
8 | 12 | const toolHarness = createSubscribedSessionHarness({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// AssistantTexts final-answer tests ensure reasoning-mode subscriptions keep |
| 2 | +// stored assistant text aligned to the final answer when block replies are off. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | createReasoningFinalAnswerMessage, |
@@ -29,6 +31,8 @@ describe("subscribeEmbeddedAgentSession", () => {
|
29 | 31 | expect(subscription.assistantTexts).toEqual(["Final answer"]); |
30 | 32 | }); |
31 | 33 | it("suppresses partial replies when reasoning is enabled and block replies are disabled", () => { |
| 34 | +// With reasoning enabled, streamed draft text stays private until the final |
| 35 | +// message_end answer is available. |
32 | 36 | const { session, emit } = createStubSessionHarness(); |
33 | 37 | |
34 | 38 | const onPartialReply = vi.fn(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Fenced block chunking tests ensure indented and longer Markdown fences remain |
| 2 | +// intact when paragraph block replies are split. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | createParagraphChunkedBlockReplyHarness, |
@@ -7,6 +9,8 @@ import {
|
7 | 9 | |
8 | 10 | describe("subscribeEmbeddedAgentSession", () => { |
9 | 11 | it("keeps indented fenced blocks intact", () => { |
| 12 | +// Indented fences are still code blocks for block-reply chunking and should |
| 13 | +// not be split into malformed fragments. |
10 | 14 | const onBlockReply = vi.fn(); |
11 | 15 | const { emit } = createParagraphChunkedBlockReplyHarness({ |
12 | 16 | onBlockReply, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Fenced block reopen tests cover safe Markdown chunking when code fences are |
| 2 | +// too long to fit in one block reply. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | createParagraphChunkedBlockReplyHarness, |
@@ -7,6 +9,8 @@ import {
|
7 | 9 | |
8 | 10 | describe("subscribeEmbeddedAgentSession", () => { |
9 | 11 | it("reopens fenced blocks when splitting inside them", () => { |
| 12 | +// Oversized code blocks are split with reopened fences so every emitted |
| 13 | +// chunk remains valid Markdown. |
10 | 14 | const onBlockReply = vi.fn(); |
11 | 15 | const { emit } = createParagraphChunkedBlockReplyHarness({ |
12 | 16 | onBlockReply, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Long fenced block and compaction retry tests cover Markdown-safe chunking and |
| 2 | +// subscription state reset around automatic compaction retries. |
1 | 3 | import type { AssistantMessage } from "openclaw/plugin-sdk/llm"; |
2 | 4 | import { describe, expect, it, vi } from "vitest"; |
3 | 5 | import { |
@@ -27,6 +29,8 @@ describe("subscribeEmbeddedAgentSession", () => {
|
27 | 29 | expectFencedChunks(onBlockReply.mock.calls, "```json"); |
28 | 30 | }); |
29 | 31 | it("waits for auto-compaction retry and clears buffered text", async () => { |
| 32 | +// A retrying compaction invalidates any assistant text buffered from the |
| 33 | +// failed attempt; waiters resolve only after the retry path reaches agent_end. |
30 | 34 | const listeners: SessionEventHandler[] = []; |
31 | 35 | const session = { |
32 | 36 | subscribe: (listener: SessionEventHandler) => { |
@@ -119,6 +123,8 @@ describe("subscribeEmbeddedAgentSession", () => {
|
119 | 123 | }); |
120 | 124 | |
121 | 125 | it("resets assistant usage to a zero snapshot after compaction without retry", () => { |
| 126 | +// When compaction ends the active assistant message is synthetic, so usage |
| 127 | +// should reset to a zero snapshot instead of carrying stale token totals. |
122 | 128 | const listeners: SessionEventHandler[] = []; |
123 | 129 | const session = { |
124 | 130 | messages: [ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。