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.
Bug report
The
BetaAsyncAbstractMemoryToolclass docstring insrc/anthropic/lib/tools/_beta_builtin_memory_tool.py(lines 159-188) contains a usage example that was copy-pasted from the synchronousBetaAbstractMemoryToolwithout being updated for async usage. Following the example verbatim raisesTypeErrorat instantiation time.Three errors in the docstring example
1. Wrong base class (line 169):
2. Sync method definitions instead of async (lines 170, 174):
3. Sync client instead of async (lines 181-187):
Expected behavior
The docstring example for the async class should use
BetaAsyncAbstractMemoryToolas base class,async defmethods, andAsyncAnthropic()client — matching async conventions.Evidence this is a copy-paste error
The sync counterpart
BetaAbstractMemoryTooldocstring (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
BetaAsyncAbstractMemoryTooldocstring to:BetaAsyncAbstractMemoryToolasynckeyword to all method definitionsAnthropic()withAsyncAnthropic()async def main()/asyncio.run(main())Happy to submit a PR if helpful.