mirror of https://github.com/buster-so/buster.git
move sequential thinking away from old inherited context
This commit is contained in:
parent
0b8f8665d6
commit
e52c0c7d72
|
@ -21,9 +21,9 @@ const NEXT_THOUGHT_NEEDED_KEY =
|
||||||
'nextThoughtNeeded' as const satisfies keyof SequentialThinkingInput;
|
'nextThoughtNeeded' as const satisfies keyof SequentialThinkingInput;
|
||||||
const THOUGHT_NUMBER_KEY = 'thoughtNumber' as const satisfies keyof SequentialThinkingInput;
|
const THOUGHT_NUMBER_KEY = 'thoughtNumber' as const satisfies keyof SequentialThinkingInput;
|
||||||
|
|
||||||
export function createSequentialThinkingDelta<TAgentContext extends SequentialThinkingContext>(
|
export function createSequentialThinkingDelta(
|
||||||
sequentialThinkingState: SequentialThinkingState,
|
sequentialThinkingState: SequentialThinkingState,
|
||||||
context: TAgentContext
|
context: SequentialThinkingContext
|
||||||
) {
|
) {
|
||||||
return async function sequentialThinkingDelta(
|
return async function sequentialThinkingDelta(
|
||||||
options: { inputTextDelta: string } & ToolCallOptions
|
options: { inputTextDelta: string } & ToolCallOptions
|
||||||
|
|
|
@ -35,9 +35,7 @@ async function processSequentialThinking(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factory function that creates the execute function with proper context typing
|
// Factory function that creates the execute function with proper context typing
|
||||||
export function createSequentialThinkingExecute<TAgentContext extends SequentialThinkingContext>(
|
export function createSequentialThinkingExecute(context: SequentialThinkingContext) {
|
||||||
context: TAgentContext
|
|
||||||
) {
|
|
||||||
return wrapTraced(
|
return wrapTraced(
|
||||||
async (input: SequentialThinkingInput): Promise<SequentialThinkingOutput> => {
|
async (input: SequentialThinkingInput): Promise<SequentialThinkingOutput> => {
|
||||||
// Use the messageId from the passed context
|
// Use the messageId from the passed context
|
||||||
|
|
|
@ -11,9 +11,9 @@ import type {
|
||||||
SequentialThinkingState,
|
SequentialThinkingState,
|
||||||
} from './sequential-thinking-tool';
|
} from './sequential-thinking-tool';
|
||||||
|
|
||||||
export function createSequentialThinkingFinish<TAgentContext extends SequentialThinkingContext>(
|
export function createSequentialThinkingFinish(
|
||||||
sequentialThinkingState: SequentialThinkingState,
|
sequentialThinkingState: SequentialThinkingState,
|
||||||
context: TAgentContext
|
context: SequentialThinkingContext
|
||||||
) {
|
) {
|
||||||
return async function sequentialThinkingFinish(
|
return async function sequentialThinkingFinish(
|
||||||
options: { input: SequentialThinkingInput } & ToolCallOptions
|
options: { input: SequentialThinkingInput } & ToolCallOptions
|
||||||
|
|
|
@ -10,9 +10,9 @@ import type {
|
||||||
} from './sequential-thinking-tool';
|
} from './sequential-thinking-tool';
|
||||||
|
|
||||||
// Factory function that creates a type-safe callback for the specific agent context
|
// Factory function that creates a type-safe callback for the specific agent context
|
||||||
export function createSequentialThinkingStart<TAgentContext extends SequentialThinkingContext>(
|
export function createSequentialThinkingStart(
|
||||||
sequentialThinkingState: SequentialThinkingState,
|
sequentialThinkingState: SequentialThinkingState,
|
||||||
context: TAgentContext
|
context: SequentialThinkingContext
|
||||||
) {
|
) {
|
||||||
return async function sequentialThinkingStart(options: ToolCallOptions): Promise<void> {
|
return async function sequentialThinkingStart(options: ToolCallOptions): Promise<void> {
|
||||||
// Set the entry ID in state
|
// Set the entry ID in state
|
||||||
|
|
|
@ -58,9 +58,7 @@ export type SequentialThinkingOutput = z.infer<typeof SequentialThinkingOutputSc
|
||||||
export type SequentialThinkingContext = z.infer<typeof SequentialThinkingContextSchema>;
|
export type SequentialThinkingContext = z.infer<typeof SequentialThinkingContextSchema>;
|
||||||
export type SequentialThinkingState = z.infer<typeof SequentialThinkingStateSchema>;
|
export type SequentialThinkingState = z.infer<typeof SequentialThinkingStateSchema>;
|
||||||
|
|
||||||
export function createSequentialThinkingTool<
|
export function createSequentialThinkingTool(context: SequentialThinkingContext) {
|
||||||
TAgentContext extends SequentialThinkingContext = SequentialThinkingContext,
|
|
||||||
>(context: TAgentContext) {
|
|
||||||
const state: SequentialThinkingState = {
|
const state: SequentialThinkingState = {
|
||||||
entry_id: undefined,
|
entry_id: undefined,
|
||||||
args: undefined,
|
args: undefined,
|
||||||
|
@ -69,10 +67,10 @@ export function createSequentialThinkingTool<
|
||||||
thoughtNumber: undefined,
|
thoughtNumber: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const execute = createSequentialThinkingExecute<TAgentContext>(context);
|
const execute = createSequentialThinkingExecute(context);
|
||||||
const onInputStart = createSequentialThinkingStart<TAgentContext>(state, context);
|
const onInputStart = createSequentialThinkingStart(state, context);
|
||||||
const onInputDelta = createSequentialThinkingDelta<TAgentContext>(state, context);
|
const onInputDelta = createSequentialThinkingDelta(state, context);
|
||||||
const onInputAvailable = createSequentialThinkingFinish<TAgentContext>(state, context);
|
const onInputAvailable = createSequentialThinkingFinish(state, context);
|
||||||
|
|
||||||
return tool({
|
return tool({
|
||||||
description: `A detailed tool for dynamic and reflective problem-solving through thoughts.
|
description: `A detailed tool for dynamic and reflective problem-solving through thoughts.
|
||||||
|
|
|
@ -852,10 +852,10 @@ export const messages = pgTable(
|
||||||
{
|
{
|
||||||
id: uuid().defaultRandom().primaryKey().notNull(),
|
id: uuid().defaultRandom().primaryKey().notNull(),
|
||||||
requestMessage: text('request_message'),
|
requestMessage: text('request_message'),
|
||||||
responseMessages: jsonb('response_messages').notNull(),
|
responseMessages: jsonb('response_messages').default([]).notNull(),
|
||||||
reasoning: jsonb().notNull(),
|
reasoning: jsonb().default([]).notNull(),
|
||||||
title: text().notNull(),
|
title: text().notNull(),
|
||||||
rawLlmMessages: jsonb('raw_llm_messages').notNull(),
|
rawLlmMessages: jsonb('raw_llm_messages').default([]).notNull(),
|
||||||
finalReasoningMessage: text('final_reasoning_message'),
|
finalReasoningMessage: text('final_reasoning_message'),
|
||||||
chatId: uuid('chat_id').notNull(),
|
chatId: uuid('chat_id').notNull(),
|
||||||
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' })
|
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' })
|
||||||
|
|
Loading…
Reference in New Issue