Skip to content

Commit 442d579

Browse files
ryoppippiCopilot
andauthored
refactor(tools): rename meta tools to utility tools with tool_* prefix [ENG-11958] (#310)
* refactor(tools): rename meta tools to utility tools with tool_* prefix Rename tool naming convention to avoid confusion with Facebook's Meta brand. The "meta_*" prefix was ambiguous and could be misinterpreted. File renames: - examples/meta-tools.ts -> examples/utility-tools.ts Tool name changes: - meta_search_tools -> tool_search - meta_execute_tool -> tool_execute - meta_collect_tool_feedback -> tool_feedback API changes: - Tools.metaTools() -> Tools.utilityTools() Internal type renames: - MetaToolSearchResult -> ToolSearchResult All tests pass (220 passed) and linting passes. * Update src/tool.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix(tests): update test descriptions from 'meta tools' to 'utility tools' Address PR review comments to make test descriptions consistent with the refactoring to use 'utility tools' terminology throughout: - Update comment for mock tools creation function - Fix 4 test descriptions that still referenced 'meta tools' --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5dfb48e commit 442d579

8 files changed

Lines changed: 148 additions & 151 deletions

File tree

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,18 +355,18 @@ This is especially useful when you want to:
355355

356356
[View full example](examples/fetch-tools.ts)
357357

358-
### Meta Tools (Beta)
358+
### Utility Tools (Beta)
359359

360-
Meta tools enable dynamic tool discovery and execution, allowing AI agents to search for relevant tools based on natural language queries without hardcoding tool names.
360+
Utility tools enable dynamic tool discovery and execution, allowing AI agents to search for relevant tools based on natural language queries without hardcoding tool names.
361361

362-
> **Beta Feature**: Meta tools are currently in beta and the API may change in future versions.
362+
> **Beta Feature**: Utility tools are currently in beta and the API may change in future versions.
363363
364-
#### How Meta Tools Work
364+
#### How Utility Tools Work
365365

366-
Meta tools provide two core capabilities:
366+
Utility tools provide two core capabilities:
367367

368-
1. **Tool Discovery** (`meta_search_tools`): Search for tools using natural language queries
369-
2. **Tool Execution** (`meta_execute_tool`): Execute discovered tools dynamically
368+
1. **Tool Discovery** (`tool_search`): Search for tools using natural language queries
369+
2. **Tool Execution** (`tool_execute`): Execute discovered tools dynamically
370370

371371
#### Basic Usage
372372

@@ -378,14 +378,14 @@ const toolset = new StackOneToolSet({
378378
});
379379
const tools = await toolset.fetchTools();
380380

381-
// Get meta tools for dynamic discovery
382-
const metaTools = await tools.metaTools();
381+
// Get utility tools for dynamic discovery
382+
const utilityTools = await tools.utilityTools();
383383

384384
// Use with OpenAI
385-
const openAITools = metaTools.toOpenAI();
385+
const openAITools = utilityTools.toOpenAI();
386386

387387
// Use with AI SDK
388-
const aiSdkTools = await metaTools.toAISDK();
388+
const aiSdkTools = await utilityTools.toAISDK();
389389
```
390390

391391
#### Example: Dynamic Tool Discovery with AI SDK
@@ -406,15 +406,15 @@ const { text } = await generateText({
406406

407407
```typescript
408408
// Step 1: Discover relevant tools
409-
const filterTool = metaTools.getTool('meta_search_tools');
409+
const filterTool = utilityTools.getTool('tool_search');
410410
const searchResult = await filterTool.execute({
411411
query: 'employee time off vacation',
412412
limit: 5,
413413
minScore: 0.3, // Minimum relevance score (0-1)
414414
});
415415

416416
// Step 2: Execute a discovered tool
417-
const executeTool = metaTools.getTool('meta_execute_tool');
417+
const executeTool = utilityTools.getTool('tool_execute');
418418
const result = await executeTool.execute({
419419
toolName: 'bamboohr_create_time_off',
420420
params: {
@@ -425,7 +425,7 @@ const result = await executeTool.execute({
425425
});
426426
```
427427

428-
[View full example](examples/meta-tools.ts)
428+
[View full example](examples/utility-tools.ts)
429429

430430
### Custom Base URL
431431

@@ -473,7 +473,7 @@ The `dryRun` option returns an object containing:
473473

474474
### Feedback Collection Tool
475475

476-
The StackOne AI SDK includes a built-in feedback collection tool (`meta_collect_tool_feedback`) that allows users to provide feedback on their experience with StackOne tools. This tool is automatically included when using `fetchTools()` and helps improve the SDK based on user input.
476+
The StackOne AI SDK includes a built-in feedback collection tool (`tool_feedback`) that allows users to provide feedback on their experience with StackOne tools. This tool is automatically included when using `fetchTools()` and helps improve the SDK based on user input.
477477

478478
#### How It Works
479479

@@ -498,7 +498,7 @@ const toolset = new StackOneToolSet({
498498
const tools = await toolset.fetchTools();
499499

500500
// The feedback tool is automatically included
501-
const feedbackTool = tools.getTool('meta_collect_tool_feedback');
501+
const feedbackTool = tools.getTool('tool_feedback');
502502

503503
// Use with AI agents - they will ask for user consent first
504504
const openAITools = tools.toOpenAI();
@@ -512,7 +512,7 @@ You can also use the feedback tool directly:
512512

513513
```typescript
514514
// Get the feedback tool
515-
const feedbackTool = tools.getTool('meta_collect_tool_feedback');
515+
const feedbackTool = tools.getTool('tool_feedback');
516516

517517
// Submit feedback (after getting user consent)
518518
const result = await feedbackTool.execute({

examples/fetch-tools.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('fetch-tools example e2e', () => {
6666
expect(toolsByProviders.length).toBeGreaterThan(0);
6767
const providerToolNames = toolsByProviders.toArray().map((t) => t.name);
6868
expect(
69-
providerToolNames.every((name) => name.startsWith('bamboohr_') || name.startsWith('meta_')),
69+
providerToolNames.every((name) => name.startsWith('bamboohr_') || name.startsWith('tool_')),
7070
).toBe(true);
7171

7272
// Example 5: Filter by actions with exact match
@@ -85,7 +85,7 @@ describe('fetch-tools example e2e', () => {
8585
});
8686
const globToolNames = toolsByGlobPattern
8787
.toArray()
88-
.filter((t) => !t.name.startsWith('meta_'))
88+
.filter((t) => !t.name.startsWith('tool_'))
8989
.map((t) => t.name);
9090
expect(globToolNames).toContain('bamboohr_list_employees');
9191

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* This example demonstrates how to use meta tools for dynamic tool discovery and execution.
3-
* Meta tools allow AI agents to search for relevant tools based on natural language queries
2+
* This example demonstrates how to use utility tools for dynamic tool discovery and execution.
3+
* Utility tools allow AI agents to search for relevant tools based on natural language queries
44
* and execute them dynamically without hardcoding tool names.
55
*
6-
* @beta Meta tools are in beta and may change in future versions
6+
* @beta Utility tools are in beta and may change in future versions
77
*/
88

99
import process from 'node:process';
@@ -21,9 +21,9 @@ if (!apiKey) {
2121
const accountId = 'your-bamboohr-account-id';
2222

2323
/**
24-
* Example 1: Using meta tools with AI SDK for dynamic tool discovery
24+
* Example 1: Using utility tools with AI SDK for dynamic tool discovery
2525
*/
26-
const metaToolsWithAISDK = async (): Promise<void> => {
26+
const utilityToolsWithAISDK = async (): Promise<void> => {
2727
console.log('🔍 Example 1: Dynamic tool discovery with AI SDK\n');
2828

2929
// Initialize StackOne toolset
@@ -35,14 +35,14 @@ const metaToolsWithAISDK = async (): Promise<void> => {
3535
// Fetch all available tools via MCP
3636
const allTools = await toolset.fetchTools();
3737

38-
// Get meta tools for dynamic discovery and execution
39-
const metaTools = await allTools.metaTools();
40-
const aiSdkMetaTools = await metaTools.toAISDK();
38+
// Get utility tools for dynamic discovery and execution
39+
const utilityTools = await allTools.utilityTools();
40+
const aiSdkUtilityTools = await utilityTools.toAISDK();
4141

42-
// Use meta tools to dynamically find and execute relevant tools
42+
// Use utility tools to dynamically find and execute relevant tools
4343
const { text, toolCalls } = await generateText({
4444
model: openai('gpt-5.1'),
45-
tools: aiSdkMetaTools,
45+
tools: aiSdkUtilityTools,
4646
prompt: `I need to create a time off request for an employee.
4747
First, find the right tool for this task, then use it to create a time off request
4848
for employee ID "emp_123" from January 15, 2024 to January 19, 2024.`,
@@ -54,9 +54,9 @@ const metaToolsWithAISDK = async (): Promise<void> => {
5454
};
5555

5656
/**
57-
* Example 2: Using meta tools with OpenAI for HR assistant
57+
* Example 2: Using utility tools with OpenAI for HR assistant
5858
*/
59-
const metaToolsWithOpenAI = async (): Promise<void> => {
59+
const utilityToolsWithOpenAI = async (): Promise<void> => {
6060
console.log('\n🤖 Example 2: HR Assistant with OpenAI\n');
6161

6262
const { OpenAI } = await import('openai');
@@ -75,9 +75,9 @@ const metaToolsWithOpenAI = async (): Promise<void> => {
7575
actions: ['bamboohr_*'],
7676
});
7777

78-
// Get meta tools
79-
const metaTools = await bamboohrTools.metaTools();
80-
const openAIMetaTools = metaTools.toOpenAI();
78+
// Get utility tools
79+
const utilityTools = await bamboohrTools.utilityTools();
80+
const openAIUtilityTools = utilityTools.toOpenAI();
8181

8282
// Create an HR assistant that can discover and use tools dynamically
8383
const response = await openaiClient.chat.completions.create({
@@ -86,16 +86,16 @@ const metaToolsWithOpenAI = async (): Promise<void> => {
8686
{
8787
role: 'system',
8888
content: `You are an HR assistant with access to various HR tools.
89-
Use the meta_search_tools to find appropriate tools for user requests,
90-
then use meta_execute_tool to execute them.`,
89+
Use the tool_search to find appropriate tools for user requests,
90+
then use tool_execute to execute them.`,
9191
},
9292
{
9393
role: 'user',
9494
content:
9595
'Can you help me find tools for managing employee records and then list current employees?',
9696
},
9797
],
98-
tools: openAIMetaTools,
98+
tools: openAIUtilityTools,
9999
tool_choice: 'auto',
100100
});
101101

@@ -113,10 +113,10 @@ const metaToolsWithOpenAI = async (): Promise<void> => {
113113
};
114114

115115
/**
116-
* Example 3: Direct usage of meta tools without AI
116+
* Example 3: Direct usage of utility tools without AI
117117
*/
118-
const directMetaToolUsage = async (): Promise<void> => {
119-
console.log('\n🛠️ Example 3: Direct meta tool usage\n');
118+
const directUtilityToolUsage = async (): Promise<void> => {
119+
console.log('\n🛠️ Example 3: Direct utility tool usage\n');
120120

121121
// Initialize toolset
122122
const toolset = new StackOneToolSet({
@@ -128,12 +128,12 @@ const directMetaToolUsage = async (): Promise<void> => {
128128
const allTools = await toolset.fetchTools();
129129
console.log(`Total available tools: ${allTools.length}`);
130130

131-
// Get meta tools
132-
const metaTools = await allTools.metaTools();
131+
// Get utility tools
132+
const utilityTools = await allTools.utilityTools();
133133

134134
// Step 1: Search for relevant tools
135-
const filterTool = metaTools.getTool('meta_search_tools');
136-
if (!filterTool) throw new Error('meta_search_tools not found');
135+
const filterTool = utilityTools.getTool('tool_search');
136+
if (!filterTool) throw new Error('tool_search not found');
137137
const searchResult = await filterTool.execute({
138138
query: 'employee management create update list',
139139
limit: 5,
@@ -152,8 +152,8 @@ const directMetaToolUsage = async (): Promise<void> => {
152152

153153
// Step 2: Execute one of the found tools
154154
if (foundTools.length > 0) {
155-
const executeTool = metaTools.getTool('meta_execute_tool');
156-
if (!executeTool) throw new Error('meta_execute_tool not found');
155+
const executeTool = utilityTools.getTool('tool_execute');
156+
if (!executeTool) throw new Error('tool_execute not found');
157157
const firstTool = foundTools[0];
158158

159159
console.log(`\nExecuting ${firstTool.name}...`);
@@ -205,14 +205,14 @@ const dynamicToolRouter = async (): Promise<void> => {
205205
// Combine tools
206206
const combinedTools = new Tools([...bamboohrTools.toArray(), ...workdayTools.toArray()]);
207207

208-
// Get meta tools for the combined set
209-
const metaTools = await combinedTools.metaTools();
208+
// Get utility tools for the combined set
209+
const utilityTools = await combinedTools.utilityTools();
210210

211211
// Create a router function that finds and executes tools based on intent
212212
const routeAndExecute = async (intent: string, params: JsonObject = {}) => {
213-
const filterTool = metaTools.getTool('meta_search_tools');
214-
const executeTool = metaTools.getTool('meta_execute_tool');
215-
if (!filterTool || !executeTool) throw new Error('Meta tools not found');
213+
const filterTool = utilityTools.getTool('tool_search');
214+
const executeTool = utilityTools.getTool('tool_execute');
215+
if (!filterTool || !executeTool) throw new Error('Utility tools not found');
216216

217217
// Find relevant tools
218218
const searchResult = await filterTool.execute({
@@ -258,14 +258,14 @@ const main = async () => {
258258
try {
259259
// Run examples based on environment setup
260260
if (process.env.OPENAI_API_KEY) {
261-
await metaToolsWithAISDK();
262-
await metaToolsWithOpenAI();
261+
await utilityToolsWithAISDK();
262+
await utilityToolsWithOpenAI();
263263
} else {
264264
console.log('⚠️ OPENAI_API_KEY not found, skipping AI examples\n');
265265
}
266266

267267
// These examples work without AI
268-
await directMetaToolUsage();
268+
await directUtilityToolUsage();
269269
await dynamicToolRouter();
270270
} catch (error) {
271271
console.error('Error running examples:', error);
@@ -277,4 +277,4 @@ if (import.meta.main) {
277277
await main();
278278
}
279279

280-
export { metaToolsWithAISDK, metaToolsWithOpenAI, directMetaToolUsage, dynamicToolRouter };
280+
export { utilityToolsWithAISDK, utilityToolsWithOpenAI, directUtilityToolUsage, dynamicToolRouter };

src/feedback.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface FeedbackResult {
1818
results: FeedbackResultItem[];
1919
}
2020

21-
describe('meta_collect_tool_feedback', () => {
21+
describe('tool_feedback', () => {
2222
describe('validation tests', () => {
2323
it('test_missing_required_fields', async () => {
2424
const tool = createFeedbackTool();
@@ -274,7 +274,7 @@ describe('meta_collect_tool_feedback', () => {
274274
it('test_tool_integration', async () => {
275275
// Test tool properties
276276
const tool = createFeedbackTool();
277-
expect(tool.name).toBe('meta_collect_tool_feedback');
277+
expect(tool.name).toBe('tool_feedback');
278278
expect(tool.description).toContain('Collects user feedback');
279279
expect(tool.parameters).toBeDefined();
280280

@@ -283,7 +283,7 @@ describe('meta_collect_tool_feedback', () => {
283283
expect(openaiFormat).toMatchObject({
284284
type: 'function',
285285
function: {
286-
name: 'meta_collect_tool_feedback',
286+
name: 'tool_feedback',
287287
description: expect.stringContaining('Collects user feedback'),
288288
parameters: expect.objectContaining({
289289
type: 'object',

src/feedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function createFeedbackTool(
4747
accountId,
4848
baseUrl,
4949
};
50-
const name = 'meta_collect_tool_feedback' as const;
50+
const name = 'tool_feedback' as const;
5151
const description =
5252
'Collects user feedback on StackOne tool performance. First ask the user, "Are you ok with sending feedback to StackOne?" and mention that the LLM will take care of sending it. Call this tool only when the user explicitly answers yes.';
5353
const parameters = {

0 commit comments

Comments
 (0)