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

  1. added a commit that references this issue on Mar 25, 2026
    091e868
  2. khalidsaidi commented on Mar 26, 2026

    @khalidsaidi
  3. added a commit that references this issue on Mar 28, 2026
    fd68645
  4. added a commit that references this issue on Mar 29, 2026
    3f0bf79
  5. added a commit that references this issue on Apr 5, 2026
    f673050
  6. added 2 commits that reference this issue on Apr 6, 2026
    244dc6e
    cf442ba
  7. nightcityblade commented on Apr 10, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  8. nightcityblade commented on Oct 5, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  9. nightcityblade commented on Oct 5, 2026

    @nightcityblade

    Unclaiming this issue: #1291 already covers the fix, so I closed my duplicate #1981. Sorry for missing the existing linked PR.

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