Shared Tools
Shared tools are reusable tool implementations that can be made available to multiple agents, workflows, or applications within a BindAI project. BindAI does not require a specialSharedTool class. Instead, sharing is achieved by reusing normal BindAI tool implementations and, at the project level, registering them through the project’s tool registry.
This provides a simple foundation for reusing business capabilities without duplicating tool implementations.
What Are Shared Tools?
A shared tool is a normal BindAI tool that is intentionally reused by multiple consumers. Conceptually:Why Use Shared Tools?
Without reusable tools, applications may duplicate the same functionality. For example:- Less code duplication
- Consistent behavior
- Centralized maintenance
- Easier testing
- Reusable business logic
- Simpler upgrades
Project Tool Registry
A BindAIProject owns a tool registry:
Adding a Shared Tool to a Project
A reusable tool can be registered with a project:Project.add_tool() returns the project, allowing chained project construction:
Sharing a Tool Between Agents
A tool implementation can also be supplied directly to multiple agents. For example:Shared Tools and Applications
A project can contain multiple applications:SharedTool abstraction.
Shared Tools and Workflows
Tools can participate in workflow execution as well as agent execution. Conceptually:Shared Tools vs Local Tools
Not every tool needs to be shared.
If a tool is only used once, keeping it close to the agent or workflow that owns it may be simpler.
Typical Shared Tools
Common candidates for reuse include:- Database queries
- Search
- Document retrieval
- Email delivery
- Calendar operations
- File storage
- CRM operations
- Internal APIs
- Notification services
- Data transformation
- Analytics utilities
Shared Tools and Connections
A shared tool can use a BindAI Connection to communicate with an external service. For example:bindai-connections package.
Shared Tools and Knowledge
Knowledge retrieval can be exposed through reusable tools when an application benefits from tool-based access. For example:Shared Tools and Memory
A shared tool can interact with memory when the application explicitly provides the required memory capability. For example:Tool Interfaces
Shared tools should have stable and understandable interfaces. A reusable tool should generally provide:- A clear name
- Explicit parameters
- Useful type hints
- A focused responsibility
- A descriptive docstring
- Predictable results
- Safe error handling
Avoiding Hidden Dependencies
Shared tools should avoid unnecessary hidden global state. Prefer explicit inputs:Configuration
Shared tools may require configuration such as:- API endpoints
- Database connections
- Service identifiers
- Feature settings
- Environment-specific behavior
Security
Shared tools can expose powerful capabilities. Examples include:- Database writes
- Customer data access
- File operations
- Payment operations
- External API calls
- Administrative actions
- Input validation
- Authorization
- Least privilege
- Sensitive-data handling
- Safe error messages
- Audit logging
- Rate limiting
- Idempotency for important operations
Read vs Write Tools
A useful distinction is between read-only and state-changing operations.Read
Write
Idempotency
Shared tools that perform external side effects should consider idempotency. For example:- Idempotency keys
- Duplicate detection
- Stable operation identifiers
- Transactional behavior
Versioning
A shared tool may have many consumers. For example:- Preserve compatibility when possible.
- Test important consumers.
- Document interface changes.
- Avoid unnecessary breaking changes.
- Introduce new interfaces deliberately.
Performance
Frequently used shared tools should be designed with performance in mind. Consider:- Caching
- Connection pooling
- Batching
- Async execution where appropriate
- Reducing unnecessary network calls
- Avoiding repeated expensive computation
Error Handling
Shared tools should return predictable results and handle failures safely. Potential failures include:- Invalid input
- Network errors
- Authentication failures
- External service errors
- Database errors
- Rate limits
- Timeouts
Testing Shared Tools
Shared tools should be tested independently of the agents that consume them. Recommended tests include:- Valid inputs
- Invalid inputs
- Boundary cases
- External-service failures
- Authentication failures
- Timeouts
- Duplicate requests
- Side effects
- Security restrictions
Reuse Across Agents
A shared tool should remain independent of a particular agent. Good:Organizing Shared Tools
As a project grows, tools can be organized into logical modules. For example:Shared Tools and Middleware
Shared tools can be used alongside agent middleware and other execution controls. For example:When Not to Share a Tool
Sharing is not always the right choice. Keep a tool local when:- It is highly specific to one agent.
- Its interface changes frequently.
- Its behavior depends heavily on local state.
- Its permissions are unique to one application.
- Reuse would introduce unnecessary coupling.
Best Practices
- Share tools that represent genuinely reusable capabilities.
- Keep each tool focused on one responsibility.
- Use explicit parameters and type hints.
- Keep shared interfaces stable.
- Avoid hidden global state.
- Separate configuration from implementation.
- Protect sensitive operations.
- Prefer least-privilege access.
- Make external side effects idempotent where possible.
- Test shared tools independently.
- Document breaking changes.
- Keep tool organization modular.
Current BindAI Scope
The current BindAI project model provides a concrete project-level tool registry. AProject initializes:
SharedTool class.
Instead, shared tools are normal BindAI tools that are registered or attached wherever they are needed.
Project-Level Tool Registration
A typical project can register a reusable tool like this:API Accuracy
The verified project-level APIs are:Project.add_tool() registers the supplied tool with the project’s tool registry and returns the project instance.
The project also provides:
Summary
Shared tools are reusable BindAI tool implementations that can serve multiple agents, workflows, or applications. The project model provides a concrete project-level tool registry:SharedTool runtime abstraction to support this pattern.
Project-level registration, reusable tool implementations, explicit interfaces, controlled permissions, and independent testing provide the foundation for effective tool sharing.