move sequential thinking away from old inherited context

This commit is contained in:
dal 2025-08-12 16:15:37 -06:00
parent 0b8f8665d6
commit e52c0c7d72
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
6 changed files with 15 additions and 19 deletions

View File

@ -21,9 +21,9 @@ const NEXT_THOUGHT_NEEDED_KEY =
'nextThoughtNeeded' 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,
context: TAgentContext
context: SequentialThinkingContext
) {
return async function sequentialThinkingDelta(
options: { inputTextDelta: string } & ToolCallOptions

View File

@ -35,9 +35,7 @@ async function processSequentialThinking(
}
// Factory function that creates the execute function with proper context typing
export function createSequentialThinkingExecute<TAgentContext extends SequentialThinkingContext>(
context: TAgentContext
) {
export function createSequentialThinkingExecute(context: SequentialThinkingContext) {
return wrapTraced(
async (input: SequentialThinkingInput): Promise<SequentialThinkingOutput> => {
// Use the messageId from the passed context

View File

@ -11,9 +11,9 @@ import type {
SequentialThinkingState,
} from './sequential-thinking-tool';
export function createSequentialThinkingFinish<TAgentContext extends SequentialThinkingContext>(
export function createSequentialThinkingFinish(
sequentialThinkingState: SequentialThinkingState,
context: TAgentContext
context: SequentialThinkingContext
) {
return async function sequentialThinkingFinish(
options: { input: SequentialThinkingInput } & ToolCallOptions

View File

@ -10,9 +10,9 @@ import type {
} from './sequential-thinking-tool';
// Factory function that creates a type-safe callback for the specific agent context
export function createSequentialThinkingStart<TAgentContext extends SequentialThinkingContext>(
export function createSequentialThinkingStart(
sequentialThinkingState: SequentialThinkingState,
context: TAgentContext
context: SequentialThinkingContext
) {
return async function sequentialThinkingStart(options: ToolCallOptions): Promise<void> {
// Set the entry ID in state

View File

@ -58,9 +58,7 @@ export type SequentialThinkingOutput = z.infer<typeof SequentialThinkingOutputSc
export type SequentialThinkingContext = z.infer<typeof SequentialThinkingContextSchema>;
export type SequentialThinkingState = z.infer<typeof SequentialThinkingStateSchema>;
export function createSequentialThinkingTool<
TAgentContext extends SequentialThinkingContext = SequentialThinkingContext,
>(context: TAgentContext) {
export function createSequentialThinkingTool(context: SequentialThinkingContext) {
const state: SequentialThinkingState = {
entry_id: undefined,
args: undefined,
@ -69,10 +67,10 @@ export function createSequentialThinkingTool<
thoughtNumber: undefined,
};
const execute = createSequentialThinkingExecute<TAgentContext>(context);
const onInputStart = createSequentialThinkingStart<TAgentContext>(state, context);
const onInputDelta = createSequentialThinkingDelta<TAgentContext>(state, context);
const onInputAvailable = createSequentialThinkingFinish<TAgentContext>(state, context);
const execute = createSequentialThinkingExecute(context);
const onInputStart = createSequentialThinkingStart(state, context);
const onInputDelta = createSequentialThinkingDelta(state, context);
const onInputAvailable = createSequentialThinkingFinish(state, context);
return tool({
description: `A detailed tool for dynamic and reflective problem-solving through thoughts.

View File

@ -852,10 +852,10 @@ export const messages = pgTable(
{
id: uuid().defaultRandom().primaryKey().notNull(),
requestMessage: text('request_message'),
responseMessages: jsonb('response_messages').notNull(),
reasoning: jsonb().notNull(),
responseMessages: jsonb('response_messages').default([]).notNull(),
reasoning: jsonb().default([]).notNull(),
title: text().notNull(),
rawLlmMessages: jsonb('raw_llm_messages').notNull(),
rawLlmMessages: jsonb('raw_llm_messages').default([]).notNull(),
finalReasoningMessage: text('final_reasoning_message'),
chatId: uuid('chat_id').notNull(),
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' })