update
This commit is contained in:
@@ -41,8 +41,14 @@ export class DriverAgent {
|
||||
// Reset message history
|
||||
this.messageHistory = [];
|
||||
|
||||
// Build the user message
|
||||
const userMessage = `TASK: ${task}\n\nAnalyze this task and determine what actions are needed. If you need to use a tool, provide a tool call proposal.`;
|
||||
// Build the user message based on available tools
|
||||
const hasTools = this.tools.size > 0;
|
||||
let userMessage: string;
|
||||
if (hasTools) {
|
||||
userMessage = `TASK: ${task}\n\nAnalyze this task and determine what actions are needed. If you need to use a tool, provide a tool call proposal.`;
|
||||
} else {
|
||||
userMessage = `TASK: ${task}\n\nComplete this task directly. When done, wrap your final output in <task_complete>your output here</task_complete> tags.`;
|
||||
}
|
||||
|
||||
// Add to history
|
||||
this.messageHistory.push({
|
||||
@@ -50,9 +56,15 @@ export class DriverAgent {
|
||||
content: userMessage,
|
||||
});
|
||||
|
||||
// Build tool descriptions for the system message
|
||||
const toolDescriptions = this.buildToolDescriptions();
|
||||
const fullSystemMessage = `${this.systemMessage}\n\n## Available Tools\n${toolDescriptions}`;
|
||||
// Build the system message - adapt based on available tools
|
||||
let fullSystemMessage: string;
|
||||
if (hasTools) {
|
||||
const toolDescriptions = this.buildToolDescriptions();
|
||||
fullSystemMessage = `${this.systemMessage}\n\n## Available Tools\n${toolDescriptions}`;
|
||||
} else {
|
||||
// Use a simpler system message when no tools are available
|
||||
fullSystemMessage = this.getNoToolsSystemMessage();
|
||||
}
|
||||
|
||||
// Get response from provider
|
||||
const response = await this.provider.chat({
|
||||
@@ -83,9 +95,15 @@ export class DriverAgent {
|
||||
content: message,
|
||||
});
|
||||
|
||||
// Build tool descriptions for the system message
|
||||
const toolDescriptions = this.buildToolDescriptions();
|
||||
const fullSystemMessage = `${this.systemMessage}\n\n## Available Tools\n${toolDescriptions}`;
|
||||
// Build the system message - adapt based on available tools
|
||||
const hasTools = this.tools.size > 0;
|
||||
let fullSystemMessage: string;
|
||||
if (hasTools) {
|
||||
const toolDescriptions = this.buildToolDescriptions();
|
||||
fullSystemMessage = `${this.systemMessage}\n\n## Available Tools\n${toolDescriptions}`;
|
||||
} else {
|
||||
fullSystemMessage = this.getNoToolsSystemMessage();
|
||||
}
|
||||
|
||||
// Get response from provider (pass all but last user message as history)
|
||||
const historyForChat = this.messageHistory.slice(0, -1);
|
||||
@@ -312,6 +330,35 @@ When you need to use a tool, output a tool call proposal in this format:
|
||||
- If you need clarification, ask using <needs_clarification>your question</needs_clarification>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system message when no tools are available
|
||||
* Used for direct task completion without tool usage
|
||||
*/
|
||||
private getNoToolsSystemMessage(): string {
|
||||
// Use custom system message if provided, otherwise use a simple default
|
||||
if (this.systemMessage && this.systemMessage !== this.getDefaultSystemMessage()) {
|
||||
return this.systemMessage;
|
||||
}
|
||||
|
||||
return `You are an AI assistant that completes tasks directly.
|
||||
|
||||
## Your Role
|
||||
You analyze tasks and provide complete, high-quality outputs.
|
||||
|
||||
## Output Format
|
||||
When you have completed the task, wrap your final output in task_complete tags:
|
||||
|
||||
<task_complete>
|
||||
Your complete output here
|
||||
</task_complete>
|
||||
|
||||
## Guidelines
|
||||
1. Analyze the task requirements carefully
|
||||
2. Provide a complete and accurate response
|
||||
3. Always wrap your final output in <task_complete></task_complete> tags
|
||||
4. If you need clarification, ask using <needs_clarification>your question</needs_clarification>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the conversation state
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user