Skip to content

Commit

Permalink
Fix iteration count handling and improve error logging in CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
laiso committed Jan 12, 2025
1 parent f03fb4f commit 8cf887c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ For more information about tasks, you can read the documentation in the docs/ di

let iterationCount = 0;
while (currentToolUseBlock && iterationCount < maxIterations) {
iterationCount++;
if (currentToolUseBlock) {
console.log({ currentToolUseBlock });
}
Expand All @@ -100,11 +101,13 @@ For more information about tasks, you can read the documentation in the docs/ di
CallToolResultSchema,
);
} catch (error) {
console.error('Error calling tool:', error);
const mcpError = new McpError((error as any).code, (error as any).message, (error as any).data);
conversationMessages.push({
role: 'user',
content: `ToolUser: ${JSON.stringify(currentToolUseBlock)}, Error: ${mcpError.message}`,
});
currentToolUseBlock = undefined;
continue;
}

Expand All @@ -130,8 +133,6 @@ For more information about tasks, you can read the documentation in the docs/ di
conversationMessages = result.messages;
return result.toolUseBlock;
});

iterationCount++;
}

const mcpClients = new Set(toolServerMap.values());
Expand Down

0 comments on commit 8cf887c

Please sign in to comment.