fix(auto-reply): tighten block streaming defaults
This commit is contained in:
@@ -470,20 +470,26 @@ export async function getReplyFromConfig(
|
||||
(agentCfg?.elevatedDefault as ElevatedLevel | undefined) ??
|
||||
"on")
|
||||
: "off";
|
||||
const providerKey = sessionCtx.Provider?.trim().toLowerCase();
|
||||
const explicitBlockStreamingEnable = opts?.disableBlockStreaming === false;
|
||||
const resolvedBlockStreaming =
|
||||
opts?.disableBlockStreaming === true
|
||||
? "off"
|
||||
: opts?.disableBlockStreaming === false
|
||||
? "on"
|
||||
: agentCfg?.blockStreamingDefault === "off"
|
||||
? "off"
|
||||
: "on";
|
||||
: agentCfg?.blockStreamingDefault === "on"
|
||||
? "on"
|
||||
: "off";
|
||||
const resolvedBlockStreamingBreak: "text_end" | "message_end" =
|
||||
agentCfg?.blockStreamingBreak === "message_end"
|
||||
? "message_end"
|
||||
: "text_end";
|
||||
const allowBlockStreaming =
|
||||
providerKey === "telegram" || explicitBlockStreamingEnable;
|
||||
const blockStreamingEnabled =
|
||||
resolvedBlockStreaming === "on" && opts?.disableBlockStreaming !== true;
|
||||
resolvedBlockStreaming === "on" &&
|
||||
opts?.disableBlockStreaming !== true &&
|
||||
allowBlockStreaming;
|
||||
const blockReplyChunking = blockStreamingEnabled
|
||||
? resolveBlockStreamingChunking(
|
||||
cfg,
|
||||
|
||||
@@ -5,6 +5,13 @@ import { resolveTextChunkLimit, type TextChunkProvider } from "../chunk.js";
|
||||
const DEFAULT_BLOCK_STREAM_MIN = 800;
|
||||
const DEFAULT_BLOCK_STREAM_MAX = 1200;
|
||||
const DEFAULT_BLOCK_STREAM_COALESCE_IDLE_MS = 1000;
|
||||
const PROVIDER_COALESCE_DEFAULTS: Partial<
|
||||
Record<TextChunkProvider, { minChars: number; idleMs: number }>
|
||||
> = {
|
||||
signal: { minChars: 1500, idleMs: 1000 },
|
||||
slack: { minChars: 1500, idleMs: 1000 },
|
||||
discord: { minChars: 1500, idleMs: 1000 },
|
||||
};
|
||||
|
||||
const BLOCK_CHUNK_PROVIDERS = new Set<TextChunkProvider>([
|
||||
"whatsapp",
|
||||
@@ -77,6 +84,9 @@ export function resolveBlockStreamingCoalescing(
|
||||
const providerKey = normalizeChunkProvider(provider);
|
||||
const textLimit = resolveTextChunkLimit(cfg, providerKey, accountId);
|
||||
const normalizedAccountId = normalizeAccountId(accountId);
|
||||
const providerDefaults = providerKey
|
||||
? PROVIDER_COALESCE_DEFAULTS[providerKey]
|
||||
: undefined;
|
||||
const providerCfg = (() => {
|
||||
if (!cfg || !providerKey) return undefined;
|
||||
if (providerKey === "whatsapp") {
|
||||
@@ -125,7 +135,10 @@ export function resolveBlockStreamingCoalescing(
|
||||
const minRequested = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
coalesceCfg?.minChars ?? chunking?.minChars ?? DEFAULT_BLOCK_STREAM_MIN,
|
||||
coalesceCfg?.minChars ??
|
||||
providerDefaults?.minChars ??
|
||||
chunking?.minChars ??
|
||||
DEFAULT_BLOCK_STREAM_MIN,
|
||||
),
|
||||
);
|
||||
const maxRequested = Math.max(
|
||||
@@ -136,7 +149,11 @@ export function resolveBlockStreamingCoalescing(
|
||||
const minChars = Math.min(minRequested, maxChars);
|
||||
const idleMs = Math.max(
|
||||
0,
|
||||
Math.floor(coalesceCfg?.idleMs ?? DEFAULT_BLOCK_STREAM_COALESCE_IDLE_MS),
|
||||
Math.floor(
|
||||
coalesceCfg?.idleMs ??
|
||||
providerDefaults?.idleMs ??
|
||||
DEFAULT_BLOCK_STREAM_COALESCE_IDLE_MS,
|
||||
),
|
||||
);
|
||||
const preference = chunking?.breakPreference ?? "paragraph";
|
||||
const joiner =
|
||||
|
||||
Reference in New Issue
Block a user