Skip to content

fix: update BetaAsyncAbstractMemoryTool docstring for async usage#1291

Open
mmporong wants to merge 1 commit intoanthropics:mainfrom
mmporong:fix/async-memory-tool-docstring
Open

fix: update BetaAsyncAbstractMemoryTool docstring for async usage#1291
mmporong wants to merge 1 commit intoanthropics:mainfrom
mmporong:fix/async-memory-tool-docstring

Conversation

@mmporong
Copy link
Copy Markdown

Summary

The BetaAsyncAbstractMemoryTool docstring example was copy-pasted from the sync BetaAbstractMemoryTool without being updated for async usage. Following the example verbatim raises TypeError at instantiation time.

Changes

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

Fixes #1290

The docstring example was copy-pasted from the sync BetaAbstractMemoryTool
without being updated. Following the example verbatim raises TypeError
at instantiation time.

Changes:
- Use BetaAsyncAbstractMemoryTool as base class (not BetaAbstractMemoryTool)
- Add async keyword to method definitions
- Replace Anthropic() with AsyncAnthropic()
- Wrap usage in async def main() / asyncio.run(main())

Fixes anthropics#1290
Copy link
Copy Markdown
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

Comment on lines +186 to 197
async def main() -> None:
client = AsyncAnthropic()
memory_tool = MyMemoryTool()
message = await client.beta.messages.run_tools(
model="claude-sonnet-4-5",
messages=[{"role": "user", "content": "Remember that I like coffee"}],
tools=[memory_tool],
).until_done()


asyncio.run(main())
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we generally assume the code snippet is already being ran in an async context, so you can remove the asyncio usage and the main() function wrapper.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants