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:
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:

View File

@ -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<DoneToolOutput> {
async function processDone(
state: DoneToolState,
toolCallId: string,
messageId: string
): Promise<DoneToolOutput> {
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' }
);

View File

@ -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<MessageUserClarifyingQuestionOutput> {
@ -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' }
);

View File

@ -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<RespondWithoutAssetCreationOutput> {
@ -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' }
);

View File

@ -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 {