Toolpacks
Toolpacks provide a way to group related tools together. This is useful for organizing your tools and controlling their availability within a conversation. Instead of listing every single tool directly in the system prompt, you can expose logical groups that the LLM can choose to activate.
Defining a Toolpack
Similar to Tool
, you use a fluent API starting with Toolpack.make()
.
Configuration Methods
.make(name: string)
: (Static) Starts defining a toolpack with a unique name (letters, numbers, underscores)..description(description: string)
: Sets a description for the entire toolpack, explaining the capabilities it provides. Alias: .desc()..addTool(tool: Tool)
: Adds a single, already defined Tool instance to the pack..addTools(tools: Tool[])
: Adds an array of Tool instances to the pack.
Using Toolpacks in Conversation
When you include a Toolpack instance in your conversation.content() definition, the framework handles it differently than a direct Tool:
Automatic enable_toolpack Tool: If any Toolpack is defined in the content, @obayd/agentic automatically adds a built-in tool named enable_toolpack.
Toolpack Listing in Prompt: The system prompt will list the available toolpacks (along with their descriptions and whether they are currently enabled or disabled) instead of listing every tool within those packs initially.
Enabling Workflow:
The LLM decides it needs a capability provided by a disabled toolpack (based on the pack's description).
The LLM calls the enable_toolpack tool, providing the pack_name parameter.
The Conversation executes this internal tool, adding the specified pack name to the conversation.enabledToolpacks set.
A success message is returned to the LLM in the next turn .
Crucially: The LLM must wait for this success message before attempting to use tools from the newly enabled pack.
Using Enabled Tools
Once a toolpack is enabled (either initially via initialEnabledToolpacks option or via the enable_toolpack tool), its contained tools become available for the LLM to call directly in subsequent turns, just like tools added directly to the content.
Benefits of Toolpacks
Scalability: Keeps the initial system prompt cleaner when you have many tools.
Organization: Groups related functionalities logically.
Control: Allows for dynamic enabling/disabling of capabilities during a conversation.
Contextual Relevance: The LLM only activates tools when needed for a specific task group.
Last updated