fix: update BetaAsyncAbstractMemoryTool docstring for async usage#1291
Open
mmporong wants to merge 1 commit intoanthropics:mainfrom
Open
fix: update BetaAsyncAbstractMemoryTool docstring for async usage#1291mmporong wants to merge 1 commit intoanthropics:mainfrom
mmporong wants to merge 1 commit intoanthropics:mainfrom
Conversation
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
RobertCraigie
approved these changes
Mar 25, 2026
Collaborator
RobertCraigie
left a comment
There was a problem hiding this comment.
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()) | ||
| ``` |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
BetaAsyncAbstractMemoryTooldocstring example was copy-pasted from the syncBetaAbstractMemoryToolwithout being updated for async usage. Following the example verbatim raisesTypeErrorat instantiation time.Changes
BetaAsyncAbstractMemoryToolas base class (notBetaAbstractMemoryTool)asynckeyword to method definitionsAnthropic()withAsyncAnthropic()async def main()/asyncio.run(main())Fixes #1290