Skip to content

Python: BaseTool class is not exported in _tools.py #1620

@anguzo

Description

@anguzo

Description

The BaseTool class is defined in the codebase but is not exported in the module's __all__ list, making it impossible to import directly. While duck typing with ToolProtocol should work, I think this base class should be importable.

Current Behavior

Users cannot import the class:

from agent_framework import BaseTool  # ✗ ImportError or not discoverable

Expected Behavior

Users should be able to import and use the base class:

from agent_framework import BaseTool  # ✓ Should work

Why This Matters

  • BaseTool is the recommended base class for creating custom tools
  • The documentation and examples show inheriting from BaseTool, but it's not exported

Current all (from tools.py)

__all__ = [
    "FUNCTION_INVOKING_CHAT_CLIENT_MARKER",
    "AIFunction",
    "HostedCodeInterpreterTool",
    "HostedFileSearchTool",
    "HostedMCPSpecificApproval",
    "HostedMCPTool",
    "HostedWebSearchTool",
    "ToolProtocol",
    "ai_function",
    "use_function_invocation",
]

Suggested Fix

Add BaseTool to __all__:

__all__ = [
    "FUNCTION_INVOKING_CHAT_CLIENT_MARKER",
    "AIFunction",
    "BaseTool",  # Add this
    "HostedCodeInterpreterTool",
    # ... rest of exports
]

Metadata

Metadata

Labels

model clientsIssues related to the model client implementationspython

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions