anthropics / anthropics/anthropic-sdk-python
BetaAsyncAbstractMemoryTool docstring contains sync-only example (copy-paste from sync class)
- Linguagem predominante
- Python
- Estrelas
- 3.9k
- Forks
- 853
- Merge médio
- 1d 18h
- PRs com merge (30d)
- 11
Descrição
## 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):**
```python
# Current (broken)
class MyMemoryTool(BetaAbstractMemoryTool): # sync base class
# Should be
class MyMemoryTool(BetaAsyncAbstractMemoryTool):
```
**2. Sync method definitions instead of async (lines 170, 174):**
```python
# 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):**
```python
# 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.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.