Skip to content

BetaAsyncAbstractMemoryTool docstring contains sync-only example (copy-paste from sync class) #1290

Description

@mmporong

Bug report

The BetaAsyncAbstractMemoryTool class docstring in src/anthropic/lib/tools/_beta_builtin_memory_tool.py (lines 159-188) contains a usage example that was copy-pasted from the synchronous BetaAbstractMemoryTool without being updated for async usage. Following the example verbatim raises TypeError at instantiation time.

Three errors in the docstring example

1. Wrong base class (line 169):

# Current (broken)
class MyMemoryTool(BetaAbstractMemoryTool):  # sync base class

# Should be
class MyMemoryTool(BetaAsyncAbstractMemoryTool):

2. Sync method definitions instead of async (lines 170, 174):

# Current (broken)
def view(self, command: ...) -> BetaFunctionToolResultType:
def create(self, command: ...) -> BetaFunctionToolResultType:

# Should be
async def view(self, command: ...) -> BetaFunctionToolResultType:
async def create(self, command: ...) -> BetaFunctionToolResultType:

3. Sync client instead of async (lines 181-187):

# Current (broken)
client = Anthropic()
message = client.beta.messages.run_tools(...)

# Should be
client = AsyncAnthropic()
# with await and async def main()

Expected behavior

The docstring example for the async class should use BetaAsyncAbstractMemoryTool as base class, async def methods, and AsyncAnthropic() client — matching async conventions.

Evidence this is a copy-paste error

The sync counterpart BetaAbstractMemoryTool docstring (lines 46-76 in the same file) is correctly written. The async class docstring is a verbatim copy that was never updated.

Suggested fix

Update the BetaAsyncAbstractMemoryTool docstring to:

  • Change base class to BetaAsyncAbstractMemoryTool
  • Add async keyword to all method definitions
  • Replace Anthropic() with AsyncAnthropic()
  • Wrap usage in async def main() / asyncio.run(main())

Happy to submit a PR if helpful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions