Skip to content

Commit 6778aad

Browse files
committed
fix(auto-reply/chunk): honor webchat textChunkLimit/chunkMode config
The webchat channel was explicitly bypassed in resolveTextChunkLimit and resolveChunkMode, hardcoding the 4000-char default and ignoring any channels.webchat.textChunkLimit override in user config. This made long WebChat assistant responses get cut at ~4000 chars with no escape hatch. Drop the INTERNAL_MESSAGE_CHANNEL special-case so webchat goes through the same provider config lookup as every other channel. The 4000-char fallback still applies when no override is configured, preserving existing behavior for users who do not set channels.webchat.textChunkLimit. Closes #83658
1 parent 3631af8 commit 6778aad

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/auto-reply/chunk.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,26 @@ describe("resolveTextChunkLimit", () => {
330330
options: undefined,
331331
expected: 4000,
332332
},
333+
{
334+
name: "honors webchat textChunkLimit override from config",
335+
cfg: {
336+
channels: {
337+
webchat: { textChunkLimit: 16000 },
338+
},
339+
},
340+
provider: "webchat" as const,
341+
accountId: undefined,
342+
options: undefined,
343+
expected: 16000,
344+
},
345+
{
346+
name: "falls back to default when webchat has no override",
347+
cfg: { channels: {} },
348+
provider: "webchat" as const,
349+
accountId: undefined,
350+
options: undefined,
351+
expected: 4000,
352+
},
333353
] as const)("$name", ({ cfg, provider, accountId, options, expected }) => {
334354
expect(resolveTextChunkLimit(cfg as never, provider, accountId, options)).toBe(expected);
335355
});
@@ -584,6 +604,12 @@ describe("resolveChunkMode", () => {
584604
{ cfg: providerCfg, provider: "discord", accountId: undefined, expected: "length" },
585605
{ cfg: accountCfg, provider: "slack", accountId: "primary", expected: "newline" },
586606
{ cfg: accountCfg, provider: "slack", accountId: "other", expected: "length" },
607+
{
608+
cfg: { channels: { webchat: { chunkMode: "newline" as const } } },
609+
provider: "webchat",
610+
accountId: undefined,
611+
expected: "newline",
612+
},
587613
] as const)(
588614
"resolves default/provider/account/internal chunk mode for $provider $accountId",
589615
({ cfg, provider, accountId, expected }) => {

src/auto-reply/chunk.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { resolveChannelStreamingChunkMode } from "../plugin-sdk/channel-streamin
99
import { resolveAccountEntry } from "../routing/account-lookup.js";
1010
import { normalizeAccountId } from "../routing/session-key.js";
1111
import { chunkTextByBreakResolver } from "../shared/text-chunking.js";
12-
import { INTERNAL_MESSAGE_CHANNEL } from "../utils/message-channel.js";
1312

1413
export type TextChunkProvider = ChannelId;
1514

@@ -64,7 +63,7 @@ export function resolveTextChunkLimit(
6463
? opts.fallbackLimit
6564
: DEFAULT_CHUNK_LIMIT;
6665
const providerOverride = (() => {
67-
if (!provider || provider === INTERNAL_MESSAGE_CHANNEL) {
66+
if (!provider) {
6867
return undefined;
6968
}
7069
const channelsConfig = cfg?.channels as Record<string, unknown> | undefined;
@@ -102,7 +101,7 @@ export function resolveChunkMode(
102101
provider?: TextChunkProvider,
103102
accountId?: string | null,
104103
): ChunkMode {
105-
if (!provider || provider === INTERNAL_MESSAGE_CHANNEL) {
104+
if (!provider) {
106105
return DEFAULT_CHUNK_MODE;
107106
}
108107
const channelsConfig = cfg?.channels as Record<string, unknown> | undefined;

0 commit comments

Comments
 (0)