mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
refactor(agents): remove redundant observed reasoning state
This commit is contained in:
@@ -166,11 +166,6 @@ export function handleMessageUpdate(
|
||||
}
|
||||
|
||||
const streamedReasoning = extractThinkingFromTaggedStream(ctx.state.deltaBuffer);
|
||||
if (streamedReasoning) {
|
||||
// Keep the latest observed reasoning so reasoning=on can still emit a separate
|
||||
// reasoning block when providers omit thinking blocks in final message content.
|
||||
ctx.state.lastObservedReasoning = streamedReasoning;
|
||||
}
|
||||
if (ctx.state.streamReasoning) {
|
||||
// Handle partial <think> tags: stream whatever reasoning is visible so far.
|
||||
ctx.emitReasoningStream(streamedReasoning);
|
||||
@@ -280,12 +275,10 @@ export function handleMessageEnd(
|
||||
text: ctx.stripBlockTags(rawText, { thinking: false, final: false }),
|
||||
messagingToolSentTexts: ctx.state.messagingToolSentTexts,
|
||||
});
|
||||
const streamedReasoningFallback =
|
||||
ctx.state.lastObservedReasoning || extractThinkingFromTaggedStream(ctx.state.deltaBuffer);
|
||||
const rawThinking =
|
||||
ctx.state.includeReasoning || ctx.state.streamReasoning
|
||||
? extractAssistantThinking(assistantMessage) ||
|
||||
streamedReasoningFallback ||
|
||||
extractThinkingFromTaggedStream(ctx.state.deltaBuffer) ||
|
||||
extractThinkingFromTaggedText(rawText)
|
||||
: "";
|
||||
const formattedReasoning = rawThinking ? formatReasoningMessage(rawThinking) : "";
|
||||
|
||||
@@ -51,7 +51,6 @@ export type EmbeddedPiSubscribeState = {
|
||||
lastStreamedAssistantCleaned?: string;
|
||||
emittedAssistantUpdate: boolean;
|
||||
lastStreamedReasoning?: string;
|
||||
lastObservedReasoning?: string;
|
||||
lastBlockReplyText?: string;
|
||||
reasoningStreamOpen: boolean;
|
||||
assistantMessageIndex: number;
|
||||
|
||||
@@ -54,7 +54,6 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
|
||||
lastStreamedAssistantCleaned: undefined,
|
||||
emittedAssistantUpdate: false,
|
||||
lastStreamedReasoning: undefined,
|
||||
lastObservedReasoning: undefined,
|
||||
lastBlockReplyText: undefined,
|
||||
reasoningStreamOpen: false,
|
||||
assistantMessageIndex: 0,
|
||||
@@ -118,7 +117,6 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
|
||||
state.emittedAssistantUpdate = false;
|
||||
state.lastBlockReplyText = undefined;
|
||||
state.lastStreamedReasoning = undefined;
|
||||
state.lastObservedReasoning = undefined;
|
||||
state.lastReasoningSent = undefined;
|
||||
state.reasoningStreamOpen = false;
|
||||
state.suppressBlockChunks = false;
|
||||
|
||||
Reference in New Issue
Block a user