Summary
Implement configurable tool profiles to selectively load tools based on use case, reducing context bloat from tool definitions.
Problem
When many tools are registered:
- Tool definitions consume significant context tokens
- Not all tools are relevant for every conversation
- LLM may get confused with too many options
- Increases latency and costs
Proposed Solution
Configuration Options
interface ToolProfileConfig {
enabled?: boolean; // Default: false (load all tools)
defaultProfile?: string; // Default profile to use
profiles?: Record<string, ToolProfile>;
dynamicSelection?: {
enabled?: boolean; // Auto-select tools based on context
maxTools?: number; // Max tools to include
};
}
interface ToolProfile {
name: string;
description?: string;
include?: string[]; // Tool names or groups to include
exclude?: string[]; // Tool names or groups to exclude
}
// Usage
const chat = createChatWithTools({
toolProfiles: {
enabled: true,
defaultProfile: 'coding',
profiles: {
minimal: {
include: ['search', 'read_file'],
},
coding: {
include: ['group:filesystem', 'group:code', 'search'],
exclude: ['admin_tools'],
},
full: {
// Include everything (default behavior)
},
}
}
});
// Switch profile at runtime
chat.setToolProfile('minimal');
Tool Groups
const myTool: ToolDefinition = {
name: 'read_file',
group: 'filesystem', // Assign to group
profiles: ['coding', 'full'], // Or specify profiles directly
// ...
};
// Built-in groups
// 'filesystem' - file operations
// 'code' - code analysis, execution
// 'web' - search, fetch
// 'memory' - context, persistence
// 'admin' - sensitive operations
Dynamic Tool Selection (Optional)
toolProfiles: {
dynamicSelection: {
enabled: true,
maxTools: 10,
// Automatically select most relevant tools based on:
// - Recent conversation context
// - User's current request
// - Tool usage history
}
}
Use Cases
- Chatbots: Minimal tools (search, FAQ)
- Coding assistants: File, code, and debug tools
- Admin panels: Include sensitive admin tools
- Context-aware: Dynamic selection based on conversation
Benefits
- ✅ Fully optional - disabled by default
- ✅ Configurable profiles - define once, switch easily
- ✅ Reduces context usage from tool definitions
- ✅ Improves LLM focus with relevant tools only
- ✅ Runtime profile switching
- ✅ Tool grouping for easier management
Summary
Implement configurable tool profiles to selectively load tools based on use case, reducing context bloat from tool definitions.
Problem
When many tools are registered:
Proposed Solution
Configuration Options
Tool Groups
Dynamic Tool Selection (Optional)
Use Cases
Benefits