From b3cfa35430287f40daf8674b2aef7f287e27456d Mon Sep 17 00:00:00 2001 From: dal Date: Mon, 18 Aug 2025 11:20:06 -0600 Subject: [PATCH] for the most part things are looking good --- .../identify-assumptions-step.ts | 1 - .../communication-tools/done-tool/done-tool-start.ts | 3 +++ .../message-user-clarifying-question-start.ts | 4 +++- .../respond-without-asset-creation-start.ts | 3 +++ .../tools/database-tools/execute-sql/execute-sql-start.ts | 4 +++- .../sequential-thinking-tool-start.ts | 6 +++++- .../create-dashboards-tool/create-dashboards-start.ts | 4 +++- .../modify-dashboards-tool/modify-dashboards-start.ts | 4 +++- .../metrics/create-metrics-tool/create-metrics-start.ts | 3 +++ .../metrics/modify-metrics-tool/modify-metrics-start.ts | 3 +++ .../reports/create-reports-tool/create-reports-start.ts | 3 +++ .../reports/modify-reports-tool/modify-reports-start.ts | 8 ++++++++ 12 files changed, 40 insertions(+), 6 deletions(-) diff --git a/packages/ai/src/steps/message-post-processing-steps/identify-assumptions-step/identify-assumptions-step.ts b/packages/ai/src/steps/message-post-processing-steps/identify-assumptions-step/identify-assumptions-step.ts index 7567cf2ad..21c6ab584 100644 --- a/packages/ai/src/steps/message-post-processing-steps/identify-assumptions-step/identify-assumptions-step.ts +++ b/packages/ai/src/steps/message-post-processing-steps/identify-assumptions-step/identify-assumptions-step.ts @@ -190,7 +190,6 @@ No conversation history available for analysis.`, maxOutputTokens: 10000, providerOptions: { anthropic: { - disableParallelToolCalls: true, thinking: { type: 'enabled', budgetTokens: 16000 }, }, }, diff --git a/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts b/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts index 28c4e7ce5..71924c8b6 100644 --- a/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts +++ b/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts @@ -14,7 +14,10 @@ import { // Factory function that creates a type-safe callback for the specific agent context export function createDoneToolStart(context: DoneToolContext, doneToolState: DoneToolState) { return async function doneToolStart(options: ToolCallOptions): Promise { + // Reset state for new tool call to prevent contamination from previous calls doneToolState.toolCallId = options.toolCallId; + doneToolState.args = undefined; + doneToolState.finalResponse = undefined; // Extract files from the tool call responses in messages if (options.messages) { diff --git a/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-start.ts b/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-start.ts index c255d65a3..589b7efd7 100644 --- a/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-start.ts +++ b/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-start.ts @@ -17,8 +17,10 @@ export function createMessageUserClarifyingQuestionStart( return async (options: ToolCallOptions) => { const messageId = context.messageId; - // Initialize state + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; + state.args = ''; + state.clarifyingQuestion = undefined; // If we have a messageId, create initial database entries if (messageId) { diff --git a/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-start.ts b/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-start.ts index b1f17e570..9024b482b 100644 --- a/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-start.ts +++ b/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-start.ts @@ -17,7 +17,10 @@ export function createRespondWithoutAssetCreationStart( return async function respondWithoutAssetCreationStart( options: Pick ): Promise { + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; + state.args = undefined; + state.final_response = undefined; const responseEntry = createRespondWithoutAssetCreationResponseMessage( state, diff --git a/packages/ai/src/tools/database-tools/execute-sql/execute-sql-start.ts b/packages/ai/src/tools/database-tools/execute-sql/execute-sql-start.ts index df4d26fea..52f072f35 100644 --- a/packages/ai/src/tools/database-tools/execute-sql/execute-sql-start.ts +++ b/packages/ai/src/tools/database-tools/execute-sql/execute-sql-start.ts @@ -8,12 +8,14 @@ import { export function createExecuteSqlStart(state: ExecuteSqlState, context: ExecuteSqlContext) { return async function executeSqlStart(options: ToolCallOptions): Promise { - // Initialize state + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; state.args = ''; state.statements = []; state.isComplete = false; state.startTime = Date.now(); + state.executionTime = undefined; + state.executionResults = undefined; // Create initial reasoning entry for SQL execution const reasoningEntry = createExecuteSqlReasoningEntry(state, options.toolCallId); diff --git a/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-start.ts b/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-start.ts index eb1b9fec5..ff28644ba 100644 --- a/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-start.ts +++ b/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-start.ts @@ -15,9 +15,13 @@ export function createSequentialThinkingStart( context: SequentialThinkingContext ) { return async function sequentialThinkingStart(options: ToolCallOptions): Promise { - // Set the entry ID and start time in state + // Reset state for new tool call to prevent contamination from previous calls sequentialThinkingState.toolCallId = options.toolCallId; sequentialThinkingState.startTime = Date.now(); + sequentialThinkingState.args = undefined; + sequentialThinkingState.thought = undefined; + sequentialThinkingState.nextThoughtNeeded = undefined; + sequentialThinkingState.thoughtNumber = undefined; // Create initial reasoning entry with loading status const reasoningEntry = createSequentialThinkingReasoningMessage( diff --git a/packages/ai/src/tools/visualization-tools/dashboards/create-dashboards-tool/create-dashboards-start.ts b/packages/ai/src/tools/visualization-tools/dashboards/create-dashboards-tool/create-dashboards-start.ts index 063d1542d..2b7acd461 100644 --- a/packages/ai/src/tools/visualization-tools/dashboards/create-dashboards-tool/create-dashboards-start.ts +++ b/packages/ai/src/tools/visualization-tools/dashboards/create-dashboards-tool/create-dashboards-start.ts @@ -11,8 +11,10 @@ export function createDashboardsStart( state: CreateDashboardsState ) { return async (options: ToolCallOptions) => { + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; - state.startTime = Date.now(); + state.argsText = undefined; + state.files = []; state.startTime = Date.now(); if (context.messageId) { diff --git a/packages/ai/src/tools/visualization-tools/dashboards/modify-dashboards-tool/modify-dashboards-start.ts b/packages/ai/src/tools/visualization-tools/dashboards/modify-dashboards-tool/modify-dashboards-start.ts index deb00af11..bc68acb35 100644 --- a/packages/ai/src/tools/visualization-tools/dashboards/modify-dashboards-tool/modify-dashboards-start.ts +++ b/packages/ai/src/tools/visualization-tools/dashboards/modify-dashboards-tool/modify-dashboards-start.ts @@ -11,8 +11,10 @@ export function createModifyDashboardsStart( state: ModifyDashboardsState ) { return async (options: ToolCallOptions) => { + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; - state.startTime = Date.now(); + state.argsText = undefined; + state.files = []; state.startTime = Date.now(); if (context.messageId) { diff --git a/packages/ai/src/tools/visualization-tools/metrics/create-metrics-tool/create-metrics-start.ts b/packages/ai/src/tools/visualization-tools/metrics/create-metrics-tool/create-metrics-start.ts index 36d005325..95fa4037f 100644 --- a/packages/ai/src/tools/visualization-tools/metrics/create-metrics-tool/create-metrics-start.ts +++ b/packages/ai/src/tools/visualization-tools/metrics/create-metrics-tool/create-metrics-start.ts @@ -9,6 +9,9 @@ import { export function createCreateMetricsStart(context: CreateMetricsContext, state: CreateMetricsState) { return async (options: ToolCallOptions) => { state.toolCallId = options.toolCallId; + // Reset state for new tool call to prevent contamination from previous calls + state.argsText = undefined; + state.files = []; state.startTime = Date.now(); if (context.messageId) { diff --git a/packages/ai/src/tools/visualization-tools/metrics/modify-metrics-tool/modify-metrics-start.ts b/packages/ai/src/tools/visualization-tools/metrics/modify-metrics-tool/modify-metrics-start.ts index 78980ef6b..6907fa5e6 100644 --- a/packages/ai/src/tools/visualization-tools/metrics/modify-metrics-tool/modify-metrics-start.ts +++ b/packages/ai/src/tools/visualization-tools/metrics/modify-metrics-tool/modify-metrics-start.ts @@ -8,7 +8,10 @@ import type { ModifyMetricsContext, ModifyMetricsState } from './modify-metrics- export function createModifyMetricsStart(context: ModifyMetricsContext, state: ModifyMetricsState) { return async (options: ToolCallOptions) => { + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; + state.argsText = undefined; + state.files = []; state.startTime = Date.now(); if (context.messageId) { diff --git a/packages/ai/src/tools/visualization-tools/reports/create-reports-tool/create-reports-start.ts b/packages/ai/src/tools/visualization-tools/reports/create-reports-tool/create-reports-start.ts index 068c0ad77..8725ae5c9 100644 --- a/packages/ai/src/tools/visualization-tools/reports/create-reports-tool/create-reports-start.ts +++ b/packages/ai/src/tools/visualization-tools/reports/create-reports-tool/create-reports-start.ts @@ -8,7 +8,10 @@ import { export function createReportsStart(context: CreateReportsContext, state: CreateReportsState) { return async (options: ToolCallOptions) => { + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; + state.argsText = undefined; + state.files = []; state.startTime = Date.now(); if (context.messageId) { diff --git a/packages/ai/src/tools/visualization-tools/reports/modify-reports-tool/modify-reports-start.ts b/packages/ai/src/tools/visualization-tools/reports/modify-reports-tool/modify-reports-start.ts index ee9703b71..6ac332d1c 100644 --- a/packages/ai/src/tools/visualization-tools/reports/modify-reports-tool/modify-reports-start.ts +++ b/packages/ai/src/tools/visualization-tools/reports/modify-reports-tool/modify-reports-start.ts @@ -8,7 +8,15 @@ import type { ModifyReportsContext, ModifyReportsState } from './modify-reports- export function modifyReportsStart(context: ModifyReportsContext, state: ModifyReportsState) { return async (options: ToolCallOptions) => { + // Reset state for new tool call to prevent contamination from previous calls state.toolCallId = options.toolCallId; + state.argsText = undefined; + state.reportId = undefined; + state.reportName = undefined; + state.edits = []; + state.currentContent = undefined; + state.finalContent = undefined; + state.version_number = undefined; state.startTime = Date.now(); if (context.messageId) {