From d137cfe67818818c5587810761a7ccb69cd889d7 Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 21 Aug 2025 16:20:08 -0600 Subject: [PATCH] follow ups with tool result error solved for other tool calls --- .github/workflows/deploy.yml | 19 +++++-------------- .../done-tool/done-tool-execute.ts | 18 +++++++++++++++--- ...essage-user-clarifying-question-execute.ts | 9 +++++++-- .../respond-without-asset-creation-execute.ts | 13 +++++++++++-- .../sequential-thinking-tool-execute.ts | 5 +++++ 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e8ce0c706..ccb4dbdcc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ jobs: deploy: if: ${{ github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'staging') }} runs-on: blacksmith-2vcpu-ubuntu-2404 - environment: ${{ github.event.workflow_run.head_branch == 'main' && 'production' || github.event.workflow_run.head_branch == 'staging' && 'staging' || '' }} + environment: ${{ github.event.workflow_run.head_branch }} steps: - name: Checkout code @@ -32,22 +32,13 @@ jobs: run: | BRANCH="${{ github.event.workflow_run.head_branch }}" SHA="${{ steps.commit.outputs.sha_short }}" + TAG="${BRANCH}-${SHA}" echo "🚀 Deploying to ${BRANCH} environment..." - if [[ "$BRANCH" == "main" ]]; then - echo "📦 Using image tag: ${SHA}" - else - echo "📦 Using image tag: staging-${SHA}" - fi + echo "📦 Using image tag: ${TAG}" - # Update the Porter app with the new image tag - if [[ "$BRANCH" == "main" ]]; then - porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "${SHA}" - echo "deployment_env=production" >> $GITHUB_OUTPUT - else - porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "staging-${SHA}" - echo "deployment_env=staging" >> $GITHUB_OUTPUT - fi + porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "${TAG}" + echo "deployment_env=${BRANCH}" >> $GITHUB_OUTPUT echo "✅ Deployment initiated successfully!" env: diff --git a/packages/ai/src/tools/communication-tools/done-tool/done-tool-execute.ts b/packages/ai/src/tools/communication-tools/done-tool/done-tool-execute.ts index cf5934fcb..90319721c 100644 --- a/packages/ai/src/tools/communication-tools/done-tool/done-tool-execute.ts +++ b/packages/ai/src/tools/communication-tools/done-tool/done-tool-execute.ts @@ -8,19 +8,31 @@ import { type DoneToolOutput, type DoneToolState, } from './done-tool'; +import { createDoneToolRawLlmMessageEntry } from './helpers/done-tool-transform-helper'; // Process done tool execution with todo management -async function processDone(toolCallId: string, messageId: string): Promise { +async function processDone( + state: DoneToolState, + toolCallId: string, + messageId: string +): Promise { const output: DoneToolOutput = { success: true, }; + // Create both the tool call and result messages to maintain proper ordering + const rawLlmMessage = createDoneToolRawLlmMessageEntry(state, toolCallId); const rawToolResultEntry = createRawToolResultEntry(toolCallId, DONE_TOOL_NAME, output); try { + // Send both messages together: tool call followed by result + const rawLlmMessages = rawLlmMessage + ? [rawLlmMessage, rawToolResultEntry] + : [rawToolResultEntry]; + await updateMessageEntries({ messageId, - rawLlmMessages: [rawToolResultEntry], + rawLlmMessages, }); } catch (error) { console.error('[done-tool] Error updating message entries:', error); @@ -37,7 +49,7 @@ export function createDoneToolExecute(context: DoneToolContext, state: DoneToolS throw new Error('Tool call ID is required'); } - return processDone(state.toolCallId, context.messageId); + return processDone(state, state.toolCallId, context.messageId); }, { name: 'Done Tool' } ); diff --git a/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-execute.ts b/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-execute.ts index e58d41d7e..41d956820 100644 --- a/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-execute.ts +++ b/packages/ai/src/tools/communication-tools/message-user-clarifying-question/message-user-clarifying-question-execute.ts @@ -1,6 +1,7 @@ import { updateMessageEntries } from '@buster/database'; import { wrapTraced } from 'braintrust'; import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry'; +import { messageUserClarifyingQuestionRawLlmMessageEntry } from './helpers/message-user-clarifying-question-transform-helper'; import type { MessageUserClarifyingQuestionContext, MessageUserClarifyingQuestionInput, @@ -11,6 +12,7 @@ import { MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME } from './message-user-clari // Process message user clarifying question tool execution async function processMessageUserClarifyingQuestion( + state: MessageUserClarifyingQuestionState, toolCallId: string, messageId: string ): Promise { @@ -18,6 +20,8 @@ async function processMessageUserClarifyingQuestion( success: true, }; + // Create both the tool call and result messages to maintain proper ordering + const rawLlmMessage = messageUserClarifyingQuestionRawLlmMessageEntry(toolCallId, state); const rawToolResultEntry = createRawToolResultEntry( toolCallId, MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME, @@ -25,9 +29,10 @@ async function processMessageUserClarifyingQuestion( ); try { + // Send both messages together: tool call followed by result await updateMessageEntries({ messageId, - rawLlmMessages: [rawToolResultEntry], + rawLlmMessages: [rawLlmMessage, rawToolResultEntry], }); } catch (error) { console.error('[message-user-clarifying-question] Error updating message entries:', error); @@ -50,7 +55,7 @@ export function createMessageUserClarifyingQuestionExecute( throw new Error('Tool call ID is required'); } - return processMessageUserClarifyingQuestion(state.toolCallId, context.messageId); + return processMessageUserClarifyingQuestion(state, state.toolCallId, context.messageId); }, { name: 'Message User Clarifying Question' } ); diff --git a/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-execute.ts b/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-execute.ts index b7edec401..d128a031d 100644 --- a/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-execute.ts +++ b/packages/ai/src/tools/communication-tools/respond-without-asset-creation/respond-without-asset-creation-execute.ts @@ -1,6 +1,7 @@ import { updateMessageEntries } from '@buster/database'; import { wrapTraced } from 'braintrust'; import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry'; +import { createRespondWithoutAssetCreationRawLlmMessageEntry } from './helpers/respond-without-asset-creation-transform-helper'; import { RESPOND_WITHOUT_ASSET_CREATION_TOOL_NAME, type RespondWithoutAssetCreationContext, @@ -10,6 +11,7 @@ import { } from './respond-without-asset-creation-tool'; async function processRespondWithoutAssetCreation( + state: RespondWithoutAssetCreationState, toolCallId: string, messageId: string ): Promise { @@ -17,6 +19,8 @@ async function processRespondWithoutAssetCreation( success: true, }; + // Create both the tool call and result messages to maintain proper ordering + const rawLlmMessage = createRespondWithoutAssetCreationRawLlmMessageEntry(state, toolCallId); const rawToolResultEntry = createRawToolResultEntry( toolCallId, RESPOND_WITHOUT_ASSET_CREATION_TOOL_NAME, @@ -24,9 +28,14 @@ async function processRespondWithoutAssetCreation( ); try { + // Send both messages together: tool call followed by result + const rawLlmMessages = rawLlmMessage + ? [rawLlmMessage, rawToolResultEntry] + : [rawToolResultEntry]; + await updateMessageEntries({ messageId, - rawLlmMessages: [rawToolResultEntry], + rawLlmMessages, }); } catch (error) { console.error('[respond-without-asset-creation] Error updating message entries:', error); @@ -47,7 +56,7 @@ export function createRespondWithoutAssetCreationExecute( throw new Error('Tool call ID is required'); } - return await processRespondWithoutAssetCreation(state.toolCallId, context.messageId); + return await processRespondWithoutAssetCreation(state, state.toolCallId, context.messageId); }, { name: 'Respond Without Asset Creation' } ); diff --git a/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-execute.ts b/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-execute.ts index 1486701ca..b04174134 100644 --- a/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-execute.ts +++ b/packages/ai/src/tools/planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool-execute.ts @@ -47,8 +47,13 @@ async function processSequentialThinking( entries.reasoningMessages = [reasoningEntry]; } + // Always send both raw LLM messages together to maintain proper ordering + // If rawLlmMessage is null (shouldn't happen since we checked toolCallId), send just the result if (rawLlmMessage) { entries.rawLlmMessages = [rawLlmMessage, rawToolResultEntry]; + } else { + // This shouldn't happen, but as a fallback, at least send the result + entries.rawLlmMessages = [rawToolResultEntry]; } try {