File size: 2,260 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../../config/config.js";
import {
resolveBlockStreamingChunking,
resolveEffectiveBlockStreamingConfig,
} from "./block-streaming.js";
describe("resolveEffectiveBlockStreamingConfig", () => {
it("applies ACP-style overrides while preserving chunk/coalescer bounds", () => {
const cfg = {} as OpenClawConfig;
const baseChunking = resolveBlockStreamingChunking(cfg, "discord");
const resolved = resolveEffectiveBlockStreamingConfig({
cfg,
provider: "discord",
maxChunkChars: 64,
coalesceIdleMs: 25,
});
expect(baseChunking.maxChars).toBeGreaterThanOrEqual(64);
expect(resolved.chunking.maxChars).toBe(64);
expect(resolved.chunking.minChars).toBeLessThanOrEqual(resolved.chunking.maxChars);
expect(resolved.coalescing.maxChars).toBeLessThanOrEqual(resolved.chunking.maxChars);
expect(resolved.coalescing.minChars).toBeLessThanOrEqual(resolved.coalescing.maxChars);
expect(resolved.coalescing.idleMs).toBe(25);
});
it("reuses caller-provided chunking for shared main/subagent/ACP config resolution", () => {
const resolved = resolveEffectiveBlockStreamingConfig({
cfg: undefined,
chunking: {
minChars: 10,
maxChars: 20,
breakPreference: "paragraph",
},
coalesceIdleMs: 0,
});
expect(resolved.chunking).toEqual({
minChars: 10,
maxChars: 20,
breakPreference: "paragraph",
});
expect(resolved.coalescing.maxChars).toBe(20);
expect(resolved.coalescing.idleMs).toBe(0);
});
it("allows ACP maxChunkChars overrides above base defaults up to provider text limits", () => {
const cfg = {
channels: {
discord: {
textChunkLimit: 4096,
},
},
} as OpenClawConfig;
const baseChunking = resolveBlockStreamingChunking(cfg, "discord");
expect(baseChunking.maxChars).toBeLessThan(1800);
const resolved = resolveEffectiveBlockStreamingConfig({
cfg,
provider: "discord",
maxChunkChars: 1800,
});
expect(resolved.chunking.maxChars).toBe(1800);
expect(resolved.chunking.minChars).toBeLessThanOrEqual(resolved.chunking.maxChars);
});
});
|