From e54b841d4b38ff2a080a7678bb67d8fdd9c2f42e Mon Sep 17 00:00:00 2001 From: Deepika Mamidipelly Date: Thu, 24 Sep 2026 10:31:57 -0700 Subject: [PATCH 1/2] fix(docs): correct async example in BetaAsyncAbstractMemoryTool docstring The class docstring was copy-pasted from the sync BetaAbstractMemoryTool: subclassing the wrong base class raised TypeError at instantiation, the override methods were sync instead of async, and the sample used the sync Anthropic client with a removed run_tools API. Use BetaAsyncAbstractMemoryTool, async def methods, and AsyncAnthropic with the current tool_runner API. --- .../lib/tools/_beta_builtin_memory_tool.py | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/anthropic/lib/tools/_beta_builtin_memory_tool.py b/src/anthropic/lib/tools/_beta_builtin_memory_tool.py index 0405b46a2..d515b781e 100644 --- a/src/anthropic/lib/tools/_beta_builtin_memory_tool.py +++ b/src/anthropic/lib/tools/_beta_builtin_memory_tool.py @@ -176,25 +176,40 @@ class BetaAsyncAbstractMemoryTool(BetaAsyncBuiltinFunctionTool): Example usage: ```py - class MyMemoryTool(BetaAbstractMemoryTool): - def view(self, command: BetaMemoryTool20250818ViewCommand) -> BetaFunctionToolResultType: + import asyncio + + from anthropic import AsyncAnthropic + from anthropic.lib.tools import BetaFunctionToolResultType + from anthropic.tools import BetaAsyncAbstractMemoryTool + from anthropic.types.beta import ( + BetaMemoryTool20250818ViewCommand, + BetaMemoryTool20250818CreateCommand, + ) + + + class MyMemoryTool(BetaAsyncAbstractMemoryTool): + async def view(self, command: BetaMemoryTool20250818ViewCommand) -> BetaFunctionToolResultType: ... return "view result" - def create(self, command: BetaMemoryTool20250818CreateCommand) -> BetaFunctionToolResultType: + async def create(self, command: BetaMemoryTool20250818CreateCommand) -> BetaFunctionToolResultType: ... return "created successfully" # ... implement other abstract methods - client = Anthropic() - memory_tool = MyMemoryTool() - message = client.beta.messages.run_tools( - model="claude-sonnet-4-5", - messages=[{"role": "user", "content": "Remember that I like coffee"}], - tools=[memory_tool], - ).until_done() + async def main() -> None: + client = AsyncAnthropic() + memory_tool = MyMemoryTool() + message = await client.beta.messages.tool_runner( + model="claude-sonnet-4-5", + messages=[{"role": "user", "content": "Remember that I like coffee"}], + tools=[memory_tool], + ).until_done() + + + asyncio.run(main()) ``` """ From 2bb5cc38adb8540b01fc5239268f890dd099e248 Mon Sep 17 00:00:00 2001 From: Deepika Mamidipelly Date: Thu, 24 Sep 2026 10:32:37 -0700 Subject: [PATCH 2/2] fix(docs): use tool_runner in sync memory tool docstring example The sync BetaAbstractMemoryTool docstring also referenced the removed client.beta.messages.run_tools API (renamed to tool_runner). --- src/anthropic/lib/tools/_beta_builtin_memory_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anthropic/lib/tools/_beta_builtin_memory_tool.py b/src/anthropic/lib/tools/_beta_builtin_memory_tool.py index d515b781e..c481a6191 100644 --- a/src/anthropic/lib/tools/_beta_builtin_memory_tool.py +++ b/src/anthropic/lib/tools/_beta_builtin_memory_tool.py @@ -77,7 +77,7 @@ def create(self, command: BetaMemoryTool20250818CreateCommand) -> BetaFunctionTo client = Anthropic() memory_tool = MyMemoryTool() - message = client.beta.messages.run_tools( + message = client.beta.messages.tool_runner( model="claude-sonnet-4-5", messages=[{"role": "user", "content": "Remember that I like coffee"}], tools=[memory_tool],