mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 01:10:21 +00:00
fix(telegram): gate reasoning previews to stream sessions (#61266)
This commit is contained in:
@@ -539,6 +539,25 @@ describe("dispatchTelegramMessage draft streaming", () => {
|
||||
expect(loadSessionStore).toHaveBeenCalledWith("/tmp/sessions.json", { skipCache: true });
|
||||
});
|
||||
|
||||
it("does not expose reasoning preview callbacks unless session reasoning is stream", async () => {
|
||||
let seenReasoningCallback: unknown;
|
||||
const answerDraftStream = createDraftStream(999);
|
||||
createTelegramDraftStream.mockImplementationOnce(() => answerDraftStream);
|
||||
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => {
|
||||
seenReasoningCallback = replyOptions?.onReasoningStream;
|
||||
await replyOptions?.onPartialReply?.({
|
||||
text: "<think>internal chain of thought</think>Visible answer",
|
||||
});
|
||||
return { queuedFinal: false };
|
||||
});
|
||||
|
||||
await dispatchWithContext({ context: createContext(), streamMode: "partial" });
|
||||
|
||||
expect(seenReasoningCallback).toBeUndefined();
|
||||
expect(createTelegramDraftStream).toHaveBeenCalledTimes(1);
|
||||
expect(answerDraftStream.update).toHaveBeenCalledWith("Visible answer");
|
||||
});
|
||||
|
||||
it("does not overwrite finalized preview when additional final payloads are sent", async () => {
|
||||
const draftStream = createDraftStream(999);
|
||||
createTelegramDraftStream.mockReturnValue(draftStream);
|
||||
|
||||
@@ -213,7 +213,7 @@ export const dispatchTelegramMessage = async ({
|
||||
const previewStreamingEnabled = streamMode !== "off";
|
||||
const canStreamAnswerDraft =
|
||||
previewStreamingEnabled && !accountBlockStreamingEnabled && !forceBlockStreamingForReasoning;
|
||||
const canStreamReasoningDraft = canStreamAnswerDraft || streamReasoningDraft;
|
||||
const canStreamReasoningDraft = streamReasoningDraft;
|
||||
const draftReplyToMessageId =
|
||||
replyToMode !== "off" && typeof msg.message_id === "number" ? msg.message_id : undefined;
|
||||
const draftMinInitialChars = DRAFT_MIN_INITIAL_CHARS;
|
||||
|
||||
Reference in New Issue
Block a user