follow ups with tool result error solved for other tool calls

This commit is contained in:
dal 2025-08-21 16:20:08 -06:00
parent 531966e0cd
commit d137cfe678
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
5 changed files with 43 additions and 21 deletions

View File

@ -10,7 +10,7 @@ jobs:
deploy: deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'staging') }} 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 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: steps:
- name: Checkout code - name: Checkout code
@ -32,22 +32,13 @@ jobs:
run: | run: |
BRANCH="${{ github.event.workflow_run.head_branch }}" BRANCH="${{ github.event.workflow_run.head_branch }}"
SHA="${{ steps.commit.outputs.sha_short }}" SHA="${{ steps.commit.outputs.sha_short }}"
TAG="${BRANCH}-${SHA}"
echo "🚀 Deploying to ${BRANCH} environment..." echo "🚀 Deploying to ${BRANCH} environment..."
if [[ "$BRANCH" == "main" ]]; then echo "📦 Using image tag: ${TAG}"
echo "📦 Using image tag: ${SHA}"
else
echo "📦 Using image tag: staging-${SHA}"
fi
# Update the Porter app with the new image tag porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "${TAG}"
if [[ "$BRANCH" == "main" ]]; then echo "deployment_env=${BRANCH}" >> $GITHUB_OUTPUT
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
echo "✅ Deployment initiated successfully!" echo "✅ Deployment initiated successfully!"
env: env:

View File

@ -8,19 +8,31 @@ import {
type DoneToolOutput, type DoneToolOutput,
type DoneToolState, type DoneToolState,
} from './done-tool'; } from './done-tool';
import { createDoneToolRawLlmMessageEntry } from './helpers/done-tool-transform-helper';
// Process done tool execution with todo management // Process done tool execution with todo management
async function processDone(toolCallId: string, messageId: string): Promise<DoneToolOutput> { async function processDone(
state: DoneToolState,
toolCallId: string,
messageId: string
): Promise<DoneToolOutput> {
const output: DoneToolOutput = { const output: DoneToolOutput = {
success: true, 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); const rawToolResultEntry = createRawToolResultEntry(toolCallId, DONE_TOOL_NAME, output);
try { try {
// Send both messages together: tool call followed by result
const rawLlmMessages = rawLlmMessage
? [rawLlmMessage, rawToolResultEntry]
: [rawToolResultEntry];
await updateMessageEntries({ await updateMessageEntries({
messageId, messageId,
rawLlmMessages: [rawToolResultEntry], rawLlmMessages,
}); });
} catch (error) { } catch (error) {
console.error('[done-tool] Error updating message entries:', 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'); throw new Error('Tool call ID is required');
} }
return processDone(state.toolCallId, context.messageId); return processDone(state, state.toolCallId, context.messageId);
}, },
{ name: 'Done Tool' } { name: 'Done Tool' }
); );

View File

@ -1,6 +1,7 @@
import { updateMessageEntries } from '@buster/database'; import { updateMessageEntries } from '@buster/database';
import { wrapTraced } from 'braintrust'; import { wrapTraced } from 'braintrust';
import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry'; import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry';
import { messageUserClarifyingQuestionRawLlmMessageEntry } from './helpers/message-user-clarifying-question-transform-helper';
import type { import type {
MessageUserClarifyingQuestionContext, MessageUserClarifyingQuestionContext,
MessageUserClarifyingQuestionInput, MessageUserClarifyingQuestionInput,
@ -11,6 +12,7 @@ import { MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME } from './message-user-clari
// Process message user clarifying question tool execution // Process message user clarifying question tool execution
async function processMessageUserClarifyingQuestion( async function processMessageUserClarifyingQuestion(
state: MessageUserClarifyingQuestionState,
toolCallId: string, toolCallId: string,
messageId: string messageId: string
): Promise<MessageUserClarifyingQuestionOutput> { ): Promise<MessageUserClarifyingQuestionOutput> {
@ -18,6 +20,8 @@ async function processMessageUserClarifyingQuestion(
success: true, success: true,
}; };
// Create both the tool call and result messages to maintain proper ordering
const rawLlmMessage = messageUserClarifyingQuestionRawLlmMessageEntry(toolCallId, state);
const rawToolResultEntry = createRawToolResultEntry( const rawToolResultEntry = createRawToolResultEntry(
toolCallId, toolCallId,
MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME, MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME,
@ -25,9 +29,10 @@ async function processMessageUserClarifyingQuestion(
); );
try { try {
// Send both messages together: tool call followed by result
await updateMessageEntries({ await updateMessageEntries({
messageId, messageId,
rawLlmMessages: [rawToolResultEntry], rawLlmMessages: [rawLlmMessage, rawToolResultEntry],
}); });
} catch (error) { } catch (error) {
console.error('[message-user-clarifying-question] Error updating message entries:', 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'); 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' } { name: 'Message User Clarifying Question' }
); );

View File

@ -1,6 +1,7 @@
import { updateMessageEntries } from '@buster/database'; import { updateMessageEntries } from '@buster/database';
import { wrapTraced } from 'braintrust'; import { wrapTraced } from 'braintrust';
import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry'; import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry';
import { createRespondWithoutAssetCreationRawLlmMessageEntry } from './helpers/respond-without-asset-creation-transform-helper';
import { import {
RESPOND_WITHOUT_ASSET_CREATION_TOOL_NAME, RESPOND_WITHOUT_ASSET_CREATION_TOOL_NAME,
type RespondWithoutAssetCreationContext, type RespondWithoutAssetCreationContext,
@ -10,6 +11,7 @@ import {
} from './respond-without-asset-creation-tool'; } from './respond-without-asset-creation-tool';
async function processRespondWithoutAssetCreation( async function processRespondWithoutAssetCreation(
state: RespondWithoutAssetCreationState,
toolCallId: string, toolCallId: string,
messageId: string messageId: string
): Promise<RespondWithoutAssetCreationOutput> { ): Promise<RespondWithoutAssetCreationOutput> {
@ -17,6 +19,8 @@ async function processRespondWithoutAssetCreation(
success: true, success: true,
}; };
// Create both the tool call and result messages to maintain proper ordering
const rawLlmMessage = createRespondWithoutAssetCreationRawLlmMessageEntry(state, toolCallId);
const rawToolResultEntry = createRawToolResultEntry( const rawToolResultEntry = createRawToolResultEntry(
toolCallId, toolCallId,
RESPOND_WITHOUT_ASSET_CREATION_TOOL_NAME, RESPOND_WITHOUT_ASSET_CREATION_TOOL_NAME,
@ -24,9 +28,14 @@ async function processRespondWithoutAssetCreation(
); );
try { try {
// Send both messages together: tool call followed by result
const rawLlmMessages = rawLlmMessage
? [rawLlmMessage, rawToolResultEntry]
: [rawToolResultEntry];
await updateMessageEntries({ await updateMessageEntries({
messageId, messageId,
rawLlmMessages: [rawToolResultEntry], rawLlmMessages,
}); });
} catch (error) { } catch (error) {
console.error('[respond-without-asset-creation] Error updating message entries:', 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'); 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' } { name: 'Respond Without Asset Creation' }
); );

View File

@ -47,8 +47,13 @@ async function processSequentialThinking(
entries.reasoningMessages = [reasoningEntry]; 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) { if (rawLlmMessage) {
entries.rawLlmMessages = [rawLlmMessage, rawToolResultEntry]; entries.rawLlmMessages = [rawLlmMessage, rawToolResultEntry];
} else {
// This shouldn't happen, but as a fallback, at least send the result
entries.rawLlmMessages = [rawToolResultEntry];
} }
try { try {