mirror of https://github.com/buster-so/buster.git
sequential thinking is complete field
This commit is contained in:
parent
2e11ee999a
commit
caf40c492e
|
@ -13,7 +13,7 @@ import type { SequentialThinkingState } from '../sequential-thinking-tool';
|
|||
export function createSequentialThinkingReasoningMessage(
|
||||
sequentialThinkingState: SequentialThinkingState,
|
||||
toolCallId?: string,
|
||||
status: ChatMessageReasoning_status = 'loading'
|
||||
overrideStatus?: ChatMessageReasoning_status
|
||||
): ChatMessageReasoningMessage_Text | null {
|
||||
// Use entry_id from state or fallback to provided toolCallId
|
||||
const id = sequentialThinkingState.toolCallId || toolCallId;
|
||||
|
@ -22,6 +22,9 @@ export function createSequentialThinkingReasoningMessage(
|
|||
return null;
|
||||
}
|
||||
|
||||
// Determine status based on state.isComplete or override
|
||||
const status = overrideStatus ?? (sequentialThinkingState.isComplete ? 'completed' : 'loading');
|
||||
|
||||
// Determine title based on status
|
||||
const title = status === 'completed' ? 'Thought for a few seconds' : 'Thinking it through...';
|
||||
|
||||
|
|
|
@ -30,11 +30,7 @@ async function processSequentialThinking(
|
|||
};
|
||||
|
||||
if (state.toolCallId) {
|
||||
const reasoningEntry = createSequentialThinkingReasoningMessage(
|
||||
state,
|
||||
state.toolCallId,
|
||||
'completed'
|
||||
);
|
||||
const reasoningEntry = createSequentialThinkingReasoningMessage(state, state.toolCallId);
|
||||
const rawLlmMessage = createSequentialThinkingRawLlmMessageEntry(state, state.toolCallId);
|
||||
|
||||
const rawToolResultEntry = createRawToolResultEntry(
|
||||
|
@ -79,9 +75,6 @@ export function createSequentialThinkingExecute(
|
|||
) {
|
||||
return wrapTraced(
|
||||
async (_input: SequentialThinkingInput): Promise<SequentialThinkingOutput> => {
|
||||
// Add small delay to ensure finish handler completes its DB update
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
|
||||
if (!state.toolCallId) {
|
||||
throw new Error('Tool call ID is required');
|
||||
}
|
||||
|
|
|
@ -20,13 +20,12 @@ export function createSequentialThinkingFinish(
|
|||
sequentialThinkingState.thought = normalizeEscapedText(options.input.thought);
|
||||
sequentialThinkingState.nextThoughtNeeded = options.input.nextThoughtNeeded;
|
||||
sequentialThinkingState.thoughtNumber = options.input.thoughtNumber;
|
||||
sequentialThinkingState.isComplete = true;
|
||||
|
||||
// Update the reasoning message with completed status in finish
|
||||
// The execute function will also update, but we need to ensure the completed status is set
|
||||
// Update the reasoning message - status will be determined by state.isComplete
|
||||
const reasoningEntry = createSequentialThinkingReasoningMessage(
|
||||
sequentialThinkingState,
|
||||
options.toolCallId,
|
||||
'completed' // Mark as completed when finish is called
|
||||
options.toolCallId
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -19,6 +19,7 @@ export function createSequentialThinkingStart(
|
|||
sequentialThinkingState.thought = undefined;
|
||||
sequentialThinkingState.nextThoughtNeeded = undefined;
|
||||
sequentialThinkingState.thoughtNumber = undefined;
|
||||
sequentialThinkingState.isComplete = false;
|
||||
|
||||
// Create initial reasoning entry with loading status
|
||||
const reasoningEntry = createSequentialThinkingReasoningMessage(
|
||||
|
|
|
@ -53,6 +53,7 @@ const SequentialThinkingStateSchema = z.object({
|
|||
'Current number in sequence. This is optional and will be set by the tool delta and finish'
|
||||
),
|
||||
startTime: z.number().optional().describe('The start time of the thinking process'),
|
||||
isComplete: z.boolean().optional().describe('Whether the thinking process is complete'),
|
||||
});
|
||||
|
||||
export type SequentialThinkingInput = z.infer<typeof SequentialThinkingInputSchema>;
|
||||
|
@ -68,6 +69,7 @@ export function createSequentialThinkingTool(context: SequentialThinkingContext)
|
|||
nextThoughtNeeded: undefined,
|
||||
thoughtNumber: undefined,
|
||||
startTime: undefined,
|
||||
isComplete: undefined,
|
||||
};
|
||||
|
||||
const execute = createSequentialThinkingExecute(state, context);
|
||||
|
|
|
@ -485,9 +485,6 @@ export function createCreateMetricsExecute(
|
|||
) {
|
||||
return wrapTraced(
|
||||
async (input: CreateMetricsInput): Promise<CreateMetricsOutput> => {
|
||||
// Add small delay to ensure finish handler completes its DB update
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
|
||||
const startTime = Date.now();
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue