fix: keep telegram streamMode draft-only (#619) (thanks @rubyrunsstuff)

This commit is contained in:
Peter Steinberger
2026-01-10 01:14:40 +01:00
parent b4fbf2fe0d
commit 1fd7a6e310
5 changed files with 48 additions and 22 deletions

View File

@@ -273,4 +273,45 @@ describe("block streaming", () => {
expect(sawAbort).toBe(true);
});
});
it("does not enable block streaming for telegram streamMode block", async () => {
await withTempHome(async (home) => {
const onBlockReply = vi.fn().mockResolvedValue(undefined);
const impl = async () => ({
payloads: [{ text: "final" }],
meta: {
durationMs: 5,
agentMeta: { sessionId: "s", provider: "p", model: "m" },
},
});
piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(impl);
const res = await getReplyFromConfig(
{
Body: "ping",
From: "+1004",
To: "+2000",
MessageSid: "msg-126",
Provider: "telegram",
},
{
onBlockReply,
},
{
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: path.join(home, "clawd"),
},
},
telegram: { allowFrom: ["*"], streamMode: "block" },
session: { store: path.join(home, "sessions.json") },
},
);
expect(res?.text).toBe("final");
expect(onBlockReply).not.toHaveBeenCalled();
});
});
});

View File

@@ -58,9 +58,7 @@ export function resolveBlockStreamingChunking(
Math.floor(chunkCfg?.maxChars ?? DEFAULT_BLOCK_STREAM_MAX),
);
const maxChars = Math.max(1, Math.min(maxRequested, textLimit));
const telegramBlockStreaming =
providerKey === "telegram" && cfg?.telegram?.streamMode === "block";
const minFallback = telegramBlockStreaming ? 1 : DEFAULT_BLOCK_STREAM_MIN;
const minFallback = DEFAULT_BLOCK_STREAM_MIN;
const minRequested = Math.max(
1,
Math.floor(chunkCfg?.minChars ?? minFallback),
@@ -135,13 +133,6 @@ export function resolveBlockStreamingCoalescing(
})();
const coalesceCfg =
providerCfg ?? cfg?.agents?.defaults?.blockStreamingCoalesce;
if (
providerKey === "telegram" &&
cfg?.telegram?.streamMode === "block" &&
!coalesceCfg
) {
return undefined;
}
const minRequested = Math.max(
1,
Math.floor(