Skip to content

Commit f333256

Browse files
updated
1 parent acfa5dc commit f333256

File tree

8 files changed

+483
-57
lines changed

8 files changed

+483
-57
lines changed

src/agentlib/agent.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Agent {
5656

5757
this.tools = [
5858
...this.tools,
59-
...(mentaionedMCPSTool || []),
59+
...mentaionedMCPSTool||[],
6060

6161
]
6262
let mentionedAgents = await task.userMessage.getMentionedAgents();
@@ -155,12 +155,9 @@ class Agent {
155155

156156
}
157157
else {
158-
console.log("Executing tool: ", toolName, toolInput);
159158
const [didUserReject, result] = await this.executeTool(toolName, toolInput);
160-
console.log("Tool result: ", result);
161159
// toolResults.push(this.getToolResult(toolUseId, result));
162160
let toolResult = this.getToolResult(toolUseId, result)
163-
164161
toolResults.push({
165162
role: "tool",
166163
tool_call_id: toolResult.tool_call_id,
@@ -223,7 +220,7 @@ class Agent {
223220
toolResults.push({
224221
role: "tool",
225222
tool_call_id: toolResult.tool_call_id,
226-
content: toolResult.content?.trim() ? toolResult.content : "Tool executed successfully.",
223+
content: toolResult.content,
227224

228225
});
229226
if (toolResult.userMessage) {
@@ -285,8 +282,6 @@ class Agent {
285282

286283
try {
287284
let systemPrompt = await this.systemPrompt.toPromptText();
288-
289-
//TODO: append remix prompt from user
290285
const aiMessages: Message[] = [
291286
{ role: "system", content: systemPrompt },
292287
...apiConversationHistory,
@@ -313,14 +308,13 @@ class Agent {
313308
* @param toolInput - The input parameters for the tool
314309
* @returns Promise with tuple [userRejected, result]
315310
*/
316-
private async executeTool(toolName: string, toolInput: any): Promise<[boolean, any]> {
311+
private async executeTool(toolName: string, toolInput: any): Promise<any> {
317312
//codebolttools--readfile
318-
console.log("Executing tool: ", toolName, toolInput);
319313
const [toolboxName, actualToolName] = toolName.split('--');
320314
console.log("Toolbox name: ", toolboxName, "Actual tool name: ", actualToolName);
321315
const {data} = await tools.executeTool(toolboxName, actualToolName, toolInput);
322316
console.log("Tool result: ", data);
323-
return [false, data];
317+
return data;
324318
}
325319

326320
/**
@@ -360,7 +354,6 @@ class Agent {
360354
try {
361355
let parsed = JSON.parse(content);
362356

363-
console.log("Parsed Content: ", parsed);
364357
if (parsed.payload && parsed.payload.content) {
365358
content = `The browser action has been executed. The screenshot have been captured for your analysis. The tool response is provided in the next user message`
366359
// this.apiConversationHistory.push()
@@ -372,7 +365,7 @@ class Agent {
372365
return {
373366
role: "tool",
374367
tool_call_id,
375-
content: content === "" ? "tool call success" : (Array.isArray(content) ? content[1] : content),
368+
content,
376369
userMessage
377370
};
378371
}

src/agentlib/llmoutputhandler.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -424,24 +424,16 @@ class LLMOutputHandler {
424424
* @param toolInput - The input parameters for the tool
425425
* @returns Promise with tuple [userRejected, result]
426426
*/
427-
private async executeTool(toolName: string, toolInput: any): Promise<[boolean, any]> {
428-
console.log("Executing tool: ", toolName, toolInput);
427+
private async executeTool(toolName: string, toolInput: any): Promise<any> {
428+
//codebolttools--readfile
429429
const [toolboxName, actualToolName] = toolName.split('--');
430430
console.log("Toolbox name: ", toolboxName, "Actual tool name: ", actualToolName);
431-
const response = await this.codebolt?.mcp.executeTool(toolboxName, actualToolName, toolInput);
432-
console.log("Tool result form inner function: ", response);
433-
434-
// Handle the response structure
435-
if (!response || !response.data) {
436-
return [false, "Tool execution failed: No response data"];
437-
}
438-
439-
440-
441-
// Otherwise, assume success and return the data
442-
return response.data;
431+
const data = await this.codebolt?.mcp.executeTool(toolboxName, actualToolName, toolInput);
432+
console.log("Tool result: ", data);
433+
return data;
443434
}
444435

436+
445437
/**
446438
* Creates a tool result object from the tool execution response.
447439
*

src/core/Codebolt.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ class Codebolt {
133133
messageId: response.message.messageId,
134134
threadId: response.message.threadId,
135135
selection: response.message.selection,
136-
remixPrompt:response.message.remixPrompt
136+
remixPrompt:response.message.remixPrompt,
137+
mentionedAgents:response.message.mentionedAgents
137138
};
138139

139140
const result = await handler(userMessage);

0 commit comments

Comments
 (0)