Refactor sequential thinking tool to remove raw LLM message entries

- Removed the creation and handling of raw LLM message entries in both start and finish functions.
- Updated message entry updates to only include reasoning messages, simplifying the logic and improving clarity.
This commit is contained in:
dal 2025-08-22 16:50:55 -06:00
parent 50c9575d6f
commit dcf1687b50
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
2 changed files with 4 additions and 26 deletions

View File

@ -1,10 +1,7 @@
import { updateMessageEntries } from '@buster/database';
import type { ToolCallOptions } from 'ai';
import { normalizeEscapedText } from '../../../utils/streaming/escape-normalizer';
import {
createSequentialThinkingRawLlmMessageEntry,
createSequentialThinkingReasoningMessage,
} from './helpers/sequential-thinking-tool-transform-helper';
import { createSequentialThinkingReasoningMessage } from './helpers/sequential-thinking-tool-transform-helper';
import type {
SequentialThinkingContext,
SequentialThinkingInput,
@ -31,22 +28,14 @@ export function createSequentialThinkingFinish(
'completed' // Mark as completed when finish is called
);
// Create final raw LLM message entry
const rawLlmMessage = createSequentialThinkingRawLlmMessageEntry(
sequentialThinkingState,
options.toolCallId
);
try {
if (context.messageId) {
const reasoningMessages = reasoningEntry ? [reasoningEntry] : [];
const rawLlmMessages = rawLlmMessage ? [rawLlmMessage] : [];
if (reasoningMessages.length > 0 || rawLlmMessages.length > 0) {
if (reasoningMessages.length > 0) {
await updateMessageEntries({
messageId: context.messageId,
reasoningMessages,
rawLlmMessages,
});
console.info('[sequential-thinking] Completed sequential thinking:', {

View File

@ -1,9 +1,6 @@
import { updateMessageEntries } from '@buster/database';
import type { ToolCallOptions } from 'ai';
import {
createSequentialThinkingRawLlmMessageEntry,
createSequentialThinkingReasoningMessage,
} from './helpers/sequential-thinking-tool-transform-helper';
import { createSequentialThinkingReasoningMessage } from './helpers/sequential-thinking-tool-transform-helper';
import type {
SequentialThinkingContext,
SequentialThinkingState,
@ -29,22 +26,14 @@ export function createSequentialThinkingStart(
options.toolCallId
);
// Create initial raw LLM message entry
const rawLlmMessage = createSequentialThinkingRawLlmMessageEntry(
sequentialThinkingState,
options.toolCallId
);
try {
if (context.messageId) {
const reasoningMessages = reasoningEntry ? [reasoningEntry] : [];
const rawLlmMessages = rawLlmMessage ? [rawLlmMessage] : [];
if (reasoningMessages.length > 0 || rawLlmMessages.length > 0) {
if (reasoningMessages.length > 0) {
await updateMessageEntries({
messageId: context.messageId,
reasoningMessages,
rawLlmMessages,
});
console.info('[sequential-thinking] Started sequential thinking:', {