Refactor agent steps and message roles

- Removed unused `steps` array from `createThinkAndPrepAgent` function to simplify the code.
- Updated message role from 'assistant' to 'user' in `create-todos-step` for better context alignment.
- Adjusted `valuesMessage` role in `extract-values-search-step` to 'user' when extracted values are present, enhancing message clarity.

These changes improve code clarity and ensure consistent message roles across agent steps.
This commit is contained in:
dal 2025-08-12 16:13:41 -06:00
parent a7ced93c6e
commit 0b8f8665d6
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
3 changed files with 8 additions and 11 deletions

View File

@ -53,7 +53,6 @@ export type ThinkAndPrepAgentOptions = z.infer<typeof ThinkAndPrepAgentOptionsSc
export type ThinkAndPrepStreamOptions = z.infer<typeof ThinkAndPrepStreamOptionsSchema>;
export function createThinkAndPrepAgent(thinkAndPrepAgentSchema: ThinkAndPrepAgentOptions) {
const steps: never[] = [];
const { messageId } = thinkAndPrepAgentSchema;
const systemMessage = {
@ -147,12 +146,7 @@ export function createThinkAndPrepAgent(thinkAndPrepAgentSchema: ThinkAndPrepAge
throw new Error('Max retry attempts exceeded');
}
async function getSteps() {
return steps;
}
return {
stream,
getSteps,
};
}

View File

@ -74,7 +74,7 @@ export async function runCreateTodosStep(params: CreateTodosParams): Promise<Cre
const todos = await generateTodosWithLLM(params.messages);
const todosMessage: ModelMessage = {
role: 'assistant',
role: 'user',
content: todos,
};

View File

@ -184,10 +184,13 @@ export async function runExtractValuesAndSearchStep(
return {
values: extractedValues,
valuesMessage: {
role: 'assistant',
content: storedValuesResult.searchResults,
},
valuesMessage:
extractedValues.length > 0
? {
role: 'user',
content: storedValuesResult.searchResults,
}
: undefined,
};
} catch (error) {
// Handle AbortError gracefully